[VPlan] Add VPlan::getTrue/getFalse convenience helpers (NFC).
Makes it slightly more convenient to create true/false constants.
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 39f5e36..c13fe45 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -4132,6 +4132,18 @@
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 a66c4a7..1b91901 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -570,8 +570,7 @@
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 3ecffc7..99b6914 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1502,10 +1502,8 @@
} 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 @@
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();