public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/45232]  New: Several passes introduce undefined overflow
@ 2010-08-08 12:31 rguenth at gcc dot gnu dot org
  2010-08-08 12:35 ` [Bug tree-optimization/45232] " rguenth at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-08 12:31 UTC (permalink / raw)
  To: gcc-bugs

Fold:

extern void abort (void);
int i = 1;
int main()
{
 if ((i - 1) - (-__INT_MAX__ - 1) != (-__INT_MAX__ - 1))
   abort ();
 return 0;
}

Forwprop (and reassoc with -fno-tree-forwprop) at -O1:

extern void abort (void);
int i = 1;
int main()
{
 int j = i - 1;
 j = j - (-__INT_MAX__ - 1);
 if (j != (-__INT_MAX__ - 1))
   abort ();
 return 0;
}

Not so VRP itself (it doesn't derive ranges from VARYING +- CST for
signed arithmetic).


-- 
           Summary: Several passes introduce undefined overflow
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug tree-optimization/45232] Several passes introduce undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
@ 2010-08-08 12:35 ` rguenth at gcc dot gnu dot org
  2010-08-08 12:55 ` [Bug tree-optimization/45232] Tree reassociation introduces " rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-08 12:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-08-08 12:35 -------
Err.  Exchange - (-__INT_MAX__ - 1) for + (-__INT_MAX__ - 1) and see that
fold is fine and only reassoc is broken, but requires a way more complex
testcase.

extern void abort (void);
int i = 1;
int main()
{
  int j = i - 1;
  j = j + (-__INT_MAX__ - 1);
  if (j != (-__INT_MAX__ - 1))
    abort ();
  return 0;
}

$ diff -u t.c.084t.dse1 t.c.085t.reassoc1 
--- t.c.084t.dse1       2010-08-08 14:34:08.000000000 +0200
+++ t.c.085t.reassoc1   2010-08-08 14:34:08.000000000 +0200
@@ -8,8 +17,7 @@

 <bb 2>:
   i.0_1 = i;
-  j_2 = i.0_1 + -1;
-  j_3 = j_2 + -2147483648;
+  j_3 = i.0_1 + 2147483647;
   if (j_3 != -2147483648)
     goto <bb 3>;
   else


-- 


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


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

* [Bug tree-optimization/45232] Tree reassociation introduces undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
  2010-08-08 12:35 ` [Bug tree-optimization/45232] " rguenth at gcc dot gnu dot org
@ 2010-08-08 12:55 ` rguenth at gcc dot gnu dot org
  2010-08-08 22:42 ` ebotcazou at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-08 12:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-08-08 12:55 -------
Created an attachment (id=21436)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21436&action=view)
prototype patch


-- 


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


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

* [Bug tree-optimization/45232] Tree reassociation introduces undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
  2010-08-08 12:35 ` [Bug tree-optimization/45232] " rguenth at gcc dot gnu dot org
  2010-08-08 12:55 ` [Bug tree-optimization/45232] Tree reassociation introduces " rguenth at gcc dot gnu dot org
@ 2010-08-08 22:42 ` ebotcazou at gcc dot gnu dot org
  2010-08-10  9:24 ` [Bug tree-optimization/45232] [4.6 regression] tree " rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-08-08 22:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ebotcazou at gcc dot gnu dot org  2010-08-08 22:42 -------
Responsible for the couple of ACATS regressions on 64-bit platforms:
  http://gcc.gnu.org/ml/gcc-testresults/2010-08/msg00848.html


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-08 22:42:06
               date|                            |


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


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

* [Bug tree-optimization/45232] [4.6 regression] tree reassociation introduces undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-08-08 22:42 ` ebotcazou at gcc dot gnu dot org
@ 2010-08-10  9:24 ` rguenth at gcc dot gnu dot org
  2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
  2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-10  9:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-08-10 09:24 -------
The patch doens't work - we have to disable a lot more reassociation which
isn't really allowed for types with undefined overflow.  There are a bunch
of invalid testcases in the testsuite as well.

We might be able to recover some of the regressions by teaching our tree
combiner of some tricks.  It looks like that will delay a fix for this
PR somewhat, but I'm working on it ...


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-08-08 22:42:06         |2010-08-10 09:24:08
               date|                            |
   Target Milestone|---                         |4.6.0


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


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

* [Bug tree-optimization/45232] [4.6 regression] tree reassociation introduces undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
@ 2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-12 10:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-08-12 10:38 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

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


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


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

* [Bug tree-optimization/45232] [4.6 regression] tree reassociation introduces undefined overflow
  2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-08-10  9:24 ` [Bug tree-optimization/45232] [4.6 regression] tree " rguenth at gcc dot gnu dot org
@ 2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
  2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-12 10:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2010-08-12 10:38 -------
Subject: Bug 45232

Author: rguenth
Date: Thu Aug 12 10:38:05 2010
New Revision: 163190

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163190
Log:
2010-08-12  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/45232
        * tree-ssa-reassoc.c (can_reassociate_p): Disable re-association
        for types with undefined overflow.
        (reassociate_bb): Allow re-associating of bit and min/max
        operations for types with undefined overflow.
        * tree-ssa-forwprop.c (associate_plusminus): New function.
        (tree_ssa_forward_propagate_single_use_vars): Call it.

        * gcc.dg/tree-ssa/pr44133.c: Adjust warning location.
        * gcc.dg/tree-ssa/loop-7.c: Adjust.
        * gcc.dg/tree-ssa/reassoc-1.c: XFAIL.
        * gcc.dg/tree-ssa/reassoc-20.c: Add reassoc-1.c variant with
        unsigned arithmetic.
        * gcc.dg/tree-ssa/reassoc-14.c: Use unsigned arithmetic.
        * gcc.dg/tree-ssa/reassoc-15.c: Likewise.
        * gcc.dg/tree-ssa/reassoc-18.c: Likewise.
        * gcc.dg/tree-ssa/reassoc-2.c: XFAIL.
        * gcc.dg/tree-ssa/reassoc-21.c: Add reassoc-2.c variant with
        unsigned arithmetic.
        * gcc.dg/tree-ssa/reassoc-6.c: XFAIL.
        * gcc.dg/tree-ssa/reassoc-22.c: Add reassoc-6.c variant with
        unsigned arithmetic.
        * gcc.dg/tree-ssa/reassoc-7.c: Use unsigned arithmetic.
        * gcc.dg/tree-ssa/reassoc-9.c: XFAIL.
        * gcc.dg/tree-ssa/reassoc-23.c: Add reassoc-9.c variant with
        unsigned arithmetic.
        * gcc.dg/tree-ssa/ssa-pre-2.c: Adjust.
        * gcc.dg/tree-ssa/negate.c: Adjust.
        * gcc.dg/vect/vect-1.c: Adjust.
        * gfortran.dg/reassoc_6.f: XFAIL.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-20.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-21.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-22.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-23.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/tree-ssa/loop-7.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/negate.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr44133.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-1.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-14.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-15.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-18.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-2.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-6.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-7.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/reassoc-9.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-2.c
    trunk/gcc/testsuite/gcc.dg/vect/vect-1.c
    trunk/gcc/testsuite/gfortran.dg/reassoc_6.f
    trunk/gcc/tree-ssa-forwprop.c
    trunk/gcc/tree-ssa-reassoc.c


-- 


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


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

end of thread, other threads:[~2010-08-12 10:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-08 12:31 [Bug tree-optimization/45232] New: Several passes introduce undefined overflow rguenth at gcc dot gnu dot org
2010-08-08 12:35 ` [Bug tree-optimization/45232] " rguenth at gcc dot gnu dot org
2010-08-08 12:55 ` [Bug tree-optimization/45232] Tree reassociation introduces " rguenth at gcc dot gnu dot org
2010-08-08 22:42 ` ebotcazou at gcc dot gnu dot org
2010-08-10  9:24 ` [Bug tree-optimization/45232] [4.6 regression] tree " rguenth at gcc dot gnu dot org
2010-08-12 10:38 ` rguenth at gcc dot gnu dot org
2010-08-12 10:38 ` rguenth at gcc dot gnu dot 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).