Skip to content

Commit 349af80

Browse files
committed
[clang][AArch64] Correct return type of Neon vqmovun intrinsics
Neon intrinsics vqmovunh_s16, vqmovuns_s32, vqmovund_s64 should have unsigned return types. See https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics?search=vqmovun Fixes https://bugs.llvm.org/show_bug.cgi?id=46840 Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D85118
1 parent e616a42 commit 349af80

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

clang/include/clang/Basic/arm_neon.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def XTN2 : SOpInst<"vmovn_high", "(<Q)<Q", "silUsUiUl", OP_XTN>;
830830

831831
////////////////////////////////////////////////////////////////////////////////
832832
// Signed integer saturating extract and unsigned narrow to high
833-
def SQXTUN2 : SOpInst<"vqmovun_high", "(<U)(<q).", "HsHiHl", OP_SQXTUN>;
833+
def SQXTUN2 : SOpInst<"vqmovun_high", "(<U)(<Uq).", "HsHiHl", OP_SQXTUN>;
834834

835835
////////////////////////////////////////////////////////////////////////////////
836836
// Integer saturating extract and narrow to high
@@ -1498,7 +1498,7 @@ def SCALAR_SQDMULL : SInst<"vqdmull", "(1>)11", "SsSi">;
14981498

14991499
////////////////////////////////////////////////////////////////////////////////
15001500
// Scalar Signed Saturating Extract Unsigned Narrow
1501-
def SCALAR_SQXTUN : SInst<"vqmovun", "(1<)1", "SsSiSl">;
1501+
def SCALAR_SQXTUN : SInst<"vqmovun", "(U1<)1", "SsSiSl">;
15021502

15031503
////////////////////////////////////////////////////////////////////////////////
15041504
// Scalar Signed Saturating Extract Narrow

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14094,24 +14094,24 @@ int64_t test_vqdmulls_s32(int32_t a, int32_t b) {
1409414094
// CHECK: [[VQMOVUNH_S16_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.sqxtun.v8i8(<8 x i16> [[TMP0]])
1409514095
// CHECK: [[TMP1:%.*]] = extractelement <8 x i8> [[VQMOVUNH_S16_I]], i64 0
1409614096
// CHECK: ret i8 [[TMP1]]
14097-
int8_t test_vqmovunh_s16(int16_t a) {
14098-
return (int8_t)vqmovunh_s16(a);
14097+
uint8_t test_vqmovunh_s16(int16_t a) {
14098+
return (uint8_t)vqmovunh_s16(a);
1409914099
}
1410014100

1410114101
// CHECK-LABEL: @test_vqmovuns_s32(
1410214102
// CHECK: [[TMP0:%.*]] = insertelement <4 x i32> undef, i32 %a, i64 0
1410314103
// CHECK: [[VQMOVUNS_S32_I:%.*]] = call <4 x i16> @llvm.aarch64.neon.sqxtun.v4i16(<4 x i32> [[TMP0]])
1410414104
// CHECK: [[TMP1:%.*]] = extractelement <4 x i16> [[VQMOVUNS_S32_I]], i64 0
1410514105
// CHECK: ret i16 [[TMP1]]
14106-
int16_t test_vqmovuns_s32(int32_t a) {
14107-
return (int16_t)vqmovuns_s32(a);
14106+
uint16_t test_vqmovuns_s32(int32_t a) {
14107+
return (uint16_t)vqmovuns_s32(a);
1410814108
}
1410914109

1411014110
// CHECK-LABEL: @test_vqmovund_s64(
1411114111
// CHECK: [[VQMOVUND_S64_I:%.*]] = call i32 @llvm.aarch64.neon.scalar.sqxtun.i32.i64(i64 %a)
1411214112
// CHECK: ret i32 [[VQMOVUND_S64_I]]
14113-
int32_t test_vqmovund_s64(int64_t a) {
14114-
return (int32_t)vqmovund_s64(a);
14113+
uint32_t test_vqmovund_s64(int64_t a) {
14114+
return (uint32_t)vqmovund_s64(a);
1411514115
}
1411614116

1411714117
// CHECK-LABEL: @test_vqmovnh_s16(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ int32x2_t test_vqmovun_s64(int64x2_t a) {
19081908
// CHECK: [[VQMOVUN_V1_I_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.sqxtun.v8i8(<8 x i16> %b)
19091909
// CHECK: [[SHUFFLE_I_I:%.*]] = shufflevector <8 x i8> %a, <8 x i8> [[VQMOVUN_V1_I_I]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
19101910
// CHECK: ret <16 x i8> [[SHUFFLE_I_I]]
1911-
int8x16_t test_vqmovun_high_s16(int8x8_t a, int16x8_t b) {
1911+
uint8x16_t test_vqmovun_high_s16(uint8x8_t a, int16x8_t b) {
19121912
return vqmovun_high_s16(a, b);
19131913
}
19141914

@@ -1918,7 +1918,7 @@ int8x16_t test_vqmovun_high_s16(int8x8_t a, int16x8_t b) {
19181918
// CHECK: [[VQMOVUN_V2_I_I:%.*]] = bitcast <4 x i16> [[VQMOVUN_V1_I_I]] to <8 x i8>
19191919
// CHECK: [[SHUFFLE_I_I:%.*]] = shufflevector <4 x i16> %a, <4 x i16> [[VQMOVUN_V1_I_I]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
19201920
// CHECK: ret <8 x i16> [[SHUFFLE_I_I]]
1921-
int16x8_t test_vqmovun_high_s32(int16x4_t a, int32x4_t b) {
1921+
uint16x8_t test_vqmovun_high_s32(uint16x4_t a, int32x4_t b) {
19221922
return vqmovun_high_s32(a, b);
19231923
}
19241924

@@ -1928,7 +1928,7 @@ int16x8_t test_vqmovun_high_s32(int16x4_t a, int32x4_t b) {
19281928
// CHECK: [[VQMOVUN_V2_I_I:%.*]] = bitcast <2 x i32> [[VQMOVUN_V1_I_I]] to <8 x i8>
19291929
// CHECK: [[SHUFFLE_I_I:%.*]] = shufflevector <2 x i32> %a, <2 x i32> [[VQMOVUN_V1_I_I]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
19301930
// CHECK: ret <4 x i32> [[SHUFFLE_I_I]]
1931-
int32x4_t test_vqmovun_high_s64(int32x2_t a, int64x2_t b) {
1931+
uint32x4_t test_vqmovun_high_s64(uint32x2_t a, int64x2_t b) {
19321932
return vqmovun_high_s64(a, b);
19331933
}
19341934

clang/test/Sema/arm64-neon-header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#include <arm_neon.h>
44

5-
int16x8_t foo(int8x8_t p0, int16x8_t p1) {
5+
int16x8_t foo(uint8x8_t p0, int16x8_t p1) {
66
return vqmovun_high_s16(p0, p1); // expected-warning {{incompatible vector types returning 'uint8x16_t'}}
77
}

0 commit comments

Comments
 (0)