Skip to content

Commit 535ab6a

Browse files
committed
Rebase and updated
1 parent 7eaa4f8 commit 535ab6a

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct specificval_ty {
6161

6262
specificval_ty(const VPValue *V) : Val(V) {}
6363

64-
bool match(VPValue *VPV) { return VPV == Val; }
64+
bool match(VPValue *VPV) const { return VPV == Val; }
6565
};
6666

6767
inline specificval_ty m_Specific(const VPValue *VPV) { return VPV; }
@@ -227,16 +227,16 @@ struct TernaryRecipe_match {
227227
TernaryRecipe_match(Op0_t Op0, Op1_t Op1, Op2_t Op2)
228228
: Op0(Op0), Op1(Op1), Op2(Op2) {}
229229

230-
bool match(const VPValue *V) {
230+
bool match(const VPValue *V) const {
231231
auto *DefR = V->getDefiningRecipe();
232232
return DefR && match(DefR);
233233
}
234234

235-
bool match(const VPSingleDefRecipe *R) {
235+
bool match(const VPSingleDefRecipe *R) const {
236236
return match(static_cast<const VPRecipeBase *>(R));
237237
}
238238

239-
bool match(const VPRecipeBase *R) {
239+
bool match(const VPRecipeBase *R) const {
240240
if (!detail::MatchRecipeAndOpcode<Opcode, RecipeTys...>::match(R))
241241
return false;
242242
assert(R->getNumOperands() == 3 &&

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,10 @@ Value *VPInstruction::generate(VPTransformState &State) {
663663
return NewPhi;
664664
}
665665
case VPInstruction::MergeUntilPivot: {
666-
assert(Part == 0 && "No unrolling expected for predicated vectorization.");
667-
Value *Cond = State.get(getOperand(0), Part);
668-
Value *OnTrue = State.get(getOperand(1), Part);
669-
Value *OnFalse = State.get(getOperand(2), Part);
670-
Value *Pivot = State.get(getOperand(3), VPIteration(0, 0));
666+
Value *Cond = State.get(getOperand(0), 0);
667+
Value *OnTrue = State.get(getOperand(1), 0);
668+
Value *OnFalse = State.get(getOperand(2), 0);
669+
Value *Pivot = State.get(getOperand(3), /* IsScalar */ true);
671670
assert(Pivot->getType()->isIntegerTy() && "Pivot should be an integer.");
672671
return Builder.CreateIntrinsic(Intrinsic::vp_merge, {OnTrue->getType()},
673672
{Cond, OnTrue, OnFalse, Pivot}, nullptr,

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,8 @@ void VPlanTransforms::addActiveLaneMask(
13501350
}
13511351

13521352
/// Replace recipes with their EVL variants.
1353-
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
1353+
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL,
1354+
LLVMContext &Ctx) {
13541355
using namespace llvm::VPlanPatternMatch;
13551356
SmallVector<VPValue *> HeaderMasks = collectAllHeaderMasks(Plan);
13561357
for (VPValue *HeaderMask : collectAllHeaderMasks(Plan)) {
@@ -1384,15 +1385,14 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13841385
VPValue *NewMask = GetNewMask(Red->getCondOp());
13851386
return new VPReductionEVLRecipe(*Red, EVL, NewMask);
13861387
})
1387-
.Case<VPInstruction>([&](VPInstruction *VPI) {
1388+
.Case<VPInstruction>([&](VPInstruction *VPI) -> VPRecipeBase * {
13881389
VPValue *LHS, *RHS;
13891390
if (!match(VPI, m_Select(m_Specific(HeaderMask), m_VPValue(LHS),
13901391
m_VPValue(RHS))))
13911392
return nullptr;
1392-
VPValue *Cond = Plan.getOrAddLiveIn(ConstantInt::getTrue(
1393-
CanonicalIVPHI->getScalarType()->getContext()));
1393+
VPValue *Cond = Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx));
13941394
return new VPInstruction(VPInstruction::MergeUntilPivot,
1395-
{Cond, LHS, RHS, EVL},
1395+
{Cond, LHS, RHS, &EVL},
13961396
VPI->getDebugLoc());
13971397
})
13981398
.Default([&](VPRecipeBase *R) { return nullptr; });
@@ -1486,7 +1486,8 @@ bool VPlanTransforms::tryAddExplicitVectorLength(VPlan &Plan) {
14861486
NextEVLIV->insertBefore(CanonicalIVIncrement);
14871487
EVLPhi->addOperand(NextEVLIV);
14881488

1489-
transformRecipestoEVLRecipes(Plan, *VPEVL);
1489+
LLVMContext &Ctx = CanonicalIVPHI->getScalarType()->getContext();
1490+
transformRecipestoEVLRecipes(Plan, *VPEVL, Ctx);
14901491

14911492
// Replace all uses of VPCanonicalIVPHIRecipe by
14921493
// VPEVLBasedIVPHIRecipe except for the canonical IV increment.

0 commit comments

Comments
 (0)