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

Duncan Sands baldrick at free.fr
Mon Aug 13 01:23:25 PDT 2012


Hi Rafael,

On 06/08/12 02:20, Rafael EspĂ­ndola 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.

maybe this is useful for GVN's replaceAllDominatedUsesWith and/or
isOnlyReachableViaThisEdge?

Ciao, Duncan.



More information about the llvm-commits mailing list