Skip to content

Commit 40fd17a

Browse files
authored
[ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (llvm#80819)
* fixes llvm#71751 * changed return types in the table gen file responsible for generation of the problematic intrinsics * this is to ensure that the return type for the functions is the same as specified in the Arm Developer Documentation and avoid casting bugs (https://developer.arm.com/architectures/instruction-sets/intrinsics/vqrshrunh_n_s16) * updated lit tests to reflect the change in return type, worth noting that LLVM does not seems to differentiate signed and unsigned ints in the IR, hence the change in type cannot be checked in IR as far as I am aware
1 parent d6c7253 commit 40fd17a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

clang/include/clang/Basic/arm_neon.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,9 +1354,9 @@ let isScalarNarrowShift = 1 in {
13541354
// Signed/Unsigned Saturating Rounded Shift Right Narrow (Immediate)
13551355
def SCALAR_SQRSHRN_N: SInst<"vqrshrn_n", "(1<)1I", "SsSiSlSUsSUiSUl">;
13561356
// Signed Saturating Shift Right Unsigned Narrow (Immediate)
1357-
def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<)1I", "SsSiSl">;
1357+
def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<U)1I", "SsSiSl">;
13581358
// Signed Saturating Rounded Shift Right Unsigned Narrow (Immediate)
1359-
def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1<)1I", "SsSiSl">;
1359+
def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1<U)1I", "SsSiSl">;
13601360
}
13611361

13621362
////////////////////////////////////////////////////////////////////////////////

clang/test/CodeGen/aarch64-neon-intrinsics.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14132,24 +14132,24 @@ int32_t test_vqshrund_n_s64(int64_t a) {
1413214132
// CHECK: [[VQRSHRUNH_N_S16:%.*]] = call <8 x i8> @llvm.aarch64.neon.sqrshrun.v8i8(<8 x i16> [[TMP0]], i32 8)
1413314133
// CHECK: [[TMP1:%.*]] = extractelement <8 x i8> [[VQRSHRUNH_N_S16]], i64 0
1413414134
// CHECK: ret i8 [[TMP1]]
14135-
int8_t test_vqrshrunh_n_s16(int16_t a) {
14136-
return (int8_t)vqrshrunh_n_s16(a, 8);
14135+
uint8_t test_vqrshrunh_n_s16(int16_t a) {
14136+
return (uint8_t)vqrshrunh_n_s16(a, 8);
1413714137
}
1413814138

1413914139
// CHECK-LABEL: @test_vqrshruns_n_s32(
1414014140
// CHECK: [[TMP0:%.*]] = insertelement <4 x i32> poison, i32 %a, i64 0
1414114141
// CHECK: [[VQRSHRUNS_N_S32:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqrshrun.v4i16(<4 x i32> [[TMP0]], i32 16)
1414214142
// CHECK: [[TMP1:%.*]] = extractelement <4 x i16> [[VQRSHRUNS_N_S32]], i64 0
1414314143
// CHECK: ret i16 [[TMP1]]
14144-
int16_t test_vqrshruns_n_s32(int32_t a) {
14145-
return (int16_t)vqrshruns_n_s32(a, 16);
14144+
uint16_t test_vqrshruns_n_s32(int32_t a) {
14145+
return (uint16_t)vqrshruns_n_s32(a, 16);
1414614146
}
1414714147

1414814148
// CHECK-LABEL: @test_vqrshrund_n_s64(
1414914149
// CHECK: [[VQRSHRUND_N_S64:%.*]] = call i32 @llvm.aarch64.neon.sqrshrun.i32(i64 %a, i32 32)
1415014150
// CHECK: ret i32 [[VQRSHRUND_N_S64]]
14151-
int32_t test_vqrshrund_n_s64(int64_t a) {
14152-
return (int32_t)vqrshrund_n_s64(a, 32);
14151+
uint32_t test_vqrshrund_n_s64(int64_t a) {
14152+
return (uint32_t)vqrshrund_n_s64(a, 32);
1415314153
}
1415414154

1415514155
// CHECK-LABEL: @test_vcvts_n_f32_s32(

0 commit comments

Comments
 (0)