This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix CSE bug
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 18 Oct 2003 00:20:43 +0200
- Subject: [PATCH] Fix CSE bug
Hi,
Roger's recent patch to CSE (which fixed a problem in the cost system)
introduced a regression on SPARC:
FAIL: gcc.dg/ultrasp7.c (test for excess errors)
The problem lies in these lines from cse_insn:
{
trial = src_folded, src_folded_cost = MAX_COST;
if (src_folded_force_flag)
trial = force_const_mem (mode, trial);
}
force_const_mem may return NULL, in this case because we try to force to mem
a SYMBOL_REF (which comes from a REG_EQUAL note) in PIC mode, which is not
allowed on SPARC. We ICE later when trying to validate the replacement by
'trial' in the insn.
Bootstrapped/regtested on k6-redhat-linux-gnu, sparc-sun-solaris2.8 and
sparc64-sun-solaris2.9 (mainline, except Ada). It fixes the regression.
2003-10-17 Eric Botcazou <ebotcazou@libertysurf.fr>
* cse.c (cse_insn) [src_folded]: Check that the tentative replacement
was successfully forced to memory before using the result.
--
Eric Botcazou
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.274
diff -u -p -r1.274 cse.c
--- cse.c 11 Oct 2003 03:49:54 -0000 1.274
+++ cse.c 16 Oct 2003 10:31:14 -0000
@@ -5416,7 +5416,11 @@ cse_insn (rtx insn, rtx libcall_insn)
{
trial = src_folded, src_folded_cost = MAX_COST;
if (src_folded_force_flag)
- trial = force_const_mem (mode, trial);
+ {
+ rtx forced = force_const_mem (mode, trial);
+ if (forced)
+ trial = forced;
+ }
}
else if (src
&& preferrable (src_cost, src_regcost,