Skip to content

Commit 75532b2

Browse files
committed
[VPlan] Replace getPreheaderBBFor with getCFGPredecessor. (NFC)
Replace existing uses of getPreheaderBBFor with the newly added more general getCFGPredecessor.
1 parent 9544943 commit 75532b2

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,6 @@ Value *VPTransformState::get(const VPValue *Def, bool NeedsScalar) {
350350
return VectorValue;
351351
}
352352

353-
BasicBlock *VPTransformState::CFGState::getPreheaderBBFor(VPRecipeBase *R) {
354-
VPRegionBlock *LoopRegion = R->getParent()->getEnclosingLoopRegion();
355-
return VPBB2IRBB[LoopRegion->getPreheaderVPBB()];
356-
}
357-
358353
void VPTransformState::addNewMetadata(Instruction *To,
359354
const Instruction *Orig) {
360355
// If the loop was versioned with memchecks, add the corresponding no-alias

llvm/lib/Transforms/Vectorize/VPlanHelpers.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ struct VPTransformState {
321321

322322
CFGState(DominatorTree *DT)
323323
: DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy) {}
324-
325-
/// Returns the BasicBlock* mapped to the pre-header of the loop region
326-
/// containing \p R.
327-
BasicBlock *getPreheaderBBFor(VPRecipeBase *R);
328324
} CFG;
329325

330326
/// Hold a pointer to LoopInfo to register new basic blocks in the loop.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
495495
getParent()->getPlan()->getVectorLoopRegion()->getEntry() &&
496496
"VPInstructions with PHI opcodes must be used for header phis only "
497497
"at the moment");
498-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
498+
BasicBlock *VectorPH =
499+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
499500
Value *Start = State.get(getOperand(0), VPLane(0));
500501
PHINode *Phi = State.Builder.CreatePHI(Start->getType(), 2, Name);
501502
Phi->addIncoming(Start, VectorPH);
@@ -1956,7 +1957,8 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
19561957

19571958
// Construct the initial value of the vector IV in the vector loop preheader
19581959
auto CurrIP = Builder.saveIP();
1959-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
1960+
BasicBlock *VectorPH =
1961+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
19601962
Builder.SetInsertPoint(VectorPH->getTerminator());
19611963
if (isa<TruncInst>(EntryVal)) {
19621964
assert(Start->getType()->isIntegerTy() &&
@@ -3507,7 +3509,8 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
35073509
Value *ScalarStartValue = getStartValue()->getLiveInIRValue();
35083510
Type *ScStValueType = ScalarStartValue->getType();
35093511

3510-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
3512+
BasicBlock *VectorPH =
3513+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
35113514
PHINode *NewPointerPhi = nullptr;
35123515
if (CurrentPart == 0) {
35133516
IRBuilder<>::InsertPointGuard Guard(State.Builder);
@@ -3648,7 +3651,8 @@ void VPFirstOrderRecurrencePHIRecipe::execute(VPTransformState &State) {
36483651
? VectorInit->getType()
36493652
: VectorType::get(VectorInit->getType(), State.VF);
36503653

3651-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
3654+
BasicBlock *VectorPH =
3655+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
36523656
if (State.VF.isVector()) {
36533657
auto *IdxTy = Builder.getInt32Ty();
36543658
auto *One = ConstantInt::get(IdxTy, 1);
@@ -3716,7 +3720,8 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
37163720
Phi->insertBefore(HeaderBB->getFirstInsertionPt());
37173721
State.set(this, Phi, IsInLoop);
37183722

3719-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
3723+
BasicBlock *VectorPH =
3724+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
37203725

37213726
Value *Iden = nullptr;
37223727
RecurKind RK = RdxDesc.getRecurrenceKind();
@@ -3810,7 +3815,8 @@ void VPWidenPHIRecipe::print(raw_ostream &O, const Twine &Indent,
38103815
// TODO: It would be good to use the existing VPWidenPHIRecipe instead and
38113816
// remove VPActiveLaneMaskPHIRecipe.
38123817
void VPActiveLaneMaskPHIRecipe::execute(VPTransformState &State) {
3813-
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
3818+
BasicBlock *VectorPH =
3819+
State.CFG.VPBB2IRBB.at(getParent()->getCFGPredecessor(0));
38143820
Value *StartMask = State.get(getOperand(0));
38153821
PHINode *Phi =
38163822
State.Builder.CreatePHI(StartMask->getType(), 2, "active.lane.mask");

0 commit comments

Comments
 (0)