Skip to content

Commit 9be8fd1

Browse files
committed
[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.
1 parent ff68f71 commit 9be8fd1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22396,7 +22396,7 @@ static SDValue performIntrinsicCombine(SDNode *N,
2239622396
return tryCombineCRC32(0xffff, N, DAG);
2239722397
case Intrinsic::aarch64_sve_saddv:
2239822398
// There is no i64 version of SADDV because the sign is irrelevant.
22399-
if (N->getOperand(2)->getValueType(0).getVectorElementType() == MVT::i64)
22399+
if (N->getOperand(2).getValueType().getVectorElementType() == MVT::i64)
2240022400
return combineSVEReductionInt(N, AArch64ISD::UADDV_PRED, DAG);
2240122401
else
2240222402
return combineSVEReductionInt(N, AArch64ISD::SADDV_PRED, DAG);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
; Function Attrs: mustprogress nounwind ssp uwtable(sync) vscale_range(1,16)
5+
define noundef i64 @svaddv_SVBool_SVInt64_t(<vscale x 16 x i1> %a, <vscale x 2 x i64> %b) {
6+
; CHECK-LABEL: svaddv_SVBool_SVInt64_t:
7+
; CHECK: // %bb.0: // %entry
8+
; CHECK-NEXT: //APP
9+
; CHECK-NEXT: //NO_APP
10+
; CHECK-NEXT: uaddv d0, p0, z0.d
11+
; CHECK-NEXT: fmov x0, d0
12+
; CHECK-NEXT: ret
13+
entry:
14+
%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)
15+
%asmresult = extractvalue { <vscale x 16 x i1>, <vscale x 2 x i64> } %0, 0
16+
%asmresult1 = extractvalue { <vscale x 16 x i1>, <vscale x 2 x i64> } %0, 1
17+
%1 = tail call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %asmresult)
18+
%2 = tail call i64 @llvm.aarch64.sve.saddv.nxv2i64(<vscale x 2 x i1> %1, <vscale x 2 x i64> %asmresult1)
19+
ret i64 %2
20+
}
21+
22+
declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
23+
declare i64 @llvm.aarch64.sve.saddv.nxv2i64(<vscale x 2 x i1>, <vscale x 2 x i64>)

0 commit comments

Comments
 (0)