[llvm] [SLP] Check for extracts, being replaced by original scalars, for user nodes (PR #149572)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 02:01:59 PDT 2025


================
@@ -13245,7 +13366,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
       });
       InVectors.front() = V;
     }
-    if (!SubVectors.empty()) {
+    if (!SubVectors.empty() &&
+        (SubVectors.size() > 1 || SubVectors.front().second != 0 ||
+         SubVectors.front().first->getVectorFactor() != CommonMask.size())) {
----------------
gbossu wrote:

Maybe simplify the `!SubVectors.empty()` away? We later check `SubVectors.size() > 1` anyway.

Also, for conditions that aren't immediately readable, either write a comment, or give a name to that check. E.g.
```
bool WhatThisIsChecking = SubVectors.size() > 1 || SubVectors.front().second != 0 ||
    SubVectors.front().first->getVectorFactor() != CommonMask.size();
if (WhatThisIsChecking) {
  ...
}
```

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


More information about the llvm-commits mailing list