[Bug middle-end/44530] New: wrong code due to branch optimization

Andrew Pinski pinskia@gmail.com
Sun Jun 13 21:58:00 GMT 2010



Sent from my iPhone

On Jun 13, 2010, at 2:34 PM, "Daniel dot Davies at xerox dot com" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

> When compiled with -03, the attached file prints out an error  
> message due to
> incorrectly comparing "xCount + 32 < 0x80000000".  When compiled  
> with the
> default optimization, it prints out the correct message.


It sounds like the addition is overflowing and signed integer overflow  
is undefined. Use either -fwrapv or -fno-strict-overflow.

>
> $ gcc -v -save-temps -std=gnu99 -fno-strict-aliasing -funroll-loops
> -march=core2 -mfpmath=387 -ffloat-store -pedantic -Wall -W -Wstrict- 
> prototypes
> -Wpointer-arith -Wwrite-strings -Wcast-qual -Wmissing-prototypes -fPIC
> gcc450CompareBug.c
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/gcc/ 
> i386-pc-solaris2.10/4.5.0/lto-wrapper
> Target: i386-pc-solaris2.10
> Configured with: /tool/gcc/4.5.0/gcc-4.5.0/configure
> --prefix=/tool/gcc/4.5.0/i386-pc-solaris2.10 --with-gnu-as --with- 
> gnu-ld
> --disable-shared --enable-lto --with-libelf=/usr/local --enable-gold
> Thread model: posix
> gcc version 4.5.0 (GCC)
> COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu99' '-fno-strict- 
> aliasing'
> '-funroll-loops' '-march=core2' '-mfpmath=387' '-ffloat-store' '- 
> pedantic'
> '-Wall' '-W' '-Wstrict-prototypes' '-Wpointer-arith' '-Wwrite-strings'
> '-Wcast-qual' '-Wmissing-prototypes' '-fPIC'
> /tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/gcc/i386-pc- 
> solaris2.10/4.5.0/cc1
> -E -quiet -v gcc450CompareBug.c -march=core2 -mfpmath=387 -std=gnu99  
> -pedantic
> -Wall -W -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wcast- 
> qual
> -Wmissing-prototypes -fno-strict-aliasing -funroll-loops -ffloat- 
> store -fPIC
> -fpch-preprocess -o gcc450CompareBug.i
> ignoring nonexistent directory
> "/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/../../../../i386-pc-solaris2.10/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/local/include
> /tool/gcc/4.5.0/i386-pc-solaris2.10/include
> /tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/include
>
> /tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/include-fixed
> /usr/include
> End of search list.
> COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu99' '-fno-strict- 
> aliasing'
> '-funroll-loops' '-march=core2' '-mfpmath=387' '-ffloat-store' '- 
> pedantic'
> '-Wall' '-W' '-Wstrict-prototypes' '-Wpointer-arith' '-Wwrite-strings'
> '-Wcast-qual' '-Wmissing-prototypes' '-fPIC'
> /tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/gcc/i386-pc- 
> solaris2.10/4.5.0/cc1
> -fpreprocessed gcc450CompareBug.i -quiet -dumpbase gcc450CompareBug.c
> -march=core2 -mfpmath=387 -auxbase gcc450CompareBug -pedantic -Wall -W
> -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wcast-qual
> -Wmissing-prototypes -std=gnu99 -version -fno-strict-aliasing - 
> funroll-loops
> -ffloat-store -fPIC -o gcc450CompareBug.s
> GNU C (GCC) version 4.5.0 (i386-pc-solaris2.10)
>        compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR  
> version 2.4.2,
> MPC version 0.8.2
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min- 
> heapsize=131072
> GNU C (GCC) version 4.5.0 (i386-pc-solaris2.10)
>        compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR  
> version 2.4.2,
> MPC version 0.8.2
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min- 
> heapsize=131072
> Compiler executable checksum: cf0046f5352e75464cfcf0489db9539c
> COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu99' '-fno-strict- 
> aliasing'
> '-funroll-loops' '-march=core2' '-mfpmath=387' '-ffloat-store' '- 
> pedantic'
> '-Wall' '-W' '-Wstrict-prototypes' '-Wpointer-arith' '-Wwrite-strings'
> '-Wcast-qual' '-Wmissing-prototypes' '-fPIC'
>
> /tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/../../../../i386-pc-solaris2.10/bin/as
> -v -V -Qy -s -o gcc450CompareBug.o gcc450CompareBug.s
> GNU assembler version 2.20 (i386-pc-solaris2.10) using BFD version  
> (GNU
> Binutils) 2.20
> COMPILER_PATH=/tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/gcc/i386- 
> pc-solaris2.10/4.5.0/:/tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/ 
> gcc/i386-pc-solaris2.10/4.5.0/:/tool/gcc/4.5.0/i386-pc-solaris2.10/ 
> libexec/gcc/i386-pc-solaris2.10/:/tool/gcc/4.5.0/i386-pc-solaris2.10/ 
> lib/gcc/i386-pc-solaris2.10/4.5.0/:/tool/gcc/4.5.0/i386-pc- 
> solaris2.10/lib/gcc/i386-pc-solaris2.10/:/tool/gcc/4.5.0/i386-pc- 
> solaris2.10/lib/gcc/i386-pc-solaris2.10/4.5.0/../../../../i386-pc- 
> solaris2.10/bin/:/usr/ccs/bin/
> LIBRARY_PATH=/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/:/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386- 
> pc-solaris2.10/4.5.0/../../../../i386-pc-solaris2.10/lib/:/tool/gcc/ 
> 4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/../../../:/lib/:/usr/lib/
> COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu99' '-fno-strict- 
> aliasing'
> '-funroll-loops' '-march=core2' '-mfpmath=387' '-ffloat-store' '- 
> pedantic'
> '-Wall' '-W' '-Wstrict-prototypes' '-Wpointer-arith' '-Wwrite-strings'
> '-Wcast-qual' '-Wmissing-prototypes' '-fPIC'
>
> /tool/gcc/4.5.0/i386-pc-solaris2.10/libexec/gcc/i386-pc- 
> solaris2.10/4.5.0/collect2
> -V -m elf_i386 -Y P,/usr/ccs/lib:/usr/lib -Qy /usr/lib/crt1.o /usr/ 
> lib/crti.o
> /usr/lib/values-Xa.o
> /tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/crtbegin.o
> -L/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0
> -L/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/../../../../i386-pc-solaris2.10/lib
> -L/tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/../../..
> gcc450CompareBug.o -lgcc -lc -lgcc
> /tool/gcc/4.5.0/i386-pc-solaris2.10/lib/gcc/i386-pc- 
> solaris2.10/4.5.0/crtend.o
> /usr/lib/crtn.o
> GNU ld (GNU Binutils) 2.20
>  Supported emulations:
>   elf_i386_ldso
>   elf_i386
>   elf_x86_64
>   elf_l1om
>
>
> -- 
>           Summary: wrong code due to branch optimization
>           Product: gcc
>           Version: 4.5.0
>            Status: UNCONFIRMED
>          Severity: normal
>          Priority: P3
>         Component: middle-end
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: Daniel dot Davies at xerox dot com
> GCC build triplet: i386-pc-solaris2.10
>  GCC host triplet: i386-pc-solaris2.10
> GCC target triplet: i386-pc-solaris2.10
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44530
>



More information about the Gcc-bugs mailing list