public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51023] New: likely integer wrong code bug
@ 2011-11-08  5:54 regehr at cs dot utah.edu
  2011-11-08  6:47 ` [Bug c/51023] " regehr at cs dot utah.edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: regehr at cs dot utah.edu @ 2011-11-08  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51023
           Summary: likely integer wrong code bug
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: regehr@cs.utah.edu


Seen on Ubuntu 10.04.3.  The "-O0" result is correct.

[regehr@gamow tmp049]$ current-gcc -O0 small.c  ; ./a.out 
0
[regehr@gamow tmp049]$ current-gcc -O1 small.c  ; ./a.out 
1
[regehr@gamow tmp049]$ current-gcc -v

Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r181147-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto
--prefix=/home/regehr/z/compiler-install/gcc-r181147-install
--program-prefix=r181147- --enable-languages=c,c++
Thread model: posix
gcc version 4.7.0 20111108 (experimental) (GCC) 

[regehr@gamow tmp049]$ cat small.c


int printf (const char *, ...);

struct {
  int f0;
} g_24;

short func_11 (int si1)
{
  return si1;
}

int main ()
{
  int l_141 = 0x4272A;
  g_24.f0 = func_11 (l_141) == l_141;
  printf ("%d\n", g_24.f0);
  return 0;
}


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

* [Bug c/51023] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
@ 2011-11-08  6:47 ` regehr at cs dot utah.edu
  2011-11-08 10:26 ` [Bug rtl-optimization/51023] [4.7 Regression] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: regehr at cs dot utah.edu @ 2011-11-08  6:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from John Regehr <regehr at cs dot utah.edu> 2011-11-08 05:53:57 UTC ---
Slightly smaller testcase:

int printf (const char *, ...);

short func_11 (int si1) {
  return si1;
}

int main () {
  int l_141 = 0x4272A;
  printf ("%d\n", func_11 (l_141) == l_141);
  return 0;
}


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

* [Bug rtl-optimization/51023] [4.7 Regression] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
  2011-11-08  6:47 ` [Bug c/51023] " regehr at cs dot utah.edu
@ 2011-11-08 10:26 ` rguenth at gcc dot gnu.org
  2011-11-08 23:15 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-11-08 10:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.6.2
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2011-11-08
          Component|c                           |rtl-optimization
     Ever Confirmed|0                           |1
            Summary|likely integer wrong code   |[4.7 Regression] likely
                   |bug                         |integer wrong code bug
   Target Milestone|---                         |4.7.0

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-11-08 10:24:33 UTC ---
Confirmed.  RTL optimization optimizes the comparison in main.


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

* [Bug rtl-optimization/51023] [4.7 Regression] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
  2011-11-08  6:47 ` [Bug c/51023] " regehr at cs dot utah.edu
  2011-11-08 10:26 ` [Bug rtl-optimization/51023] [4.7 Regression] " rguenth at gcc dot gnu.org
@ 2011-11-08 23:15 ` jakub at gcc dot gnu.org
  2011-11-09  9:42 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-08 23:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-08 23:09:52 UTC ---
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175917


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

* [Bug rtl-optimization/51023] [4.7 Regression] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
                   ` (2 preceding siblings ...)
  2011-11-08 23:15 ` jakub at gcc dot gnu.org
@ 2011-11-09  9:42 ` jakub at gcc dot gnu.org
  2011-11-10 16:02 ` jakub at gcc dot gnu.org
  2011-11-10 17:29 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-09  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-09 09:39:28 UTC ---
Created attachment 25765
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25765
gcc47-pr51023.patch

Part of that patch is clearly bogus, as const_op here is a constant in wider
mode than the inner mode of SIGN_EXTEND, thus before the comparison checked
not just that the sign bit is clear, but also any bits above it.

The simplify_set change from the same patch is questionable too.


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

* [Bug rtl-optimization/51023] [4.7 Regression] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
                   ` (3 preceding siblings ...)
  2011-11-09  9:42 ` jakub at gcc dot gnu.org
@ 2011-11-10 16:02 ` jakub at gcc dot gnu.org
  2011-11-10 17:29 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-10 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-10 15:36:52 UTC ---
Author: jakub
Date: Thu Nov 10 15:36:48 2011
New Revision: 181257

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181257
Log:
    PR rtl-optimization/51023
    * combine.c (simplify_comparison) <case SIGN_EXTEND>: Don't use
    val_signbit_known_clear_p for signed comparison narrowing
    optimization.  Don't check for non-VOIDmode, use
    HWI_COMPUTABLE_MODE_P macro.
    <case ZERO_EXTEND>: Don't check for non-VOIDmode.
    Optimize even when const_op is equal to GET_MODE_MASK (mode),
    don't optimize if const_op is negative.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr51023.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/51023] [4.7 Regression] likely integer wrong code bug
  2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
                   ` (4 preceding siblings ...)
  2011-11-10 16:02 ` jakub at gcc dot gnu.org
@ 2011-11-10 17:29 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-10 17:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-10 17:04:43 UTC ---
Fixed.


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

end of thread, other threads:[~2011-11-10 17:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  5:54 [Bug c/51023] New: likely integer wrong code bug regehr at cs dot utah.edu
2011-11-08  6:47 ` [Bug c/51023] " regehr at cs dot utah.edu
2011-11-08 10:26 ` [Bug rtl-optimization/51023] [4.7 Regression] " rguenth at gcc dot gnu.org
2011-11-08 23:15 ` jakub at gcc dot gnu.org
2011-11-09  9:42 ` jakub at gcc dot gnu.org
2011-11-10 16:02 ` jakub at gcc dot gnu.org
2011-11-10 17:29 ` 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).