Add Control Dependent DCE pass.
Add Control Dependent DCE pass.
This pass performs 'control dependent DCE', which converts a conditional
branch of BB into an unconditional branch if possible, when the basic block
BBa dominates BB and both basic blocks have conditional branches under the
same condition.
BBa:
%cmp = ... br i1 %cmp, label %LA1, label %LA2
...
BB:
... br i1 %cmp, label %LD1, label %LD2
The condition to apply this optimization is that the predecessors of BB is
divided into the set S1 coming from LA1 and the set S2 coming from LA2.
If S1(or S2) is empty, it rewrites the conditional branch to an
unconditional branch to LD2(or LD1).
If both S1 and S2 are not empty and BB can be duplicated, BB is duplicated
for S2, and each conditional branches in BB and the duplicated BB are
converted into unconditional branches for LD1 and LD2, respectively.
[Jump Threading] Convert conditional branches into unconditional branches using GVN results https://reviews.llvm.org/D57953
This patch duplicates and holds the variables and functions related to TryThreadEdge in JumpThreading pass.
Therefore, it is necessary to create a patch that makes these duplicates into a library before committing this patch.