From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7646 invoked by alias); 13 Nov 2012 23:00:47 -0000 Received: (qmail 6966 invoked by uid 48); 13 Nov 2012 23:00:29 -0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55315] New: comparing address to constant is folded in cse Date: Tue, 13 Nov 2012 23:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg01206.txt.bz2 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) ...