Skip to content

Commit 0433e1e

Browse files
committed
[VPlan] Add VPlan::getTrue/getFalse convenience helpers (NFC).
Makes it slightly more convenient to create true/false constants.
1 parent 1e815ce commit 0433e1e

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4132,6 +4132,18 @@ class VPlan {
41324132
return It->second;
41334133
}
41344134

4135+
/// Return a VPValue wrapping i1 true.
4136+
VPValue *getTrue() {
4137+
LLVMContext &Ctx = getContext();
4138+
return getOrAddLiveIn(ConstantInt::getTrue(Ctx));
4139+
}
4140+
4141+
/// Return a VPValue wrapping i1 false.
4142+
VPValue *getFalse() {
4143+
LLVMContext &Ctx = getContext();
4144+
return getOrAddLiveIn(ConstantInt::getFalse(Ctx));
4145+
}
4146+
41354147
/// Return the live-in VPValue for \p V, if there is one or nullptr otherwise.
41364148
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
41374149

llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,7 @@ void VPlanTransforms::prepareForVectorization(
570570
VPBuilder Builder(MiddleVPBB);
571571
VPValue *Cmp;
572572
if (!RequiresScalarEpilogueCheck)
573-
Cmp = Plan.getOrAddLiveIn(
574-
ConstantInt::getFalse(IntegerType::getInt1Ty(Plan.getContext())));
573+
Cmp = Plan.getFalse();
575574
else if (TailFolded)
576575
Cmp = Plan.getOrAddLiveIn(
577576
ConstantInt::getTrue(IntegerType::getInt1Ty(Plan.getContext())));

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,10 +1502,8 @@ static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF,
15021502
} else {
15031503
// The vector region contains header phis for which we cannot remove the
15041504
// loop region yet.
1505-
LLVMContext &Ctx = SE.getContext();
1506-
auto *BOC = new VPInstruction(
1507-
VPInstruction::BranchOnCond,
1508-
{Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx))}, Term->getDebugLoc());
1505+
auto *BOC = new VPInstruction(VPInstruction::BranchOnCond, {Plan.getTrue()},
1506+
Term->getDebugLoc());
15091507
ExitingVPBB->appendRecipe(BOC);
15101508
}
15111509

@@ -2171,7 +2169,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
21712169
Type *CanonicalIVType = Plan.getCanonicalIV()->getScalarType();
21722170
VPTypeAnalysis TypeInfo(CanonicalIVType);
21732171
LLVMContext &Ctx = CanonicalIVType->getContext();
2174-
VPValue *AllOneMask = Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx));
2172+
VPValue *AllOneMask = Plan.getTrue();
21752173
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
21762174
VPBasicBlock *Header = LoopRegion->getEntryBasicBlock();
21772175

0 commit comments

Comments
 (0)