Squint
Squint copied to clipboard
Bugfix: sort variant
Optimizer bug needs to be fixed for this test case (optimizer effectively creates a NOP!):
#include <stdio.h>
#include <stdlib.h>
void bubblesort(float *c, int n)
{
float v1, v2;
int i, done;
do {
done = 1; // --n;
v1 = c[0];
for (i=1; i<n; ++i) {
v2 = c[i];
if (v1 > v2) {
c[i-1] = v2;
c[i] = v1;
done = 0;
}
else
v1 = v2;
}
} while (!done);
}
int main()
{
int i;
float val[20];
for (i=0; i<20; ++i)
val[i] = (float) rand();
bubblesort(val, 20);
for (i=0; i<20; ++i)
printf("%f\n", val[i]);
printf("\n");
return 0;
}