http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56962



             Bug #: 56962

           Summary: [4.8/4.9 Regression] SLSR caused miscompilation of

                    fftw

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Keywords: wrong-code

          Severity: normal

          Priority: P3

         Component: tree-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: ja...@gcc.gnu.org





Reduced testcase:

extern void abort (void);

long double v[144];



__attribute__((noinline, noclone)) void

bar (long double *x)

{

  if (x != &v[29])

    abort ();

}



__attribute__((noinline, noclone)) void

foo (long double *x, long y, long z)

{

  long double a, b, c;

  a = x[z * 4 + y * 3];

  b = x[z * 5 + y * 3];

  c = x[z * 5 + y * 4];

  x[y * 4] = a;

  bar (&x[z * 5 + y]);

  x[z * 5 + y * 5] = b + c;

}



int

main ()

{

  foo (v, 24, 1);

  return 0;

}



This fails at -O2, works with -O2 -fno-tree-slsr.  Started with

http://gcc.gnu.org/r190220



The *.reassoc2 to *.slsr diff with unimportant stuff removed:

...

   _2 = z_1(D) * 4;

   _4 = y_3(D) * 3;

   _5 = _2 + _4;

...

   _12 = z_1(D) * 5;

-  _13 = _4 + _12;   

+  _13 = _5 + z_1(D);

...

   _18 = y_3(D) * 4;

-  _19 = _12 + _18; 

+  _19 = _13 + y_3(D);

...

-  _28 = y_3(D) + _12;

+  _28 = _19 - _5;

...



Here before slsr we have:

_5 = y*3+z*4    

_13 = y*3+z*5

_19 = y*4+z*5    

_28 = y+z*5

and the _13 and _19 changes look just fine, but the _28 change is changing the

value from y+z*5 to y+z.

Reply via email to