[llvm] [LV] Vectorize fmin/fmax reductions (PR #198300)

Nashe Mncube via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 08:01:12 PDT 2026


================

----------------
nasherm wrote:

I've done some local testing and `handleFirstArgMinOrMax` doesn't get triggered with FP types.  This is because of the following snippet 

```cpp
@@ -2217,7 +2230,7 @@ bool VPlanTransforms::handleMultiUseReductions(VPlan &Plan,
     MinOrMaxResult->moveBefore(*FindIVRdxResult->getParent(),
                                FindIVRdxResult->getIterator());
 
bool IsStrictPredicate = ICmpInst::isLT(Pred) || ICmpInst::isGT(Pred);
     if (IsStrictPredicate) {
       if (!handleFirstArgMinOrMax(Plan, MinOrMaxPhiR, FindIVPhiR,
                                   cast<VPWidenIntOrFpInductionRecipe>(IVOp),
```

The `IsStrictPredicate` is only true for integer types. I'm wondering if I should add support for FP strict predicates as well i.e. making the following change? 

```diff
@@ -2217,7 +2230,7 @@ bool VPlanTransforms::handleMultiUseReductions(VPlan &Plan,
     MinOrMaxResult->moveBefore(*FindIVRdxResult->getParent(),
                                FindIVRdxResult->getIterator());
 
-    bool IsStrictPredicate = ICmpInst::isLT(Pred) || ICmpInst::isGT(Pred);
+    bool IsStrictPredicate = CmpInst::isStrictPredicate(Pred);
     if (IsStrictPredicate) {
       if (!handleFirstArgMinOrMax(Plan, MinOrMaxPhiR, FindIVPhiR,
                                   cast<VPWidenIntOrFpInductionRecipe>(IVOp),
~
```


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


More information about the llvm-commits mailing list