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

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