Skip to content

Commit 36d5390

Browse files
authored
[AArch64] Use unsigned variant of <s|u>addv_64 SVE vector reduction intrinsic for 64 bit values (#157418)
1 parent c82fbe8 commit 36d5390

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22659,7 +22659,7 @@ static SDValue performIntrinsicCombine(SDNode *N,
2265922659
return tryCombineCRC32(0xffff, N, DAG);
2266022660
case Intrinsic::aarch64_sve_saddv:
2266122661
// There is no i64 version of SADDV because the sign is irrelevant.
22662-
if (N->getOperand(2)->getValueType(0).getVectorElementType() == MVT::i64)
22662+
if (N->getOperand(2).getValueType().getVectorElementType() == MVT::i64)
2266322663
return combineSVEReductionInt(N, AArch64ISD::UADDV_PRED, DAG);
2266422664
else
2266522665
return combineSVEReductionInt(N, AArch64ISD::SADDV_PRED, DAG);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
3+
4+
define noundef i64 @svaddv_SVBool_SVInt64_t(<vscale x 16 x i1> %a, <vscale x 2 x i64> %b) {
5+
; CHECK-LABEL: svaddv_SVBool_SVInt64_t:
6+
; CHECK: // %bb.0: // %entry
7+
; CHECK-NEXT: //APP
8+
; CHECK-NEXT: //NO_APP
9+
; CHECK-NEXT: uaddv d0, p0, z0.d
10+
; CHECK-NEXT: fmov x0, d0
11+
; CHECK-NEXT: ret
12+
entry:
13+
%0 = tail call { <vscale x 16 x i1>, <vscale x 2 x i64> } asm sideeffect "", "=@3Upa,=w,0,1"(<vscale x 16 x i1> %a, <vscale x 2 x i64> %b)
14+
%asmresult = extractvalue { <vscale x 16 x i1>, <vscale x 2 x i64> } %0, 0
15+
%asmresult1 = extractvalue { <vscale x 16 x i1>, <vscale x 2 x i64> } %0, 1
16+
%1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %asmresult)
17+
%2 = tail call i64 @llvm.aarch64.sve.saddv.nxv2i64(<vscale x 2 x i1> %1, <vscale x 2 x i64> %asmresult1)
18+
ret i64 %2
19+
}
20+
21+
declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
22+
declare i64 @llvm.aarch64.sve.saddv.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>)

0 commit comments

Comments
 (0)