[llvm] [AArch64][ISel] Prefer SVE over NEON for fixed-width ASL LSR (PR #199003)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 05:08:38 PDT 2026


================
@@ -17638,12 +17678,17 @@ SDValue AArch64TargetLowering::LowerVectorSRA_SRL_SHL(SDValue Op,
                          Op->getFlags());
     }
 
-    // Right shift register.  Note, there is not a shift right register
-    // instruction, but the shift left register instruction takes a signed
-    // value, where negative numbers specify a right shift.
+    // SVE preference for non-immediate shifts only. The SVE instruction is
+    // destructive, so prefer it only when the shifted value can be clobbered
+    // without needing a MOVPRFX. Keep NEON for splatted negated shift amounts
+    // because SSHL/USHL can consume the original value directly.
+    if (useSVEForFixedLengthVectorVT(VT, /*OverrideNEON=*/true) &&
+        canUseDestructiveSVERightShift(Op) &&
+        !isNegatedSplatShiftAmount(Op.getOperand(1), DAG))
+      return LowerToPredicatedOp(Op, DAG, PredOpc);
----------------
paulwalker-arm wrote:

We should not need this change. Instead you'll want to do `bool OverideNEON = !Subtarget->isNeonAvailable() || ....` and pass that into the existing `useSVEForFixedLengthVectorVT()` call.

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


More information about the llvm-commits mailing list