Skip to content

Commit

Permalink
[VPlan] Add createPtrAdd helper (NFC).
Browse files Browse the repository at this point in the history
Preparation for llvm#106431.
  • Loading branch information
fhahn authored and augusto2112 committed Sep 26, 2024
1 parent f664a57 commit 46017fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ class VPBuilder {
new VPInstruction(Instruction::ICmp, Pred, A, B, DL, Name));
}

VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset, DebugLoc DL,
const Twine &Name = "") {
return createInstruction(VPInstruction::PtrAdd, {Ptr, Offset}, DL, Name);
}

VPDerivedIVRecipe *createDerivedIV(InductionDescriptor::InductionKind Kind,
FPMathOperator *FPBinOp, VPValue *Start,
VPCanonicalIVPHIRecipe *CanonicalIV,
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,10 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
Plan, InductionDescriptor::IK_IntInduction, Instruction::Add, nullptr,
nullptr, StartV, StepV, Builder);

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

Recipe->insertAfter(Steps);
PtrIV->replaceAllUsesWith(Recipe);
PtrIV->replaceAllUsesWith(PtrAdd);
continue;
}

Expand Down

0 comments on commit 46017fc

Please sign in to comment.