Skip to content

Commit 113d991

Browse files
committed
!fixup rename variable, enforce order
1 parent 5fa1876 commit 113d991

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,7 +3509,6 @@ VPlanTransforms::expandSCEVs(VPlan &Plan, ScalarEvolution &SE) {
35093509
auto *Entry = cast<VPIRBasicBlock>(Plan.getEntry());
35103510
BasicBlock *EntryBB = Entry->getIRBasicBlock();
35113511
DenseMap<const SCEV *, Value *> ExpandedSCEVs;
3512-
VPBasicBlock::iterator InsertPt;
35133512
for (VPRecipeBase &R : make_early_inc_range(*Entry)) {
35143513
if (isa<VPIRInstruction, VPIRPhi>(&R))
35153514
continue;
@@ -3524,16 +3523,21 @@ VPlanTransforms::expandSCEVs(VPlan &Plan, ScalarEvolution &SE) {
35243523
ExpSCEV->replaceAllUsesWith(Exp);
35253524
if (Plan.getTripCount() == ExpSCEV)
35263525
Plan.resetTripCount(Exp);
3527-
InsertPt = std::next(ExpSCEV->getIterator());
35283526
ExpSCEV->eraseFromParent();
35293527
}
35303528
assert(none_of(*Entry, IsaPred<VPExpandSCEVRecipe>) &&
35313529
"VPExpandSCEVRecipes must be at the beginning of the entry block, "
35323530
"after any VPIRInstructions");
3533-
for (Instruction &I : *EntryBB) {
3534-
if (!Expander.isInsertedInstruction(&I) || isa<PHINode>(I))
3531+
// Add IR instructions in the entry basic block but not in the VPIRBasicBlock
3532+
// to the VPIRBasicBlock.
3533+
auto EI = Entry->begin();
3534+
for (Instruction &I : drop_end(*EntryBB)) {
3535+
if (EI != Entry->end() && isa<VPIRInstruction>(*EI) &&
3536+
&cast<VPIRInstruction>(&*EI)->getInstruction() == &I) {
3537+
EI++;
35353538
continue;
3536-
VPIRInstruction::create(I)->insertBefore(*Entry, InsertPt);
3539+
}
3540+
VPIRInstruction::create(I)->insertBefore(*Entry, EI);
35373541
}
35383542

35393543
return ExpandedSCEVs;

0 commit comments

Comments
 (0)