Skip to content

Bugfix: sort variant #111

@HPCguy

Description

@HPCguy

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;
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions