public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/35833]  New: Wrong code generated with -ftree-vrp
@ 2008-04-05 14:08 qrczak at knm dot org dot pl
  2008-04-05 16:18 ` [Bug tree-optimization/35833] " rguenth at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: qrczak at knm dot org dot pl @ 2008-04-05 14:08 UTC (permalink / raw)
  To: gcc-bugs

This is not vanilla 4.3.0 but gcc-4_3-branch from 
2008-03-13.

Here is a source:

struct S {struct S *field;};
extern struct S True, False, Z;
static inline int f(void) {return 1;}
static inline int g(struct S **obj) {
   return f() && *obj == &Z;
}
struct S **h(struct S **x) {
   if (x)
      return g(x) ? &True.field : &False.field;
   else
      return &True.field;
}

"gcc -S -O -ftree-vrp bug.c" produces the following code for h:

h:
        pushl   %ebp
        movl    $True, %eax
        movl    %esp, %ebp
        leave
        ret

This is obviously wrong: there are condidions when it should return
&False.field.

The bug is not triggered without -ftree-vrp, or after minor modifications like
manually inlining f() or g(). A correct code:

h:
        pushl   %ebp
        movl    $True, %eax
        movl    %esp, %ebp
        movl    8(%ebp), %edx
        testl   %edx, %edx
        je      .L3
        cmpl    $Z, (%edx)
        movl    $True, %eax
        je      .L3
        movl    $False, %eax
.L3:
        leave
        ret


-- 
           Summary: Wrong code generated with -ftree-vrp
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qrczak at knm dot org dot pl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug tree-optimization/35833] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
@ 2008-04-05 16:18 ` rguenth at gcc dot gnu dot org
  2008-04-05 16:18 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 16:18 UTC (permalink / raw)
  To: gcc-bugs



-- 

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|2008-04-05 16:17:17         |2008-04-05 16:17:39
               date|                            |


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


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

* [Bug tree-optimization/35833] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
  2008-04-05 16:18 ` [Bug tree-optimization/35833] " rguenth at gcc dot gnu dot org
@ 2008-04-05 16:18 ` rguenth at gcc dot gnu dot org
  2008-04-05 16:39 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 16:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-04-05 16:17 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2008-04-05 16:17:17
               date|                            |


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


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

* [Bug tree-optimization/35833] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
  2008-04-05 16:18 ` [Bug tree-optimization/35833] " rguenth at gcc dot gnu dot org
  2008-04-05 16:18 ` rguenth at gcc dot gnu dot org
@ 2008-04-05 16:39 ` rguenth at gcc dot gnu dot org
  2008-04-05 16:53 ` [Bug tree-optimization/35833] [4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-04-05 16:38 -------
On the mailine this fixed it:

2008-03-27  Richard Guenther  <rguenther@suse.de>

        * fold-const.c (target.h): Include.
        (fold_comparison): Fold comparison of addresses of decls
        that bind locally or of constants.  Consolidate address folding code.
        * tree-vrp.c (operand_less_p): Deal with non-INTEGER_CST
        results from fold_binary_to_constant.
        (compare_values_warnv): Likewise.


-- 


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


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

* [Bug tree-optimization/35833] [4.3 Regression] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
                   ` (2 preceding siblings ...)
  2008-04-05 16:39 ` rguenth at gcc dot gnu dot org
@ 2008-04-05 16:53 ` pinskia at gcc dot gnu dot org
  2008-04-05 18:02 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-05 16:53 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major
      Known to fail|                            |4.3.0
      Known to work|                            |4.4.0 4.0.0
            Summary|Wrong code generated with - |[4.3 Regression] Wrong code
                   |ftree-vrp                   |generated with -ftree-vrp
   Target Milestone|---                         |4.3.1


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


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

* [Bug tree-optimization/35833] [4.3 Regression] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
                   ` (3 preceding siblings ...)
  2008-04-05 16:53 ` [Bug tree-optimization/35833] [4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2008-04-05 18:02 ` rguenth at gcc dot gnu dot org
  2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-04-05 18:01 -------
Subject: Bug 35833

Author: rguenth
Date: Sat Apr  5 18:01:14 2008
New Revision: 133940

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133940
Log:
2008-04-05  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/35833
        * tree-vrp.c (operand_less_p): Deal with non-INTEGER_CST
        results from fold_binary_to_constant.
        (compare_values_warnv): Likewise.

        * gcc.dg/torture/pr35833.c: New testcase.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/torture/pr35833.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/tree-vrp.c


-- 


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


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

* [Bug tree-optimization/35833] [4.3 Regression] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
                   ` (5 preceding siblings ...)
  2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
@ 2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
  2008-04-08 22:10 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 18:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-04-05 18:04 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to work|4.4.0 4.0.0                 |4.4.0 4.2.3 4.0.0
         Resolution|                            |FIXED


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


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

* [Bug tree-optimization/35833] [4.3 Regression] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
                   ` (4 preceding siblings ...)
  2008-04-05 18:02 ` rguenth at gcc dot gnu dot org
@ 2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
  2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
  2008-04-08 22:10 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-05 18:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2008-04-05 18:04 -------
Subject: Bug 35833

Author: rguenth
Date: Sat Apr  5 18:04:07 2008
New Revision: 133941

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133941
Log:
2008-04-05  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/35833
        * gcc.dg/torture/pr35833.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr35833.c
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug tree-optimization/35833] [4.3 Regression] Wrong code generated with -ftree-vrp
  2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
                   ` (6 preceding siblings ...)
  2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
@ 2008-04-08 22:10 ` rguenth at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-08 22:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2008-04-08 22:09 -------
Subject: Bug 35833

Author: rguenth
Date: Tue Apr  8 22:07:20 2008
New Revision: 134111

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134111
Log:
2008-04-05  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/35833
        * tree-vrp.c (operand_less_p): Deal with non-INTEGER_CST
        results from fold_binary_to_constant.
        (compare_values_warnv): Likewise.

        * gcc.dg/torture/pr35833.c: New testcase.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/20080408-1.c
      - copied unchanged from r134108,
trunk/gcc/testsuite/gcc.c-torture/execute/20080408-1.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/fold-const.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2008-04-08 22:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-05 14:08 [Bug tree-optimization/35833] New: Wrong code generated with -ftree-vrp qrczak at knm dot org dot pl
2008-04-05 16:18 ` [Bug tree-optimization/35833] " rguenth at gcc dot gnu dot org
2008-04-05 16:18 ` rguenth at gcc dot gnu dot org
2008-04-05 16:39 ` rguenth at gcc dot gnu dot org
2008-04-05 16:53 ` [Bug tree-optimization/35833] [4.3 Regression] " pinskia at gcc dot gnu dot org
2008-04-05 18:02 ` rguenth at gcc dot gnu dot org
2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
2008-04-05 18:05 ` rguenth at gcc dot gnu dot org
2008-04-08 22:10 ` 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).