[llvm] 0433e1e - [VPlan] Add VPlan::getTrue/getFalse convenience helpers (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 4 13:05:23 PDT 2025
Author: Florian Hahn
Date: 2025-08-04T21:04:55+01:00
New Revision: 0433e1e15fa3a9ef8485aaba2b96203f2e3d3e6a
URL: https://github.com/llvm/llvm-project/commit/0433e1e15fa3a9ef8485aaba2b96203f2e3d3e6a
DIFF: https://github.com/llvm/llvm-project/commit/0433e1e15fa3a9ef8485aaba2b96203f2e3d3e6a.diff
LOG: [VPlan] Add VPlan::getTrue/getFalse convenience helpers (NFC).
Makes it slightly more convenient to create true/false constants.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 39f5e3651e9bb..c13fe4548ff11 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -4132,6 +4132,18 @@ class VPlan {
return It->second;
}
+ /// Return a VPValue wrapping i1 true.
+ VPValue *getTrue() {
+ LLVMContext &Ctx = getContext();
+ return getOrAddLiveIn(ConstantInt::getTrue(Ctx));
+ }
+
+ /// Return a VPValue wrapping i1 false.
+ VPValue *getFalse() {
+ LLVMContext &Ctx = getContext();
+ return getOrAddLiveIn(ConstantInt::getFalse(Ctx));
+ }
+
/// Return the live-in VPValue for \p V, if there is one or nullptr otherwise.
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index a66c4a73849ce..1b91901e25d08 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -570,8 +570,7 @@ void VPlanTransforms::prepareForVectorization(
VPBuilder Builder(MiddleVPBB);
VPValue *Cmp;
if (!RequiresScalarEpilogueCheck)
- Cmp = Plan.getOrAddLiveIn(
- ConstantInt::getFalse(IntegerType::getInt1Ty(Plan.getContext())));
+ Cmp = Plan.getFalse();
else if (TailFolded)
Cmp = Plan.getOrAddLiveIn(
ConstantInt::getTrue(IntegerType::getInt1Ty(Plan.getContext())));
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 3ecffc7593d49..99b69149dbb2a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1502,10 +1502,8 @@ static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF,
} else {
// The vector region contains header phis for which we cannot remove the
// loop region yet.
- LLVMContext &Ctx = SE.getContext();
- auto *BOC = new VPInstruction(
- VPInstruction::BranchOnCond,
- {Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx))}, Term->getDebugLoc());
+ auto *BOC = new VPInstruction(VPInstruction::BranchOnCond, {Plan.getTrue()},
+ Term->getDebugLoc());
ExitingVPBB->appendRecipe(BOC);
}
@@ -2171,7 +2169,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
Type *CanonicalIVType = Plan.getCanonicalIV()->getScalarType();
VPTypeAnalysis TypeInfo(CanonicalIVType);
LLVMContext &Ctx = CanonicalIVType->getContext();
- VPValue *AllOneMask = Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx));
+ VPValue *AllOneMask = Plan.getTrue();
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
VPBasicBlock *Header = LoopRegion->getEntryBasicBlock();
More information about the llvm-commits
mailing list