[llvm] b2d70e8 - [VPlan] Use Builder to create cast recipes in VPlanTransforms (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 4 05:39:32 PST 2025
Author: Florian Hahn
Date: 2025-03-04T13:39:12Z
New Revision: b2d70e8796ab68a80567fb794079ee07bb243f6e
URL: https://github.com/llvm/llvm-project/commit/b2d70e8796ab68a80567fb794079ee07bb243f6e
DIFF: https://github.com/llvm/llvm-project/commit/b2d70e8796ab68a80567fb794079ee07bb243f6e.diff
LOG: [VPlan] Use Builder to create cast recipes in VPlanTransforms (NFC).
Use VPBuilder in a few more places. This avoids manual insertions and
will make changing the cast recipe easier in the future.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 6944bfcb5352b..7646350ca0ed2 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1748,11 +1748,10 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
if (unsigned VFSize =
TypeInfo.inferScalarType(MaxEVL)->getScalarSizeInBits();
VFSize != 32) {
- MaxEVL = new VPScalarCastRecipe(
+ VPBuilder Builder(LoopRegion->getPreheaderVPBB());
+ MaxEVL = Builder.createScalarCast(
VFSize > 32 ? Instruction::Trunc : Instruction::ZExt, MaxEVL,
Type::getInt32Ty(Ctx), DebugLoc());
- VPBasicBlock *Preheader = LoopRegion->getPreheaderVPBB();
- Preheader->appendRecipe(cast<VPScalarCastRecipe>(MaxEVL));
}
PrevEVL = new VPScalarPHIRecipe(MaxEVL, &EVL, DebugLoc(), "prev.evl");
PrevEVL->insertBefore(*Header, Header->getFirstNonPhi());
@@ -1872,20 +1871,19 @@ bool VPlanTransforms::tryAddExplicitVectorLength(
auto *CanonicalIVIncrement =
cast<VPInstruction>(CanonicalIVPHI->getBackedgeValue());
+ Builder.setInsertPoint(CanonicalIVIncrement);
VPSingleDefRecipe *OpVPEVL = VPEVL;
if (unsigned IVSize = CanonicalIVPHI->getScalarType()->getScalarSizeInBits();
IVSize != 32) {
- OpVPEVL = new VPScalarCastRecipe(
+ OpVPEVL = Builder.createScalarCast(
IVSize < 32 ? Instruction::Trunc : Instruction::ZExt, OpVPEVL,
CanonicalIVPHI->getScalarType(), CanonicalIVIncrement->getDebugLoc());
- OpVPEVL->insertBefore(CanonicalIVIncrement);
}
- auto *NextEVLIV =
- new VPInstruction(Instruction::Add, {OpVPEVL, EVLPhi},
- {CanonicalIVIncrement->hasNoUnsignedWrap(),
- CanonicalIVIncrement->hasNoSignedWrap()},
- CanonicalIVIncrement->getDebugLoc(), "index.evl.next");
- NextEVLIV->insertBefore(CanonicalIVIncrement);
+ auto *NextEVLIV = Builder.createOverflowingOp(
+ Instruction::Add, {OpVPEVL, EVLPhi},
+ {CanonicalIVIncrement->hasNoUnsignedWrap(),
+ CanonicalIVIncrement->hasNoSignedWrap()},
+ CanonicalIVIncrement->getDebugLoc(), "index.evl.next");
EVLPhi->addOperand(NextEVLIV);
transformRecipestoEVLRecipes(Plan, *VPEVL);
More information about the llvm-commits
mailing list