[llvm] [LV] Fix cost misaligned when gather/scatter w/ addr is uniform. (PR #157387)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 23:36:22 PDT 2025


================
@@ -6905,6 +6905,15 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,
       if (isa<VPPartialReductionRecipe>(&R))
         return true;
 
+      // The VPlan-based cost model can analysis if recipes is scalar
+      // recursively, but legacy cost model cannot.
+      if (auto *WidenMemR = dyn_cast<VPWidenMemoryRecipe>(&R);
+          WidenMemR &&
+          vputils::isSingleScalar(WidenMemR->getAddr()) !=
----------------
lukel97 wrote:

Nit I don't think the `if (Foo = ...; Foo && ...)` pattern is used much in the loop vectorizer
```suggestion
      if (auto *WidenMemR = dyn_cast<VPWidenMemoryRecipe>(&R))
          if (vputils::isSingleScalar(WidenMemR->getAddr()) !=
```

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


More information about the llvm-commits mailing list