[llvm] [RISCV] Match vcompress during shuffle lowering (PR #117748)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 12:35:22 PST 2024


================
@@ -5372,6 +5394,25 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
     if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
       return V;
 
+    // Can we generate a vcompress instead of a vrgather?  These scale better
+    // at high LMUL, at the cost of not being able to fold a following select
+    // into them.  The mask constants are also smaller than the index vector
+    // constants, and thus easier to materialize.
+    if (isCompressMask(Mask)) {
+      SmallVector<SDValue> MaskVals;
+      MaskVals.resize(NumElts, DAG.getConstant(false, DL, XLenVT));
+      for (const auto &Idx : enumerate(Mask)) {
----------------
topperc wrote:

Why are we using `enumerate` if we're never using `index()`?

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


More information about the llvm-commits mailing list