public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40747]  New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
@ 2009-07-14 16:32 zsojka at seznam dot cz
  2009-07-14 16:36 ` [Bug c/40747] " zsojka at seznam dot cz
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: zsojka at seznam dot cz @ 2009-07-14 16:32 UTC (permalink / raw)
  To: gcc-bugs

Tested with:

trunk r149624
# ./gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --enable-languages=c,c++
--prefix=/mnt/svn/gcc-trunk/build/
Thread model: posix
gcc version 4.5.0 20090714 (experimental) (GCC)

and gentoo's 4.4.0, 4.5_alpha20090709

The following code is miscompiled
------------------------
// command line: gcc tst.c -c -o tst.o -O1
// or: with -m32
int f3(int i) {
        return (i < 4 && i >= 0) ? i : 4;
}
------------------------

Resulting (relevant) asm is:
------------------------
f3:
.LFB0:
        .cfi_startproc
        cmpl    $4, %edi
        movl    $4, %eax
        cmovle  %edi, %eax
        ret
        .cfi_endproc
------------------------

For the following code:
------------------------
// command line: gcc tst.c -c -o tst.o -O1
// or: with -m32
#include <stdio.h>

int f3(int i) {
        return (i < 4 && i >= 0) ? i : 4;
}

int main() {
        printf("%d %d %d\n", f3(-1), f3(2), f3(5));
}
------------------------
Result is "-1 2 4", but it should be "4 2 4" (as it is with -O0)


-- 
           Summary: [4.4/4.5 Regression] wrong code for int-is-in-range test
                    at -O1 and above
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zsojka at seznam dot cz
  GCC host triplet: x86_64-pc-linux-gnu


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


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

* [Bug c/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
@ 2009-07-14 16:36 ` zsojka at seznam dot cz
  2009-07-14 17:16 ` sezeroz at gmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: zsojka at seznam dot cz @ 2009-07-14 16:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from zsojka at seznam dot cz  2009-07-14 16:35 -------
Created an attachment (id=18194)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18194&action=view)
preprocessed source

most of that file is content of included <stdio.h>


-- 


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


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

* [Bug c/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
  2009-07-14 16:36 ` [Bug c/40747] " zsojka at seznam dot cz
@ 2009-07-14 17:16 ` sezeroz at gmail dot com
  2009-07-14 17:26 ` jakub at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sezeroz at gmail dot com @ 2009-07-14 17:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sezeroz at gmail dot com  2009-07-14 17:16 -------
Also happens with i686-pc-linux-gnu with gcc-4.4.1 (gcc-4_4-branch, r149543).


-- 

sezeroz at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sezeroz at gmail dot com


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


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

* [Bug c/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
  2009-07-14 16:36 ` [Bug c/40747] " zsojka at seznam dot cz
  2009-07-14 17:16 ` sezeroz at gmail dot com
@ 2009-07-14 17:26 ` jakub at gcc dot gnu dot org
  2009-07-14 18:00 ` jakub at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-14 17:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2009-07-14 17:25 -------
Confirmed, introduced between r134374 + r134467, looking into it.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-14 17:25:58
               date|                            |


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


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

* [Bug c/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2009-07-14 17:26 ` jakub at gcc dot gnu dot org
@ 2009-07-14 18:00 ` jakub at gcc dot gnu dot org
  2009-07-15  7:32 ` [Bug middle-end/40747] " steven at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-14 18:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2009-07-14 18:00 -------
Indeed, caused by http://gcc.gnu.org/ml/gcc-patches/2008-04/msg01303.html
(r134384).


-- 


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2009-07-14 18:00 ` jakub at gcc dot gnu dot org
@ 2009-07-15  7:32 ` steven at gcc dot gnu dot org
  2009-07-15  8:19 ` sezeroz at gmail dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-07-15  7:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.2


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2009-07-15  7:32 ` [Bug middle-end/40747] " steven at gcc dot gnu dot org
@ 2009-07-15  8:19 ` sezeroz at gmail dot com
  2009-07-15  8:28 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sezeroz at gmail dot com @ 2009-07-15  8:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from sezeroz at gmail dot com  2009-07-15 08:19 -------
This bug may result in unreliable binary outputs, why is it targeted for fixing
in 4.4.2 and not in 4.4.1?


-- 


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2009-07-15  8:19 ` sezeroz at gmail dot com
@ 2009-07-15  8:28 ` jakub at gcc dot gnu dot org
  2009-07-15  8:30 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15  8:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2009-07-15 08:28 -------
I'm already bootstrapping/regtesting a fix, will post afterwards.
If it gets approved quickly, I'll include it in 4.4.1-rc1 I plan to roll today.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.4.2                       |4.4.1


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2009-07-15  8:28 ` jakub at gcc dot gnu dot org
@ 2009-07-15  8:30 ` jakub at gcc dot gnu dot org
  2009-07-15  9:48 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15  8:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2009-07-15  8:30 ` jakub at gcc dot gnu dot org
@ 2009-07-15  9:48 ` jakub at gcc dot gnu dot org
  2009-07-15 10:18 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15  9:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2009-07-15 09:48 -------
Patch posted: http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00842.html


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2009-
                   |                            |07/msg00842.html


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (8 preceding siblings ...)
  2009-07-15  9:48 ` jakub at gcc dot gnu dot org
@ 2009-07-15 10:18 ` jakub at gcc dot gnu dot org
  2009-07-15 11:23 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15 10:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jakub at gcc dot gnu dot org  2009-07-15 10:18 -------
Subject: Bug 40747

Author: jakub
Date: Wed Jul 15 10:17:54 2009
New Revision: 149675

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149675
Log:
        PR middle-end/40747
        * fold-const.c (fold_cond_expr_with_comparison): When folding
        < and <= to MIN, make sure the MIN uses the same type as the
        comparison's operands.

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

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr40747.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (9 preceding siblings ...)
  2009-07-15 10:18 ` jakub at gcc dot gnu dot org
@ 2009-07-15 11:23 ` jakub at gcc dot gnu dot org
  2009-07-15 11:26 ` jakub at gcc dot gnu dot org
  2009-10-21 10:51 ` mikpe at it dot uu dot se
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15 11:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jakub at gcc dot gnu dot org  2009-07-15 11:23 -------
Subject: Bug 40747

Author: jakub
Date: Wed Jul 15 11:23:22 2009
New Revision: 149681

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149681
Log:
        PR middle-end/40747
        * fold-const.c (fold_cond_expr_with_comparison): When folding
        < and <= to MIN, make sure the MIN uses the same type as the
        comparison's operands.

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

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr40747.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/fold-const.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (10 preceding siblings ...)
  2009-07-15 11:23 ` jakub at gcc dot gnu dot org
@ 2009-07-15 11:26 ` jakub at gcc dot gnu dot org
  2009-10-21 10:51 ` mikpe at it dot uu dot se
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-15 11:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jakub at gcc dot gnu dot org  2009-07-15 11:26 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/40747] [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above
  2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
                   ` (11 preceding siblings ...)
  2009-07-15 11:26 ` jakub at gcc dot gnu dot org
@ 2009-10-21 10:51 ` mikpe at it dot uu dot se
  12 siblings, 0 replies; 14+ messages in thread
From: mikpe at it dot uu dot se @ 2009-10-21 10:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from mikpe at it dot uu dot se  2009-10-21 10:51 -------
*** Bug 40547 has been marked as a duplicate of this bug. ***


-- 

mikpe at it dot uu dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu dot se


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


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

end of thread, other threads:[~2009-10-21 10:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-14 16:32 [Bug c/40747] New: [4.4/4.5 Regression] wrong code for int-is-in-range test at -O1 and above zsojka at seznam dot cz
2009-07-14 16:36 ` [Bug c/40747] " zsojka at seznam dot cz
2009-07-14 17:16 ` sezeroz at gmail dot com
2009-07-14 17:26 ` jakub at gcc dot gnu dot org
2009-07-14 18:00 ` jakub at gcc dot gnu dot org
2009-07-15  7:32 ` [Bug middle-end/40747] " steven at gcc dot gnu dot org
2009-07-15  8:19 ` sezeroz at gmail dot com
2009-07-15  8:28 ` jakub at gcc dot gnu dot org
2009-07-15  8:30 ` jakub at gcc dot gnu dot org
2009-07-15  9:48 ` jakub at gcc dot gnu dot org
2009-07-15 10:18 ` jakub at gcc dot gnu dot org
2009-07-15 11:23 ` jakub at gcc dot gnu dot org
2009-07-15 11:26 ` jakub at gcc dot gnu dot org
2009-10-21 10:51 ` mikpe at it dot uu dot se

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).