forked from OSchip/llvm-project
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()
Makes Dominator Tree preservation in a followup patch somewhat easier.
This commit is contained in:
parent
0ea45a412a
commit
22b8421156
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue