This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR opt/12280: Avoid RTL sharing in noce_emit_cmove


> 
> 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
gcc.gnu.org/ml/gcc-patches/2003-06/msg03076.html
I wrote also enable_checking test for RTL sharing I sent to list same
month.

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]