[llvm-commits] [llvm] r59756 - /llvm/trunk/include/llvm/Intrinsics.td

Bill Wendling isanbard at gmail.com
Fri Nov 21 16:05:13 PST 2008


On Nov 21, 2008, at 3:50 PM, Chris Lattner wrote:

> On Nov 21, 2008, at 2:10 PM, Bill Wendling wrote:
>> I had an idea over lunch which may or may not be good. Here it is
>> though.
>>
>> What if we add a new LLVM instruction, called, say, "flag". It would
>> be similar to the icmp instruction, but unary instead of binary. It
>> would take a mnemonic operator for a flag and an arithmetic  
>> expression
>> as its arguments. Here's an example:
>>
>> 	%sum = add i32 %v1, %v2
>> 	%of = flag of i32 %sum
>> 	br i1 %of, label %overflow, label %normal
>
> This doesn't work.  LLVM IR needs to be context sensitive.  For
> example, what are the flags produce by an identity bitcast or phi
> node?  The code above should be semantically equivalent if you insert
> identity bitcasts.  This is exactly the problem that some of the
> vector lane proposals hit.
>
> These would have to be equivalent for this to be feasible:
>
>> 	%sum = add i32 %v1, %v2
>> 	%of = flag of i32 %sum
>> 	br i1 %of, label %overflow, label %normal
>
>
>
>> %sum = add i32 %v1, %v2
>   %tmp = bitcast i32 %sum to i32
>> %of = flag of i32 %tmp
>> br i1 %of, label %overflow, label %normal
>
> Similarly for phis, call arguments, etc.
>
The flag instruction could transitively look through identity casts  
and phi nodes for the instruction? The verifier could make sure that  
what hid behind a bitcast or phi node is an arithmetic instruction.  
Because it's only concerned about the value, and it can find the  
instruction that generates that value, then it can determine the flag  
value. I'm not sure I see the problem with context sensitivity here.

-bw




More information about the llvm-commits mailing list