1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
3 // RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
4 
5 #include <arm_mve.h>
6 
7 // CHECK-LABEL: @test_vmaxq_s8(
8 // CHECK-NEXT:  entry:
9 // CHECK-NEXT:    [[TMP0:%.*]] = icmp sge <16 x i8> [[A:%.*]], [[B:%.*]]
10 // CHECK-NEXT:    [[TMP1:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> [[A]], <16 x i8> [[B]]
11 // CHECK-NEXT:    ret <16 x i8> [[TMP1]]
12 //
test_vmaxq_s8(int8x16_t a,int8x16_t b)13 int8x16_t test_vmaxq_s8(int8x16_t a, int8x16_t b)
14 {
15 #ifdef POLYMORPHIC
16     return vmaxq(a, b);
17 #else /* POLYMORPHIC */
18     return vmaxq_s8(a, b);
19 #endif /* POLYMORPHIC */
20 }
21 
22 // CHECK-LABEL: @test_vmaxq_u16(
23 // CHECK-NEXT:  entry:
24 // CHECK-NEXT:    [[TMP0:%.*]] = icmp uge <8 x i16> [[A:%.*]], [[B:%.*]]
25 // CHECK-NEXT:    [[TMP1:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[A]], <8 x i16> [[B]]
26 // CHECK-NEXT:    ret <8 x i16> [[TMP1]]
27 //
test_vmaxq_u16(uint16x8_t a,uint16x8_t b)28 uint16x8_t test_vmaxq_u16(uint16x8_t a, uint16x8_t b)
29 {
30 #ifdef POLYMORPHIC
31     return vmaxq(a, b);
32 #else /* POLYMORPHIC */
33     return vmaxq_u16(a, b);
34 #endif /* POLYMORPHIC */
35 }
36 
37 // CHECK-LABEL: @test_vmaxq_s32(
38 // CHECK-NEXT:  entry:
39 // CHECK-NEXT:    [[TMP0:%.*]] = icmp sge <4 x i32> [[A:%.*]], [[B:%.*]]
40 // CHECK-NEXT:    [[TMP1:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[A]], <4 x i32> [[B]]
41 // CHECK-NEXT:    ret <4 x i32> [[TMP1]]
42 //
test_vmaxq_s32(int32x4_t a,int32x4_t b)43 int32x4_t test_vmaxq_s32(int32x4_t a, int32x4_t b)
44 {
45 #ifdef POLYMORPHIC
46     return vmaxq(a, b);
47 #else /* POLYMORPHIC */
48     return vmaxq_s32(a, b);
49 #endif /* POLYMORPHIC */
50 }
51 
52 // CHECK-LABEL: @test_vmaxq_m_u8(
53 // CHECK-NEXT:  entry:
54 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
55 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
56 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.max.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 1, <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
57 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
58 //
test_vmaxq_m_u8(uint8x16_t inactive,uint8x16_t a,uint8x16_t b,mve_pred16_t p)59 uint8x16_t test_vmaxq_m_u8(uint8x16_t inactive, uint8x16_t a, uint8x16_t b, mve_pred16_t p)
60 {
61 #ifdef POLYMORPHIC
62     return vmaxq_m(inactive, a, b, p);
63 #else /* POLYMORPHIC */
64     return vmaxq_m_u8(inactive, a, b, p);
65 #endif /* POLYMORPHIC */
66 }
67 
68 // CHECK-LABEL: @test_vmaxq_m_s16(
69 // CHECK-NEXT:  entry:
70 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
71 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
72 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.max.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 0, <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
73 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
74 //
test_vmaxq_m_s16(int16x8_t inactive,int16x8_t a,int16x8_t b,mve_pred16_t p)75 int16x8_t test_vmaxq_m_s16(int16x8_t inactive, int16x8_t a, int16x8_t b, mve_pred16_t p)
76 {
77 #ifdef POLYMORPHIC
78     return vmaxq_m(inactive, a, b, p);
79 #else /* POLYMORPHIC */
80     return vmaxq_m_s16(inactive, a, b, p);
81 #endif /* POLYMORPHIC */
82 }
83 
84 // CHECK-LABEL: @test_vmaxq_m_u32(
85 // CHECK-NEXT:  entry:
86 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
87 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
88 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.max.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 1, <4 x i1> [[TMP1]], <4 x i32> [[INACTIVE:%.*]])
89 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
90 //
test_vmaxq_m_u32(uint32x4_t inactive,uint32x4_t a,uint32x4_t b,mve_pred16_t p)91 uint32x4_t test_vmaxq_m_u32(uint32x4_t inactive, uint32x4_t a, uint32x4_t b, mve_pred16_t p)
92 {
93 #ifdef POLYMORPHIC
94     return vmaxq_m(inactive, a, b, p);
95 #else /* POLYMORPHIC */
96     return vmaxq_m_u32(inactive, a, b, p);
97 #endif /* POLYMORPHIC */
98 }
99 
100 // CHECK-LABEL: @test_vmaxq_x_u8(
101 // CHECK-NEXT:  entry:
102 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
103 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
104 // CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.arm.mve.max.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 1, <16 x i1> [[TMP1]], <16 x i8> undef)
105 // CHECK-NEXT:    ret <16 x i8> [[TMP2]]
106 //
test_vmaxq_x_u8(uint8x16_t a,uint8x16_t b,mve_pred16_t p)107 uint8x16_t test_vmaxq_x_u8(uint8x16_t a, uint8x16_t b, mve_pred16_t p)
108 {
109 #ifdef POLYMORPHIC
110     return vmaxq_x(a, b, p);
111 #else /* POLYMORPHIC */
112     return vmaxq_x_u8(a, b, p);
113 #endif /* POLYMORPHIC */
114 }
115 
116 // CHECK-LABEL: @test_vmaxq_x_u16(
117 // CHECK-NEXT:  entry:
118 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
119 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
120 // CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.arm.mve.max.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], i32 1, <8 x i1> [[TMP1]], <8 x i16> undef)
121 // CHECK-NEXT:    ret <8 x i16> [[TMP2]]
122 //
test_vmaxq_x_u16(uint16x8_t a,uint16x8_t b,mve_pred16_t p)123 uint16x8_t test_vmaxq_x_u16(uint16x8_t a, uint16x8_t b, mve_pred16_t p)
124 {
125 #ifdef POLYMORPHIC
126     return vmaxq_x(a, b, p);
127 #else /* POLYMORPHIC */
128     return vmaxq_x_u16(a, b, p);
129 #endif /* POLYMORPHIC */
130 }
131 
132 // CHECK-LABEL: @test_vmaxq_x_s32(
133 // CHECK-NEXT:  entry:
134 // CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
135 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
136 // CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.arm.mve.max.predicated.v4i32.v4i1(<4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], i32 0, <4 x i1> [[TMP1]], <4 x i32> undef)
137 // CHECK-NEXT:    ret <4 x i32> [[TMP2]]
138 //
test_vmaxq_x_s32(int32x4_t a,int32x4_t b,mve_pred16_t p)139 int32x4_t test_vmaxq_x_s32(int32x4_t a, int32x4_t b, mve_pred16_t p)
140 {
141 #ifdef POLYMORPHIC
142     return vmaxq_x(a, b, p);
143 #else /* POLYMORPHIC */
144     return vmaxq_x_s32(a, b, p);
145 #endif /* POLYMORPHIC */
146 }
147