https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61931

            Bug ID: 61931
           Summary: Wrong Constant Folding
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp

GCC 4.8.4 for arm miscompiles the following code.

  $ cat test.c

  int a, b, c, d, e, f, g, h;
  long long i;
  int
  main (void)
  {
    int j;
    i = a - ((((b | ((1LL * c) >> 1)) / 3) | (1 << (1 / (e + 1)))) | 1);
    j = ((((1 % (1LLU << f)) & (((1LLU >> h)) - (63LLU * d)))) << 1) == ((1LL %
(g + 1)) * a);
    if (i == 1);
    else
    __builtin_printf ("%lld, j = %lld\n", 0, j);
  }

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O1 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  1, j = 0

  $ arm-none-eabi-gcc-4.8.4 test.c -o test.out -O0 --specs=rdimon.specs
  $ qemu-arm -L /usr/arm-linux-gnueabihf/ ./test.out
  -12884901887, j = 0

  $ arm-none-eabi-gcc-4.8.4 -v
  Using built-in specs.
  COLLECT_GCC=arm-none-eabi-gcc-4.8.4
 
COLLECT_LTO_WRAPPER=/home/ishiuraken/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.4/lto-wrapper
  Target: arm-none-eabi
  Configured with: /home/build/work/GCC-4-8-build/src/gcc/configure
--target=arm-none-eabi --prefix=/home/build/work/GCC-4-8-build/install-native
--libexecdir=/home/build/work/GCC-4-8-build/install-native/lib
--infodir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/info
--mandir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/man
--htmldir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/html
--pdfdir=/home/build/work/GCC-4-8-build/install-native/share/doc/gcc-arm-none-eabi/pdf
--enable-languages=c,c++ --enable-plugins --disable-decimal-float
--disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath
--disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared
--disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib
--with-headers=yes --with-python-dir=share/gcc-arm-none-eabi
--with-sysroot=/home/build/work/GCC-4-8-build/install-native/arm-none-eabi
--build=i686-linux-gnu --host=i686-linux-gnu
--with-gmp=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpfr=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-mpc=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-isl=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-cloog=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-libelf=/home/build/work/GCC-4-8-build/build-native/host-libs/usr
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-pkgversion='GNU Tools for ARM Embedded Processors'
--with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r
  Thread model: single
  gcc version 4.8.4 20140526 (release) [ARM/embedded-4_8-branch revision
211358] (GNU Tools for ARM Embedded Processors)

Reply via email to