[llvm] [AArch64] Use unsigned variant of `<s|u>addv_64` SVE vector reduction intrinsic for 64 bit values (PR #157418)
Rajveer Singh Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 8 03:25:11 PDT 2025
https://github.com/Rajveer100 created https://github.com/llvm/llvm-project/pull/157418
Resolves #157122
When lowering this intrinsic, we are querying the first result type (i.e `getValueType(0)`) which may not always be true hence giving wrong the extended value type.
As an improvement, for 64 bit values an extend isn't performed regardless of `<U/S>ADDV_PRED`, so we can directly use the unsigned variant.
>From 2c1ede59a9e8503aff1bb3e4ea0ce66f49c45bfd Mon Sep 17 00:00:00 2001
From: Rajveer <rajveer.developer at icloud.com>
Date: Mon, 8 Sep 2025 15:43:24 +0530
Subject: [PATCH] [AArch64] Use unsigned variant of `<s|u>addv_64` SVE vector
reduction intrinsic for 64 bit values
Resolves #157122
When lowering this intrinsic, we are querying the first result type (i.e `getValueType(0)`)
which may not always be true hence giving wrong the extended value type.
As an improvement, for 64 bit values an extend isn't performed regardless of `<U/S>ADDV_PRED`,
so we can directly use the unsigned variant.
---
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index aefbbe2534be2..a8d184738c13b 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -22395,11 +22395,7 @@ static SDValue performIntrinsicCombine(SDNode *N,
case Intrinsic::aarch64_crc32ch:
return tryCombineCRC32(0xffff, N, DAG);
case Intrinsic::aarch64_sve_saddv:
- // There is no i64 version of SADDV because the sign is irrelevant.
- if (N->getOperand(2)->getValueType(0).getVectorElementType() == MVT::i64)
- return combineSVEReductionInt(N, AArch64ISD::UADDV_PRED, DAG);
- else
- return combineSVEReductionInt(N, AArch64ISD::SADDV_PRED, DAG);
+ return combineSVEReductionInt(N, AArch64ISD::UADDV_PRED, DAG);
case Intrinsic::aarch64_sve_uaddv:
return combineSVEReductionInt(N, AArch64ISD::UADDV_PRED, DAG);
case Intrinsic::aarch64_sve_smaxv:
More information about the llvm-commits
mailing list