public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/56962] [4.8/4.9 Regression] SLSR caused miscompilation of fftw
  2013-04-15  8:25 [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw jakub at gcc dot gnu.org
@ 2013-04-15  8:25 ` jakub at gcc dot gnu.org
  2013-04-15 10:15 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-15  8:25 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |wschmidt at gcc dot gnu.org
   Target Milestone|---                         |4.8.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw
@ 2013-04-15  8:25 jakub at gcc dot gnu.org
  2013-04-15  8:25 ` [Bug tree-optimization/56962] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-15  8:25 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: jakub@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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56962] [4.8/4.9 Regression] SLSR caused miscompilation of fftw
  2013-04-15  8:25 [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw jakub at gcc dot gnu.org
  2013-04-15  8:25 ` [Bug tree-optimization/56962] " jakub at gcc dot gnu.org
@ 2013-04-15 10:15 ` jakub at gcc dot gnu.org
  2013-04-15 13:19 ` wschmidt at gcc dot gnu.org
  2013-04-15 15:02 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-15 10:15 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-04-15
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-15 10:15:16 UTC ---
Created attachment 29873
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29873
gcc49-pr56962.patch

Untested fix.  CAND_ADD can apparently be set even on c->cand_stmt which isn't
a addition (e.g. cast of the addition etc.), plus by just silently assuming
that if rhs1 isn't equal to c->base_expr, then rhs2 is, doesn't work in all
cases.
In particular, c->cand_stmt can be e.g. addition of two SSA_NAMEs where each
one of those adds in some part, not equal to c->base_expr.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56962] [4.8/4.9 Regression] SLSR caused miscompilation of fftw
  2013-04-15  8:25 [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw jakub at gcc dot gnu.org
  2013-04-15  8:25 ` [Bug tree-optimization/56962] " jakub at gcc dot gnu.org
  2013-04-15 10:15 ` jakub at gcc dot gnu.org
@ 2013-04-15 13:19 ` wschmidt at gcc dot gnu.org
  2013-04-15 15:02 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: wschmidt at gcc dot gnu.org @ 2013-04-15 13:19 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Bill Schmidt <wschmidt at gcc dot gnu.org> 2013-04-15 13:19:53 UTC ---
The fix looks correct to me.  Thanks!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/56962] [4.8/4.9 Regression] SLSR caused miscompilation of fftw
  2013-04-15  8:25 [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw jakub at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-04-15 13:19 ` wschmidt at gcc dot gnu.org
@ 2013-04-15 15:02 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-15 15:02 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-15 15:02:43 UTC ---
Author: jakub
Date: Mon Apr 15 14:56:36 2013
New Revision: 197978

URL: http://gcc.gnu.org/viewcvs?rev=197978&root=gcc&view=rev
Log:
    PR tree-optimization/56962
    * gimple-ssa-strength-reduction.c (record_increment): Only set
    initializer if gimple_assign_rhs_code is {,POINTER_}PLUS_EXPR and
    either rhs1 or rhs2 is equal to c->base_expr.

    * gcc.c-torture/execute/pr56962.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr56962.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-strength-reduction.c
    trunk/gcc/testsuite/ChangeLog

Author: jakub
Date: Mon Apr 15 15:00:06 2013
New Revision: 197979

URL: http://gcc.gnu.org/viewcvs?rev=197979&root=gcc&view=rev
Log:
    PR tree-optimization/56962
    * gimple-ssa-strength-reduction.c (record_increment): Only set
    initializer if gimple_assign_rhs_code is {,POINTER_}PLUS_EXPR and
    either rhs1 or rhs2 is equal to c->base_expr.

    * gcc.c-torture/execute/pr56962.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr56962.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/gimple-ssa-strength-reduction.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-15 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15  8:25 [Bug tree-optimization/56962] New: [4.8/4.9 Regression] SLSR caused miscompilation of fftw jakub at gcc dot gnu.org
2013-04-15  8:25 ` [Bug tree-optimization/56962] " jakub at gcc dot gnu.org
2013-04-15 10:15 ` jakub at gcc dot gnu.org
2013-04-15 13:19 ` wschmidt at gcc dot gnu.org
2013-04-15 15:02 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).