[PATCH] D48202: Generalize MergeBlockIntoPredecessor. Replace uses of MergeBasicBlockIntoOnlyPred.
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 19 07:20:27 PDT 2018
dmgreen added a comment.
You may need to update Transforms/LoopSimplifyCFG/scev.ll now too (which is hopefully simple). Otherwise this looks sensible to me.
================
Comment at: lib/Transforms/Utils/BasicBlockUtils.cpp:146
// Can't merge if there are multiple successors.
if (!OnlySucc) return false;
----------------
asbirlea wrote:
> dmgreen wrote:
> > This and the previous block is just (PredBB->getUniqueSuccessor() == BB)?
> This method is expected to also merge blocks when there are multiple edges from PredBB to BB.
> Example: `test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch.ll: test3`
>
> ```
> Start: ; preds = %0
> switch i32 3, label %TheDest [
> i32 0, label %TheDest
> i32 1, label %TheDest
> i32 2, label %TheDest
> i32 5, label %TheDest
> ]
> TheDest:
> ret i32 1234
> ```
I believe this is what getUniqueSuccessor does (as opposed to getSingleSuccessor). You are not making things any worse by leaving it as it is though.
Repository:
rL LLVM
https://reviews.llvm.org/D48202
More information about the llvm-commits
mailing list