[llvm] 22b8421 - [NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 28 14:12:11 PST 2021
Author: Roman Lebedev
Date: 2021-01-29T01:11:34+03:00
New Revision: 22b84211565829089c0d372c6ac635fbe060e5fc
URL: https://github.com/llvm/llvm-project/commit/22b84211565829089c0d372c6ac635fbe060e5fc
DIFF: https://github.com/llvm/llvm-project/commit/22b84211565829089c0d372c6ac635fbe060e5fc.diff
LOG: [NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()
Makes Dominator Tree preservation in a followup patch somewhat easier.
Added:
Modified:
llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
index 6f4225b597ee..b135f5e957ac 100644
--- a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
@@ -346,22 +346,23 @@ static void scalarizeMaskedStore(CallInst *CI, bool &ModifiedDT) {
// %EltAddr = getelementptr i32* %1, i32 0
// %store i32 %OneElt, i32* %EltAddr
//
- BasicBlock *CondBlock =
- IfBlock->splitBasicBlock(InsertPt->getIterator(), "cond.store");
- Builder.SetInsertPoint(InsertPt);
+ Instruction *ThenTerm =
+ SplitBlockAndInsertIfThen(Predicate, InsertPt, /*Unreachable=*/false);
+ BasicBlock *CondBlock = ThenTerm->getParent();
+ CondBlock->setName("cond.store");
+
+ Builder.SetInsertPoint(CondBlock->getTerminator());
Value *OneElt = Builder.CreateExtractElement(Src, Idx);
Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, FirstEltPtr, Idx);
Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
// Create "else" block, fill it in the next iteration
- BasicBlock *NewIfBlock =
- CondBlock->splitBasicBlock(InsertPt->getIterator(), "else");
- Builder.SetInsertPoint(InsertPt);
- Instruction *OldBr = IfBlock->getTerminator();
- BranchInst::Create(CondBlock, NewIfBlock, Predicate, OldBr);
- OldBr->eraseFromParent();
+ BasicBlock *NewIfBlock = ThenTerm->getSuccessor(0);
+ NewIfBlock->setName("else");
IfBlock = NewIfBlock;
+
+ Builder.SetInsertPoint(NewIfBlock, NewIfBlock->begin());
}
CI->eraseFromParent();
More information about the llvm-commits
mailing list