Skip to content

Commit e080be5

Browse files
authored
[NFC][LoopVectorize] Clean up some code around getting a context (#111114)
There are several places in LoopVectorize where we do more work than necessary to obtain a LLVMContext. I've tried to make the code more efficient.
1 parent 587f31f commit e080be5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7548,7 +7548,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
75487548
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
75497549
// cost model is complete for better cost estimates.
75507550
VPlanTransforms::unrollByUF(BestVPlan, BestUF,
7551-
OrigLoop->getHeader()->getModule()->getContext());
7551+
OrigLoop->getHeader()->getContext());
75527552
VPlanTransforms::optimizeForVFAndUF(BestVPlan, BestVF, BestUF, PSE);
75537553

75547554
LLVM_DEBUG(dbgs() << "Executing best plan with VF=" << BestVF
@@ -8378,8 +8378,8 @@ VPSingleDefRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI,
83788378
if (Legal->isMaskRequired(CI))
83798379
Mask = getBlockInMask(CI->getParent());
83808380
else
8381-
Mask = Plan.getOrAddLiveIn(ConstantInt::getTrue(
8382-
IntegerType::getInt1Ty(Variant->getFunctionType()->getContext())));
8381+
Mask = Plan.getOrAddLiveIn(
8382+
ConstantInt::getTrue(IntegerType::getInt1Ty(CI->getContext())));
83838383

83848384
Ops.insert(Ops.begin() + *MaskPos, Mask);
83858385
}
@@ -8753,8 +8753,6 @@ addUsersInExitBlock(VPlan &Plan,
87538753

87548754
auto *MiddleVPBB =
87558755
cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
8756-
BasicBlock *ExitBB =
8757-
cast<VPIRBasicBlock>(MiddleVPBB->getSuccessors()[0])->getIRBasicBlock();
87588756
VPBuilder B(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
87598757

87608758
// Introduce extract for exiting values and update the VPIRInstructions
@@ -8765,10 +8763,10 @@ addUsersInExitBlock(VPlan &Plan,
87658763
if (V->isLiveIn())
87668764
continue;
87678765

8768-
VPValue *Ext = B.createNaryOp(
8769-
VPInstruction::ExtractFromEnd,
8770-
{V, Plan.getOrAddLiveIn(ConstantInt::get(
8771-
IntegerType::get(ExitBB->getContext(), 32), 1))});
8766+
LLVMContext &Ctx = ExitIRI->getInstruction().getContext();
8767+
VPValue *Ext = B.createNaryOp(VPInstruction::ExtractFromEnd,
8768+
{V, Plan.getOrAddLiveIn(ConstantInt::get(
8769+
IntegerType::get(Ctx, 32), 1))});
87728770
ExitIRI->setOperand(0, Ext);
87738771
}
87748772
}

0 commit comments

Comments
 (0)