[llvm] [AArch64] Use SVE rev for full reverse shuffles with SVE128 (PR #224589)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 07:00:21 PDT 2026


================
@@ -16195,11 +16195,23 @@ SDValue AArch64TargetLowering::LowerVECTOR_SHUFFLE(SDValue Op,
                     DAG.getNode(AArch64ISD::NVCAST, DL, BSVT, V1)));
   }
 
-  if (((NumElts == 8 && EltSize == 16) || (NumElts == 16 && EltSize == 8)) &&
+  if (((NumElts == 8 && EltSize == 16) || (NumElts == 16 && EltSize == 8) ||
+       (NumElts == 4 && EltSize == 32)) &&
       ShuffleVectorInst::isReverseMask(ShuffleMask, ShuffleMask.size())) {
-    SDValue Rev = DAG.getNode(AArch64ISD::REV64, DL, VT, V1);
-    return DAG.getNode(AArch64ISD::EXT, DL, VT, Rev, Rev,
-                       DAG.getConstant(8, DL, MVT::i32));
+    // For sve128 we can use a REV full vector reverse.
+    if (Subtarget->isSVEorStreamingSVEAvailable() &&
----------------
david-arm wrote:

I realise the original code was already generating a rev and I'm probably missing something, but how can we just ignore `V2` here? Is it just a convention that reverse shuffles only ever reference the first vector?

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


More information about the llvm-commits mailing list