[llvm-commits] [patch] Add dominance computation for edges

Bill Wendling wendling at apple.com
Mon Aug 6 11:42:18 PDT 2012


On Aug 5, 2012, at 5:20 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

> In LLVM the only value that is defined in an edge is the return value
> of an invoke. There are cases however where a fact is true only   in
> areas dominated by and edge. For example, in
> 
> define i32 @f(i32 %x) {
> bb0:
>  %cmp = icmp eq i32 %x, 0
>  br i1 %cmp, label %bb2, label %bb1
> bb1:
>  br label %bb2
> bb2:
>  %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
>  %foo = add i32 %cond, %x
>  ret i32 %foo
> }
> 
> We can replace x with 0 in cond, but not in foo.
> 
> The attached patch refactors the code we have to handle invoke so that
> it is available to clients that want to know if a use is dominated by
> an edge.
> 
I don't understand this at all. I don't see an 'invoke' in the example. And the '%x' in '%foo' cannot be replaced by '0' because it may not be '0' (i.e., it took the 'bb1' route to 'bb2).

-bw





More information about the llvm-commits mailing list