This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] PR opt/12280: Avoid RTL sharing in noce_emit_cmove
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 Nov 2003 01:53:42 +0100
- Subject: Re: [PATCH] PR opt/12280: Avoid RTL sharing in noce_emit_cmove
- References: <Pine.LNX.email@example.com>
> The following patch resolves PR optimization/12280 which is an ICE on
> valid targeted for gcc 3.4. It turns out that the underlying problem
> is caused by RTL sharing between instructions during combine. The
> source of the sharing is noce_emit_cmove in GCC's if-conversion code.
> In ifcvt.c, get_condition and noce_get_condition returns the RTL of
> the comparison controling a conditional jump, possibly making use of
> a preceding condition code setting instruction. If conversion then
> replaces the jump with a conditional move, but leaves the condition
> code setting instruction to be eliminated by DCE. Unfortunately, its
> possible to end up sharing the RTL of the comparison's operands in
> both the original condition code setter and the new cmove instruction.
> In the example attached to the PR, the condition code setter survives
> "life analysis" (but with a REG_UNUSED annotation), and combine falls
> foul of the sharing producing an unrecognizable instruction which leads
> to the ICE in later passes.
> The patch below fixes this problem by calling copy_rtx on the operands
> of the comparison, prior to creating the conditional move instruction.
> I'm also investigating an additional fix to recognize this instruction
> as dead during "life", but that would only be a work-around and is
> slightly more risky.
> The following patch has been tested on i686-pc-linux-gnu with a complete
> "make bootstrap", all languages except treelang, and regression tested
> with a top-level "make -k check" with no new failures.
> Ok for mainline?
There are more such places in ifcvt.c. The proper fix appears to be to
call limited insn unsharing. You may take a look at thread
I wrote also enable_checking test for RTL sharing I sent to list same