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

* [Bug rtl-optimization/55315] comparing address to constant is folded in cse
  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 ` vries at gcc dot gnu.org
  2012-11-19  9:36 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2012-11-17 10:32 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from vries at gcc dot gnu.org 2012-11-17 10:32:43 UTC ---
Submitted patch: http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01438.html


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

* [Bug rtl-optimization/55315] comparing address to constant is folded in cse
  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
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2012-11-19  9:36 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from vries at gcc dot gnu.org 2012-11-19 09:35:59 UTC ---
Author: vries
Date: Mon Nov 19 09:35:54 2012
New Revision: 193617

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193617
Log:
2012-11-19  Tom de Vries  <tom@codesourcery.com>

    PR rtl-optimization/55315

    * gcc.target/mips/pr55315.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/mips/pr55315.c
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/55315] comparing address to constant is folded in cse
  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
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2012-11-19  9:36 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from vries at gcc dot gnu.org 2012-11-19 09:35:53 UTC ---
Author: vries
Date: Mon Nov 19 09:35:48 2012
New Revision: 193616

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193616
Log:
2012-11-19  Tom de Vries  <tom@codesourcery.com>

    PR rtl-optimization/55315

    * rtlanal.c (nonzero_address_p): Don't assume a nonzero address plus a
    const is a nonzero address.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/rtlanal.c


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

* [Bug rtl-optimization/55315] comparing address to constant is folded in cse
  2012-11-13 23:00 [Bug rtl-optimization/55315] New: comparing address to constant is folded in cse vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-11-19  9:36 ` vries at gcc dot gnu.org
@ 2012-11-19  9:39 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2012-11-19  9:39 UTC (permalink / raw)
  To: gcc-bugs


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

vries at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
         AssignedTo|unassigned at gcc dot       |vries at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from vries at gcc dot gnu.org 2012-11-19 09:38:52 UTC ---
Patch and test-cases checked in, marking as resolved fixed.


^ 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).