[llvm] [RISCV] Improve lowering of spread(2) shuffles (PR #118658)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 11:13:35 PST 2024


================
@@ -5331,17 +5331,36 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
     // Extract the halves of the vectors.
     MVT HalfVT = VT.getHalfNumVectorElementsVT();
 
+    // Recognize if one half is actually undef; the matching above will
+    // otherwise reuse the even stream for the undef one.  This improves
+    // spread(2) shuffles.
+    bool EvenIsUndef = true, OddIsUndef = true;
----------------
topperc wrote:

Could simplify this loop to

```
bool IsUndef[2] = { true, true};
for (unsigned i = 0; i < Mask.size(); i++)
  IsUndef[i % 2] &= (Mask[i] == -1);
```

but maybe the array is too subtle?

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


More information about the llvm-commits mailing list