Skip to content

Commit c95583f

Browse files
committed
[VPlan] Add createPtrAdd helper (NFC).
Preparation for llvm#106431.
1 parent a6bdf3f commit c95583f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

+5
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ class VPBuilder {
220220
new VPInstruction(Instruction::ICmp, Pred, A, B, DL, Name));
221221
}
222222

223+
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL,
224+
const Twine &Name = "") {
225+
return createInstruction(VPInstruction::PtrAdd, {Ptr, Offset}, DL, Name);
226+
}
227+
223228
VPDerivedIVRecipe *createDerivedIV(InductionDescriptor::InductionKind Kind,
224229
FPMathOperator *FPBinOp, VPValue *Start,
225230
VPCanonicalIVPHIRecipe *CanonicalIV,

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -593,12 +593,10 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
593593
Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr,
594594
nullptr, StartV, StepV, Builder);
595595

596-
auto *Recipe = new VPInstruction(VPInstruction::PtrAdd,
597-
{PtrIV->getStartValue(), Steps},
598-
PtrIV->getDebugLoc(), "next.gep");
596+
VPValue *PtrAdd = Builder.createPtrAdd(PtrIV->getStartValue(), Steps,
597+
PtrIV->getDebugLoc(), "next.gep");
599598

600-
Recipe->insertAfter(Steps);
601-
PtrIV->replaceAllUsesWith(Recipe);
599+
PtrIV->replaceAllUsesWith(PtrAdd);
602600
continue;
603601
}
604602

0 commit comments

Comments
 (0)