[SimplifyCFG] Improve FoldValueComparisonIntoPredecessors to handle more cases
authorJames Molloy <james.molloy@arm.com>
Wed, 31 Aug 2016 10:46:39 +0000 (10:46 +0000)
committerJames Molloy <james.molloy@arm.com>
Wed, 31 Aug 2016 10:46:39 +0000 (10:46 +0000)
commit8e69b032e5e13e1f8f9ebd8e1ee20643b6e6bf8b
treedf234f088e9575a41d1f709fd721764216222701
parentc53b40b5096597d54c968c8ab07495225b67b97a
[SimplifyCFG] Improve FoldValueComparisonIntoPredecessors to handle more cases

A very important case is not handled here: multiple arcs to a single block with a PHI. Consider:

    a:
      %1 = icmp %b, 1
      br %1, label %c, label %e
    c:
      %2 = icmp %b, 2
      br %2, label %d, label %e
    d:
      br %e
    e:
      phi [0, %a], [1, %c], [2, %d]

FoldValueComparisonIntoPredecessors will refuse to fold this, as it doesn't know how to deal with two arcs to a common destination with different PHI values. The answer is obvious - just split all conflicting arcs.

llvm-svn: 280218
llvm/lib/Transforms/Utils/SimplifyCFG.cpp