[llvm-commits] [llvm] r50096 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/and-cond.ll

Chris Lattner clattner at apple.com
Tue Apr 22 10:51:06 PDT 2008


On Apr 22, 2008, at 12:31 AM, Evan Cheng wrote:

>
> On Apr 22, 2008, at 12:05 AM, Chris Lattner wrote:
>
>> Author: lattner
>> Date: Tue Apr 22 02:05:46 2008
>> New Revision: 50096
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=50096&view=rev
>> Log:
>> Teach jump threading to thread through blocks like:
>>
>> br (and X, phi(Y, Z, false)), label L1, label L2
>>
>> This triggers once on 252.eon and 6 times on 176.gcc.  Blocks
>> in question often look like this:
>>
>> bb262:		; preds = %bb261, %bb248
>> 	%iftmp.251.0 = phi i1 [ true, %bb261 ], [ false, %bb248 ]		; <i1>
>> [#uses=4]
>> 	%tmp270 = icmp eq %struct.rtx_def* %tmp.0.i, null		; <i1> [#uses=1]
>> 	%bothcond = or i1 %iftmp.251.0, %tmp270		; <i1> [#uses=1]
>> 	br i1 %bothcond, label %bb288, label %bb273
>>
>> In this case, it is clear that it doesn't matter if tmp.0.i is null
>> when coming from bb261.  When coming from bb248, it is all that
>> matters.
>
> Do you mean iftmp.251.0, not tmp.0.i?

I meant tmp.0.i, which is an operand in the tmp270 icmp instruction.   
Regardless of whether tmp.0.i is null or not (i.e. regardless of the  
value of %tmp270), the bb261 predecessor will *always* take the branch  
to bb288.  The pass now makes bb261 jump directly to bb288,  
eliminating the compare (and branch, and phi) on that path.

Eliminating that path makes the other path through the block simpler,  
turning the phi node into 'false', and turning the 'bothcond' or into  
'or false, tmp270'.  This means that on the bb248 path, the phi and or  
is gone, but the comparison against null remains.

-Chris



More information about the llvm-commits mailing list