[llvm] [LV][VPlan] set FastMathFlags on EVLRecipe (PR #119847)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 02:25:37 PST 2024


================
@@ -1516,16 +1516,23 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
                         IntegerType::getInt1Ty(CI->getContext())));
                     Ops.push_back(Mask);
                     Ops.push_back(&EVL);
+                    FastMathFlags FMF = {};
+                    if (isa<FPMathOperator>(CI))
+                      FMF = CI->getFastMathFlags();
                     return new VPWidenIntrinsicRecipe(
-                        VPID, Ops, TypeInfo.inferScalarType(CInst),
+                        VPID, Ops, TypeInfo.inferScalarType(CInst), FMF,
                         CInst->getDebugLoc());
                   })
               .Case<VPWidenSelectRecipe>([&](VPWidenSelectRecipe *Sel) {
+                auto *SelInst = dyn_cast<SelectInst>(Sel->getUnderlyingInstr());
----------------
fhahn wrote:

Please only use flags from the recipe, not the underlying instruction. Using from the underlying instruction may be incorrect in some cases, e.g. if the recipe originally was only execute unconditionally.

Same for `VPWidenCastRecipe` above.


Maybe start with just `Select` VPInstructions here, then PRs to add flags to `VPWidenCastRecipe`/`VPWidenSelectRecipe` separately, then a PR to pass them through to the intrinsics.

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


More information about the llvm-commits mailing list