[llvm] [AArch64] Prefer SVE2 for fixed-length i64 [S|U][MIN|MAX] reductions (PR #181161)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 16 08:50:28 PST 2026


================
@@ -31577,12 +31536,31 @@ SDValue AArch64TargetLowering::LowerReductionToSVE(unsigned Opcode,
   // UADDV always returns an i64 result.
   EVT ResVT = (Opcode == AArch64ISD::UADDV_PRED) ? MVT::i64 :
                                                    SrcVT.getVectorElementType();
+
+  SDValue Rdx;
+  // Lower v2<ty> VECREDUCE_[US](MIN|MAX) to pairwise operation with SVE2/SME.
+  if (SrcVT.getVectorElementCount() == ElementCount::getFixed(2) &&
+      (Subtarget->hasSVE2() || Subtarget->hasSME())) {
+    if (std::optional<Intrinsic::ID> PairwiseIID =
+            getPairwiseOpForReduction(ScalarOp->getOpcode())) {
+      EVT VT = VecOp.getValueType();
+      EVT PredVT = VT.changeVectorElementType(*DAG.getContext(), MVT::i1);
----------------
paulwalker-arm wrote:

You can use the MVT variant of `changeVectorElementType` here because it's guaranteed to be a simple VT, otherwise we've got bigger problems.

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


More information about the llvm-commits mailing list