public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41919]  New: optimized code with -O2 or -O3 gives strange result
@ 2009-11-03  5:09 chenyang at cs dot utah dot edu
  2009-11-03 10:48 ` [Bug tree-optimization/41919] [4.5 Regression] " rguenth at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: chenyang at cs dot utah dot edu @ 2009-11-03  5:09 UTC (permalink / raw)
  To: gcc-bugs

Using r153799, got strange result with the code below. The expected result is
-104. 

yang@yang-working:~$ svngcc -O3 -o small3 small.c
yang@yang-working:~$ ./small3
2
yang@yang-working:~$ svngcc -O2 -o small2 small.c
yang@yang-working:~$ ./small2
2
yang@yang-working:~$ svngcc -O1 -o small1 small.c
yang@yang-working:~$ ./small1
-104
yang@yang-working:~$ cat small.c
#include <stdio.h>
#include <assert.h>

struct S1
{
  char f0;
};

int g_23 = 0;

static struct S1 foo (void)
{
  int *l_100 = &g_23;
  int **l_110 = &l_100;
  struct S1 l_128 = {
    1
  };
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  assert (l_100 == &g_23);
  return l_128;
}

static char bar(char si1, char si2)
{
  return (si1 <= 0) ? si1 : (si2 * 2);
}

int main (void)
{
  struct S1 s = foo();
  printf("%d\n", bar(0x99 ^ (s.f0 && 1), 1));
  return 0;
}

yang@yang-working:~$ svngcc -v
Using built-in specs.
COLLECT_GCC=svngcc
COLLECT_LTO_WRAPPER=/home/yang/compilers/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-lto --prefix=/home/yang/compilers
--program-prefix=svn --enable-languages=c,c++
--with-libelf=/home/yang/compilers : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,lto,c++ --no-create
--no-recursion : (reconfigured) ../configure --enable-lto
--prefix=/home/yang/compilers --program-prefix=svn
--with-libelf=/home/yang/compilers --enable-languages=c,c++,lto --no-create
--no-recursion
Thread model: posix
gcc version 4.5.0 20091102 (experimental) (GCC)


-- 
           Summary: optimized code with -O2 or -O3 gives strange result
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chenyang at cs dot utah dot edu
 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=41919


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
@ 2009-11-03 10:48 ` rguenth at gcc dot gnu dot org
  2009-11-03 16:06 ` 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 @ 2009-11-03 10:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-11-03 10:48 -------
It's VRP which does

si1_12: [-104, -104]

Folding statement: if (si1_12 > 0)
Simplified relational if (si1_12 > 0)
 into if (si1_12 == -104)

uh.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |tree-optimization
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to work|                            |4.4.2
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-03 10:48:06
               date|                            |
            Summary|optimized code with -O2 or -|[4.5 Regression] optimized
                   |O3 gives strange result     |code with -O2 or -O3 gives
                   |                            |strange result
   Target Milestone|---                         |4.5.0


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
  2009-11-03 10:48 ` [Bug tree-optimization/41919] [4.5 Regression] " rguenth at gcc dot gnu dot org
@ 2009-11-03 16:06 ` rguenth at gcc dot gnu dot org
  2009-11-03 16:26 ` 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 @ 2009-11-03 16:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2009-11-03 16:05 -------
Mine.


-- 

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|2009-11-03 10:48:06         |2009-11-03 16:05:48
               date|                            |


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
  2009-11-03 10:48 ` [Bug tree-optimization/41919] [4.5 Regression] " rguenth at gcc dot gnu dot org
  2009-11-03 16:06 ` rguenth at gcc dot gnu dot org
@ 2009-11-03 16:26 ` rguenth at gcc dot gnu dot org
  2009-11-03 16:41 ` rguenth 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 @ 2009-11-03 16:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-11-03 16:25 -------
Jeff promised to look at this.  I can't make sense of test_for_singularity
and the appearant mismatch of EQ_EXPR vs. NE_EXPR when generating the
test substitution.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|rguenth at gcc dot gnu dot  |law at gcc dot gnu dot org
                   |org                         |


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
                   ` (2 preceding siblings ...)
  2009-11-03 16:26 ` rguenth at gcc dot gnu dot org
@ 2009-11-03 16:41 ` rguenth at gcc dot gnu dot org
  2009-11-04 10:19 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-03 16:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2009-11-03 16:41 -------
I'll take it back as I have a patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|law at gcc dot gnu dot org  |rguenth at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
                   ` (3 preceding siblings ...)
  2009-11-03 16:41 ` rguenth at gcc dot gnu dot org
@ 2009-11-04 10:19 ` rguenth at gcc dot gnu dot org
  2009-11-04 10:24 ` 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 @ 2009-11-04 10:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2009-11-04 10:18 -------
Subject: Bug 41919

Author: rguenth
Date: Wed Nov  4 10:18:33 2009
New Revision: 153891

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

        PR tree-optimization/41919
        * tree-vrp.c (test_for_singularity): Properly compare values.

        * gcc.c-torture/execute/pr41919.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr41919.c
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c


-- 


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
                   ` (4 preceding siblings ...)
  2009-11-04 10:19 ` rguenth at gcc dot gnu dot org
@ 2009-11-04 10:24 ` rguenth at gcc dot gnu dot org
  2009-11-04 10:35 ` rguenth at gcc dot gnu dot org
  2009-11-20 14:52 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-04 10:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2009-11-04 10:24 -------
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=41919


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
                   ` (5 preceding siblings ...)
  2009-11-04 10:24 ` rguenth at gcc dot gnu dot org
@ 2009-11-04 10:35 ` rguenth at gcc dot gnu dot org
  2009-11-20 14:52 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-04 10:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2009-11-04 10:35 -------
Subject: Bug 41919

Author: rguenth
Date: Wed Nov  4 10:35:04 2009
New Revision: 153893

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

        PR tree-optimization/41919
        * tree-vrp.c (test_for_singularity): Properly compare values.

        * gcc.c-torture/execute/pr41919.c: New testcase.

Modified:
    trunk/gcc/ChangeLog


-- 


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


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

* [Bug tree-optimization/41919] [4.5 Regression] optimized code with -O2 or -O3 gives strange result
  2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
                   ` (6 preceding siblings ...)
  2009-11-04 10:35 ` rguenth at gcc dot gnu dot org
@ 2009-11-20 14:52 ` hjl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: hjl at gcc dot gnu dot org @ 2009-11-20 14:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from hjl at gcc dot gnu dot org  2009-11-20 14:50 -------
Subject: Bug 41919

Author: hjl
Date: Fri Nov 20 14:49:22 2009
New Revision: 154366

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154366
Log:
2009-11-20  H.J. Lu  <hongjiu.lu@intel.com>

        Backport from mainline:
        2009-11-18  Alexandre Oliva  <aoliva@redhat.com>

        PR debug/41926
        * gcc.dg/vect/vect-debug-pr41926.c: New.

        2009-11-16  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/42055
        * g++.dg/template/crash92.C: New.

        2009-11-08  Richard Guenther  <rguenther@suse.de>

        PR rtl-optimization/41928
        * gfortran.dg/pr41928.f90: New testcase.

        2009-11-06  Jakub Jelinek  <jakub@redhat.com>

        PR middle-end/41935
        * gcc.dg/pr41935.c: New test.
        * c-c++-common/pr41935.c: New test.
        * gcc.c-torture/execute/pr41935.c: New test.

        2009-11-04  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/41919
        * gcc.c-torture/execute/pr41919.c: New testcase.

        2009-11-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41907
        * gfortran.dg/missing_optional_dummy_6.f90: New test.

        2009-11-02  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/41750
        * gcc.c-torture/execute/pr41750.c: New test.

        2009-11-02  Jakub Jelinek  <jakub@redhat.com>

        PR tree-optimization/41841
        * gcc.dg/pr41841.c: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/c-c++-common/pr41935.c
      - copied unchanged from r154365,
trunk/gcc/testsuite/c-c++-common/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/crash92.C
      - copied unchanged from r154365,
trunk/gcc/testsuite/g++.dg/template/crash92.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41750.c
      - copied unchanged from r154365,
trunk/gcc/testsuite/gcc.c-torture/execute/pr41750.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41919.c
      - copied unchanged from r154365,
trunk/gcc/testsuite/gcc.c-torture/execute/pr41919.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41935.c
      - copied unchanged from r154365,
trunk/gcc/testsuite/gcc.c-torture/execute/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41841.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.dg/pr41841.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41935.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.dg/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/vect-debug-pr41926.c
      - copied unchanged from r154365,
trunk/gcc/testsuite/gcc.dg/vect/vect-debug-pr41926.c
   
branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/missing_optional_dummy_6.f90
      - copied unchanged from r154365,
trunk/gcc/testsuite/gfortran.dg/missing_optional_dummy_6.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr41928.f90
      - copied unchanged from r154365,
trunk/gcc/testsuite/gfortran.dg/pr41928.f90
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2009-11-20 14:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-03  5:09 [Bug c/41919] New: optimized code with -O2 or -O3 gives strange result chenyang at cs dot utah dot edu
2009-11-03 10:48 ` [Bug tree-optimization/41919] [4.5 Regression] " rguenth at gcc dot gnu dot org
2009-11-03 16:06 ` rguenth at gcc dot gnu dot org
2009-11-03 16:26 ` rguenth at gcc dot gnu dot org
2009-11-03 16:41 ` rguenth at gcc dot gnu dot org
2009-11-04 10:19 ` rguenth at gcc dot gnu dot org
2009-11-04 10:24 ` rguenth at gcc dot gnu dot org
2009-11-04 10:35 ` rguenth at gcc dot gnu dot org
2009-11-20 14:52 ` hjl 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).