On Apr 15, 2011, at 4:38 PM, Maxim Kuvyrkov wrote:

> On Apr 15, 2011, at 3:34 PM, Eric Botcazou wrote:
> 
>>> The problem this patch fixes is that combine_simplify_rtx() prefers to
>>> return an expression (say, <xor (a) (b)>) even when a comparison is
>>> prefered (say, <neq (xor (a) (b)) 0>).  Expressions are not recognized as
>>> valid conditions of if_then_else for most targets, so combiner misses a
>>> potential optimization.  This patch makes combine_simplify_rtx() aware of
>>> the context it was invoked in, and, when appropriate, does not discourage
>>> it from returning a conditional.
>> 
>> Btw, this is very likely also valid for targets with STORE_FLAG_VALUE == -1 
>> so 
>> the same IN_COND short-circuit would need to be added a few lines below in 
>> combine_simplify_rtx.  But this would need to be tested.  Do you happen to 
>> have access to such a target, e.g. m68k?
> 
> Hm, I didn't notice that one, thanks!  I have access to m68k (ColdFire, tbp) 
> and will test this change there before committing.

I've successfully tested the following trivial patch on m68k-linux 
(cross-compiler, gcc, g++ and libstdc++ testsuites).

Checked in as obvious.

--
Maxim Kuvyrkov
Mentor Graphics / CodeSourcery

Attachment: fsf-gcc-combine-fix-1.ChangeLog
Description: Binary data

Attachment: fsf-gcc-combine-fix-1.patch
Description: Binary data

Reply via email to