[llvm] f26e859 - [VPlan] Use VPlan::getConstantInt in a few more cases (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 15 06:45:54 PST 2026
Author: Florian Hahn
Date: 2026-02-15T14:45:33Z
New Revision: f26e8595c3073fafc822bfcdd3ca9dec32ab573b
URL: https://github.com/llvm/llvm-project/commit/f26e8595c3073fafc822bfcdd3ca9dec32ab573b
DIFF: https://github.com/llvm/llvm-project/commit/f26e8595c3073fafc822bfcdd3ca9dec32ab573b.diff
LOG: [VPlan] Use VPlan::getConstantInt in a few more cases (NFC).
VPlan::getConstantInt() allows for slightly more compact creation of
VPIRValues wrapping ConstantInts.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index da1035847020a..80847fcbb77fb 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -458,8 +458,7 @@ static void createLoopRegion(VPlan &Plan, VPBlockBase *HeaderVPB) {
static void addCanonicalIVRecipes(VPlan &Plan, VPBasicBlock *HeaderVPBB,
VPBasicBlock *LatchVPBB, Type *IdxTy,
DebugLoc DL) {
- Value *StartIdx = ConstantInt::get(IdxTy, 0);
- auto *StartV = Plan.getOrAddLiveIn(StartIdx);
+ auto *StartV = Plan.getConstantInt(IdxTy, 0);
// Add a VPCanonicalIVPHIRecipe starting at 0 to the header.
auto *CanonicalIVPHI = new VPCanonicalIVPHIRecipe(StartV, DL);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 0d713a6dc4e47..fe2314f32d483 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1990,9 +1990,7 @@ static bool tryToReplaceALMWithWideALM(VPlan &Plan, ElementCount VF,
DebugLoc DL = ALM->getDebugLoc();
for (unsigned Part = 0; Part < UF; ++Part) {
SmallVector<VPValue *> Ops;
- Ops.append({ALM, Plan.getOrAddLiveIn(
- ConstantInt::get(IntegerType::getInt64Ty(Ctx),
- VF.getKnownMinValue() * Part))});
+ Ops.append({ALM, Plan.getConstantInt(64, VF.getKnownMinValue() * Part)});
auto *Ext =
new VPWidenIntrinsicRecipe(Intrinsic::vector_extract, Ops,
IntegerType::getInt1Ty(Ctx), {}, {}, DL);
@@ -2427,9 +2425,8 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
VPBuilder B(cast<VPInstruction>(U));
VPValue *LastActiveLane = cast<VPInstruction>(U)->getOperand(0);
- Type *I64Ty = Type::getInt64Ty(Plan.getContext());
- VPValue *Zero = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 0));
- VPValue *One = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 1));
+ VPValue *Zero = Plan.getConstantInt(64, 0);
+ VPValue *One = Plan.getConstantInt(64, 1);
VPValue *PenultimateIndex = B.createSub(LastActiveLane, One);
VPValue *PenultimateLastIter =
B.createNaryOp(VPInstruction::ExtractLane,
@@ -2944,8 +2941,8 @@ void VPlanTransforms::addActiveLaneMask(
Plan, DataAndControlFlowWithoutRuntimeCheck);
} else {
VPBuilder B = VPBuilder::getToInsertAfter(WideCanonicalIV);
- VPValue *ALMMultiplier = Plan.getOrAddLiveIn(
- ConstantInt::get(LoopRegion->getCanonicalIVType(), 1));
+ VPValue *ALMMultiplier =
+ Plan.getConstantInt(LoopRegion->getCanonicalIVType(), 1);
LaneMask =
B.createNaryOp(VPInstruction::ActiveLaneMask,
{WideCanonicalIV, Plan.getTripCount(), ALMMultiplier},
@@ -3970,8 +3967,7 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) {
LastActiveL->getDebugLoc(), "first.inactive.lane");
// Subtract 1 to get the last active lane.
- VPValue *One = Plan.getOrAddLiveIn(
- ConstantInt::get(Type::getInt64Ty(Plan.getContext()), 1));
+ VPValue *One = Plan.getConstantInt(64, 1);
VPValue *LastLane =
Builder.createSub(FirstInactiveLane, One,
LastActiveL->getDebugLoc(), "last.active.lane");
@@ -5383,8 +5379,8 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
auto *Inc = cast<VPInstruction>(CanIV->getBackedgeValue());
VPBuilder PHBuilder(Plan.getVectorPreheader());
- VPValue *UF = Plan.getOrAddLiveIn(
- ConstantInt::get(VectorLoop->getCanonicalIVType(), 1 * Plan.getUF()));
+ VPValue *UF =
+ Plan.getConstantInt(VectorLoop->getCanonicalIVType(), Plan.getUF());
if (VF.isScalable()) {
VPValue *VScale = PHBuilder.createElementCount(
VectorLoop->getCanonicalIVType(), ElementCount::getScalable(1));
More information about the llvm-commits
mailing list