[llvm] [LV][EVL] Support cast instruction with EVL-vectorization (PR #108351)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 12 22:19:44 PST 2024


================
@@ -1484,6 +1484,25 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
                 VPValue *NewMask = GetNewMask(Red->getCondOp());
                 return new VPReductionEVLRecipe(*Red, EVL, NewMask);
               })
+              .Case<VPWidenCastRecipe>(
+                  [&](VPWidenCastRecipe *CInst) -> VPRecipeBase * {
+                    auto *CI = cast<CastInst>(CInst->getUnderlyingInstr());
+                    Intrinsic::ID VPID =
+                        VPIntrinsic::getForOpcode(CI->getOpcode());
+                    if (VPID == Intrinsic::not_intrinsic)
+                      return nullptr;
+                    SmallVector<VPValue *> Ops(CInst->operands());
+                    if (VPIntrinsic::getMaskParamPos(VPID)) {
+                      VPValue *Mask = Plan.getOrAddLiveIn(ConstantInt::getTrue(
+                          IntegerType::getInt1Ty(CI->getContext())));
+                      Ops.push_back(Mask);
+                    }
+                    if (VPIntrinsic::getVectorLengthParamPos(VPID)) {
+                      Ops.push_back(&EVL);
+                    }
----------------
LiqinWeng wrote:

`assert(VPIntrinsic::getVectorLengthParamPos(VPID) && Ops.push_back(Mask) )` ???

https://github.com/llvm/llvm-project/pull/108351


More information about the llvm-commits mailing list