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



             Bug #: 55315

           Summary: comparing address to constant is folded in cse

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: rtl-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: vr...@gcc.gnu.org





Consider test.c:

...

int data[4096];



int

f (void)

{

  return ((unsigned int) &data[0]) == 0xdeadbea0U;

}

...



Although the address is not available at compile time, the compiler (mips

target) concludes it's not equal to the constant:

...

$ gcc test.c -O2 -o- -S

...

f:

        j       $31

        move    $2,$0

...



The comparison:

  ((unsigned int) &data[0]) == 0xdeadbea0U

is transformed into this by expand:

  ((unsigned int) &data[0]) + (~0xdeadbea0U + 1) == 0



Then cse uses this part of nonzero_address_p:

...

    case PLUS:

      if (CONST_INT_P (XEXP (x, 1)))

        return nonzero_address_p (XEXP (x, 0));

...

to determine that ((unsigned int) &data[0]) + (~0xdeadbea0U + 1) is non-null,

while there is no evidence that the PLUS is an address.



This is similar to PR29519, and the test-case of this PR is mentioned in

comment 5.



configure line:

...

Target: mipsisa32r2-sde-elf

Configured with: src/gcc-mainline/configure --build=i686-pc-linux-gnu

--host=i686-pc-linux-gnu --target=mipsisa32r2-sde-elf --enable-threads

--disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as

--with-gnu-ld --enable-languages=c,c++ --disable-shared --enable-lto

--with-newlib --disable-nls --disable-shared --disable-threads --disable-libssp

--disable-libgomp --without-headers --with-newlib --disable-decimal-float

--disable-libffi --disable-libquadmath --disable-libitm --disable-libatomic

--enable-languages=c --with-build-sysroot=install/mipsisa32r2-sde-elf

--with-gmp=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--with-mpfr=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--with-mpc=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'

--with-isl=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--with-cloog=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--with-libelf=obj/pkg-mainline-0-mipsisa32r2-sde-elf/fsf-mainline-0-mipsisa32r2-sde-elf.extras/host-libs-i686-pc-linux-gnu/usr

--disable-libgomp --disable-libitm --enable-poison-system-directories

--with-build-time-tools=install/mipsisa32r2-sde-elf/bin

Thread model: single

gcc version 4.8.0 20121113 (experimental) (GCC) 

...

Reply via email to