@@ -1442,17 +1442,18 @@ void VPlanTransforms::addActiveLaneMask(
1442
1442
HeaderMask->replaceAllUsesWith (LaneMask);
1443
1443
}
1444
1444
1445
- static VPRecipeBase *createEVLRecipe (VPValue &EVL, VPValue *HeaderMask,
1446
- VPValue *AllOneMask,
1447
- VPRecipeBase *CurRecipe,
1448
- VPTypeAnalysis TypeInfo) {
1445
+ // / Create EVLRecipe with Recipe
1446
+ static VPRecipeBase *createEVLRecipe (VPValue *HeaderMask,
1447
+ VPRecipeBase &CurRecipe,
1448
+ VPTypeAnalysis &TypeInfo,
1449
+ VPValue &AllOneMask, VPValue &EVL) {
1449
1450
using namespace llvm ::VPlanPatternMatch;
1450
1451
auto GetNewMask = [&](VPValue *OrigMask) -> VPValue * {
1451
1452
assert (OrigMask && " Unmasked recipe when folding tail" );
1452
1453
return HeaderMask == OrigMask ? nullptr : OrigMask;
1453
1454
};
1454
1455
1455
- return TypeSwitch<VPRecipeBase *, VPRecipeBase *>(CurRecipe)
1456
+ return TypeSwitch<VPRecipeBase *, VPRecipeBase *>(& CurRecipe)
1456
1457
.Case <VPWidenLoadRecipe>([&](VPWidenLoadRecipe *L) {
1457
1458
VPValue *NewMask = GetNewMask (L->getMask ());
1458
1459
return new VPWidenLoadEVLRecipe (*L, EVL, NewMask);
@@ -1473,18 +1474,16 @@ static VPRecipeBase *createEVLRecipe(VPValue &EVL, VPValue *HeaderMask,
1473
1474
})
1474
1475
.Case <VPWidenIntrinsicRecipe>(
1475
1476
[&](VPWidenIntrinsicRecipe *CInst) -> VPRecipeBase * {
1476
- auto *CI = cast <CallInst>(CInst->getUnderlyingInstr ());
1477
+ auto *CI = dyn_cast <CallInst>(CInst->getUnderlyingInstr ());
1477
1478
Intrinsic::ID VPID = VPIntrinsic::getForIntrinsic (
1478
1479
CI->getCalledFunction ()->getIntrinsicID ());
1479
1480
assert (VPID != Intrinsic::not_intrinsic &&
1480
- " Expected VP Instrinsic" );
1481
-
1482
- SmallVector<VPValue *> Ops (CInst->operands ());
1483
- assert (VPIntrinsic::getMaskParamPos (VPID) &&
1481
+ VPIntrinsic::getMaskParamPos (VPID) &&
1484
1482
VPIntrinsic::getVectorLengthParamPos (VPID) &&
1485
1483
" Expected VP intrinsic" );
1486
1484
1487
- Ops.push_back (AllOneMask);
1485
+ SmallVector<VPValue *> Ops (CInst->operands ());
1486
+ Ops.push_back (&AllOneMask);
1488
1487
Ops.push_back (&EVL);
1489
1488
return new VPWidenIntrinsicRecipe (*CI, VPID, Ops,
1490
1489
TypeInfo.inferScalarType (CInst),
@@ -1494,13 +1493,12 @@ static VPRecipeBase *createEVLRecipe(VPValue &EVL, VPValue *HeaderMask,
1494
1493
auto *CI = dyn_cast<CastInst>(CInst->getUnderlyingInstr ());
1495
1494
Intrinsic::ID VPID = VPIntrinsic::getForOpcode (CI->getOpcode ());
1496
1495
assert (VPID != Intrinsic::not_intrinsic &&
1497
- " Expected vp.casts Instrinsic" );
1496
+ VPIntrinsic::getMaskParamPos (VPID) &&
1497
+ VPIntrinsic::getVectorLengthParamPos (VPID) &&
1498
+ " Expected vp.cast intrinsic" );
1498
1499
1499
1500
SmallVector<VPValue *> Ops (CInst->operands ());
1500
- assert (VPIntrinsic::getMaskParamPos (VPID) &&
1501
- VPIntrinsic::getVectorLengthParamPos (VPID) &&
1502
- " Expected VP intrinsic" );
1503
- Ops.push_back (AllOneMask);
1501
+ Ops.push_back (&AllOneMask);
1504
1502
Ops.push_back (&EVL);
1505
1503
return new VPWidenIntrinsicRecipe (
1506
1504
VPID, Ops, TypeInfo.inferScalarType (CInst), CInst->getDebugLoc ());
@@ -1524,7 +1522,7 @@ static VPRecipeBase *createEVLRecipe(VPValue &EVL, VPValue *HeaderMask,
1524
1522
// Use all true as the condition because this transformation is
1525
1523
// limited to selects whose condition is a header mask.
1526
1524
return new VPWidenIntrinsicRecipe (
1527
- Intrinsic::vp_merge, {AllOneMask, LHS, RHS, &EVL},
1525
+ Intrinsic::vp_merge, {& AllOneMask, LHS, RHS, &EVL},
1528
1526
TypeInfo.inferScalarType (LHS), VPI->getDebugLoc ());
1529
1527
})
1530
1528
.Default ([&](VPRecipeBase *R) { return nullptr ; });
@@ -1548,7 +1546,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
1548
1546
for (VPUser *U : collectUsersRecursively (HeaderMask)) {
1549
1547
auto *CurRecipe = cast<VPRecipeBase>(U);
1550
1548
VPRecipeBase *EVLRecipe =
1551
- createEVLRecipe (EVL, HeaderMask, AllOneMask, CurRecipe, TypeInfo );
1549
+ createEVLRecipe (HeaderMask, *CurRecipe, TypeInfo, *AllOneMask, EVL );
1552
1550
if (!EVLRecipe)
1553
1551
continue ;
1554
1552
0 commit comments