public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/55315] New: comparing address to constant is folded in cse
@ 2012-11-13 23:00 vries at gcc dot gnu.org
  2012-11-17 10:32 ` [Bug rtl-optimization/55315] " vries at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2012-11-13 23:00 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: vries@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) 
...


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

end of thread, other threads:[~2012-11-19  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 23:00 [Bug rtl-optimization/55315] New: comparing address to constant is folded in cse vries at gcc dot gnu.org
2012-11-17 10:32 ` [Bug rtl-optimization/55315] " vries at gcc dot gnu.org
2012-11-19  9:36 ` vries at gcc dot gnu.org
2012-11-19  9:36 ` vries at gcc dot gnu.org
2012-11-19  9:39 ` vries at gcc dot gnu.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).