public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40987]  New: Wrong optimization with if-conversion
@ 2009-08-06 14:06 thomas at coware dot com
  2009-08-06 14:58 ` [Bug c/40987] " rguenth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: thomas at coware dot com @ 2009-08-06 14:06 UTC (permalink / raw)
  To: gcc-bugs

The following test fails when I disable all optimizations but if-conversion:

#include <stdio.h>

long long func(long arg) {
   long long val = 0;
   if (arg < 0) {
      val = 0xffffffff80000000ull;
   }
   return val;
}

int main() {
   long long result = func(-1);
   if (result != 0xffffffff80000000ull) {
      printf("failed.\n");
      return 1;
   } 
   printf("passed.\n");
   return 0;
}

The return value of func is 0x80000000ull where it should be
0xffffffff80000000ull. It works correctly when I don't do any optimization or
with more optimization (-O1, -O2, -O3).

The compile command line is the following:
gcc test.c -O1 -fno-defer-pop -fno-delayed-branch -fno-guess-branch-probability
-fno-cprop-registers -fno-loop-optimize -fno-if-conversion2 -fno-tree-ccp
-fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-ter 
-fno-tree-lrs -fno-tree-sra -fno-tree-copyrename -fno-tree-fre -fno-tree-ch
-fno-unit-at-a-time -fno-merge-constants -fno-omit-frame-pointer -o test

there are no compiler warnings, even with -Wall

I use gcc 4.3.4, configure options:
 ../gcc-4.3.4/configure --disable-shared --disable-nls --enable-languages=c++
--with-gnu-as --with-gnu-ld --enable-__cxa_atexit


-- 
           Summary: Wrong optimization with if-conversion
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas at coware dot com
 GCC build triplet: i686
  GCC host triplet: i686
GCC target triplet: i686


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


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

end of thread, other threads:[~2009-09-26 10:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-06 14:06 [Bug c/40987] New: Wrong optimization with if-conversion thomas at coware dot com
2009-08-06 14:58 ` [Bug c/40987] " rguenth at gcc dot gnu dot org
2009-08-06 15:26 ` thomas at coware dot com
2009-08-06 15:59 ` mikpe at it dot uu dot se
2009-08-06 19:25 ` thomas at coware dot com
2009-08-06 22:12 ` steven at gcc dot gnu dot org
2009-08-06 22:13 ` steven at gcc dot gnu dot org
2009-08-07  7:38 ` thomas at coware dot com
2009-08-07 12:10 ` [Bug rtl-optimization/40987] " rguenth at gcc dot gnu dot org
2009-09-19 16:57 ` mikpe at it dot uu dot se
2009-09-24 14:39 ` mikpe at it dot uu dot se
2009-09-26 10:18 ` steven 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).