The dominance computation already has logic for computing if an edge dominates
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 7 Aug 2012 17:30:46 +0000 (17:30 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 7 Aug 2012 17:30:46 +0000 (17:30 +0000)
commit702bcce747cd3fd89049b16d37c9c88952b5af81
treed1d8133d0c32f722e356250ec8e8f555ba61de92
parent8da94ad6e0947690201c543da556ec0396ad9912
The dominance computation already has logic for computing if an edge dominates
a use or a BB, but it is inline in the handling of the invoke instruction.

This patch refactors it so that it can be used in other cases. 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
}

GVN should be able to replace %x with 0 in any use that is dominated by the
true edge out of bb0. In the above example the only such use is the one in
the phi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161429 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/Dominators.h
lib/VMCore/Dominators.cpp