This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix mainline bootstrap failure on ia64
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Andreas Jaeger <aj at suse dot de>
- Date: Thu, 30 Sep 2004 15:21:27 -0600 (MDT)
- Subject: Fix mainline bootstrap failure on ia64
My recent patch to fix PR middle-end/17151 has exposed a latent a bug
in combine, that broke bootstrap on ia64-unknown-linux-gnu. Now that
the other bootstrap failures have been fixed I've been able to determine
that this one was indeed caused by my patch resulting in a miscompilation
of bitmap.c that leads to an ICE building libgcc in stage2.
The problem was that ia64's BImode now triggers an unsafe transformation
in force_to_mode that believes if we only require the least significant
bit of "(ne:BI (foo:QI) (const_int 0))", that this is equivalent to the
least significant bit of "(foo:QI)"! Doh!
The comment above the transformation reads:
/* (and (ne FOO 0) CONST) can be (and FOO CONST) if CONST is included
in STORE_FLAG_VALUE and FOO has a single bit that might be nonzero,
which is equal to STORE_FLAG_VALUE. */
The missing test for this optimization is that "FOO" must have the same
mode as the NE and the AND. The code assumes that FOO has the same mode
as the result, so when asked whether FOO in BImode only has a single bit
that might be non-zero, it always returns true and the transformation
always triggers.
The following patch has been tested on ia64-unknown-linux-gnu with a
full "make bootstrap", all default languages, and is currently running
the testsuite with a top-level "make -k check". Given that we failed
to bootstrap previously, this is obviously an improvement. I'll wait
until the regression checking completes before committing this fix as
"obvious".
My apologies for the breakage. This latent bug can potentially affect
all STORE_FLAG_VALUE == 1 platforms; fortunately the IA-64's use of
BImode has prevented this thing from going unnoticed any longer.
Any objections to commiting this patch to mainline?
2004-09-30 Roger Sayle <roger@eyesopen.com>
* combine.c (force_to_mode) <NE_EXPR>: Only convert the expression
(AND (NE FOO 0) CONST) into (AND FOO CONST) if FOO has the same
machine mode as the result.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.457
diff -c -3 -p -r1.457 combine.c
*** combine.c 28 Sep 2004 23:29:01 -0000 1.457
--- combine.c 30 Sep 2004 18:32:03 -0000
*************** force_to_mode (rtx x, enum machine_mode
*** 7338,7343 ****
--- 7338,7344 ----
in STORE_FLAG_VALUE and FOO has a single bit that might be nonzero,
which is equal to STORE_FLAG_VALUE. */
if ((mask & ~STORE_FLAG_VALUE) == 0 && XEXP (x, 1) == const0_rtx
+ && GET_MODE (XEXP (x, 0)) == mode
&& exact_log2 (nonzero_bits (XEXP (x, 0), mode)) >= 0
&& (nonzero_bits (XEXP (x, 0), mode)
== (unsigned HOST_WIDE_INT) STORE_FLAG_VALUE))
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833