[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.
This commit is contained in:
Roman Lebedev 2021-01-28 21:39:28 +03:00
parent 0ea45a412a
commit 22b8421156
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
1 changed files with 10 additions and 9 deletions

View File

@ -346,22 +346,23 @@ static void scalarizeMaskedStore(CallInst *CI, bool &ModifiedDT) {
// %EltAddr = getelementptr i32* %1, i32 0 // %EltAddr = getelementptr i32* %1, i32 0
// %store i32 %OneElt, i32* %EltAddr // %store i32 %OneElt, i32* %EltAddr
// //
BasicBlock *CondBlock = Instruction *ThenTerm =
IfBlock->splitBasicBlock(InsertPt->getIterator(), "cond.store"); SplitBlockAndInsertIfThen(Predicate, InsertPt, /*Unreachable=*/false);
Builder.SetInsertPoint(InsertPt);
BasicBlock *CondBlock = ThenTerm->getParent();
CondBlock->setName("cond.store");
Builder.SetInsertPoint(CondBlock->getTerminator());
Value *OneElt = Builder.CreateExtractElement(Src, Idx); Value *OneElt = Builder.CreateExtractElement(Src, Idx);
Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, FirstEltPtr, Idx); Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, FirstEltPtr, Idx);
Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal); Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
// Create "else" block, fill it in the next iteration // Create "else" block, fill it in the next iteration
BasicBlock *NewIfBlock = BasicBlock *NewIfBlock = ThenTerm->getSuccessor(0);
CondBlock->splitBasicBlock(InsertPt->getIterator(), "else"); NewIfBlock->setName("else");
Builder.SetInsertPoint(InsertPt);
Instruction *OldBr = IfBlock->getTerminator();
BranchInst::Create(CondBlock, NewIfBlock, Predicate, OldBr);
OldBr->eraseFromParent();
IfBlock = NewIfBlock; IfBlock = NewIfBlock;
Builder.SetInsertPoint(NewIfBlock, NewIfBlock->begin());
} }
CI->eraseFromParent(); CI->eraseFromParent();