Skip to content

Commit 46c229b

Browse files
committed
Rebase and updated
1 parent 79fc9ca commit 46c229b

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
@@ -674,11 +674,10 @@ Value *VPInstruction::generate(VPTransformState &State) {
674674
return NewPhi;
675675
}
676676
case VPInstruction::MergeUntilPivot: {
677-
assert(Part == 0 && "No unrolling expected for predicated vectorization.");
678-
Value *Cond = State.get(getOperand(0), Part);
679-
Value *OnTrue = State.get(getOperand(1), Part);
680-
Value *OnFalse = State.get(getOperand(2), Part);
681-
Value *Pivot = State.get(getOperand(3), VPIteration(0, 0));
677+
Value *Cond = State.get(getOperand(0), 0);
678+
Value *OnTrue = State.get(getOperand(1), 0);
679+
Value *OnFalse = State.get(getOperand(2), 0);
680+
Value *Pivot = State.get(getOperand(3), /* IsScalar */ true);
682681
assert(Pivot->getType()->isIntegerTy() && "Pivot should be an integer.");
683682
return Builder.CreateIntrinsic(Intrinsic::vp_merge, {OnTrue->getType()},
684683
{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
@@ -1351,7 +1351,8 @@ void VPlanTransforms::addActiveLaneMask(
13511351
}
13521352

13531353
/// Replace recipes with their EVL variants.
1354-
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
1354+
static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL,
1355+
LLVMContext &Ctx) {
13551356
using namespace llvm::VPlanPatternMatch;
13561357
SmallVector<VPValue *> HeaderMasks = collectAllHeaderMasks(Plan);
13571358
VPTypeAnalysis TypeInfo(Plan.getCanonicalIV()->getScalarType());
@@ -1393,15 +1394,14 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
13931394
TypeInfo.inferScalarType(Sel),
13941395
false, false, false);
13951396
})
1396-
.Case<VPInstruction>([&](VPInstruction *VPI) {
1397+
.Case<VPInstruction>([&](VPInstruction *VPI) -> VPRecipeBase * {
13971398
VPValue *LHS, *RHS;
13981399
if (!match(VPI, m_Select(m_Specific(HeaderMask), m_VPValue(LHS),
13991400
m_VPValue(RHS))))
14001401
return nullptr;
1401-
VPValue *Cond = Plan.getOrAddLiveIn(ConstantInt::getTrue(
1402-
CanonicalIVPHI->getScalarType()->getContext()));
1402+
VPValue *Cond = Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx));
14031403
return new VPInstruction(VPInstruction::MergeUntilPivot,
1404-
{Cond, LHS, RHS, EVL},
1404+
{Cond, LHS, RHS, &EVL},
14051405
VPI->getDebugLoc());
14061406
})
14071407
.Default([&](VPRecipeBase *R) { return nullptr; });
@@ -1495,7 +1495,8 @@ bool VPlanTransforms::tryAddExplicitVectorLength(VPlan &Plan) {
14951495
NextEVLIV->insertBefore(CanonicalIVIncrement);
14961496
EVLPhi->addOperand(NextEVLIV);
14971497

1498-
transformRecipestoEVLRecipes(Plan, *VPEVL);
1498+
LLVMContext &Ctx = CanonicalIVPHI->getScalarType()->getContext();
1499+
transformRecipestoEVLRecipes(Plan, *VPEVL, Ctx);
14991500

15001501
// Replace all uses of VPCanonicalIVPHIRecipe by
15011502
// VPEVLBasedIVPHIRecipe except for the canonical IV increment.

0 commit comments

Comments
 (0)