Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/xop-builtins.c

raw
1 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-cir -o %t.cir
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-cir -o %t.cir
4 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
5
6 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fclangir -emit-llvm -o %t.ll
7 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
8 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -fclangir -emit-llvm -o %t.ll
9 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
10
11 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-cir -o %t.cir
12 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
13 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-cir -o %t.cir
14 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
15
16 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fclangir -emit-llvm -o %t.ll
17 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
18 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -fclangir -emit-llvm -o %t.ll
19 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
20
21 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG
22 // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG
23 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG
24 // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +xop -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG
25
26 #include <x86intrin.h>
27
28 // This test mimics clang/test/CodeGen/X86/xop-builtins.c, which eventually
29 // CIR shall be able to support fully.
30
31 __m128i test_mm_roti_epi8(__m128i a) {
32 // CIR-LABEL: test_mm_roti_epi8
33 // CIR: cir.vec.splat %{{.*}} : !{{[us]}}8i, !cir.vector<16 x !{{[us]}}8i>
34 // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<16 x !{{[su]}}8i>, !cir.vector<16 x !{{[su]}}8i>, !cir.vector<16 x !{{[su]}}8i>) -> !cir.vector<16 x !{{[su]}}8i>
35
36 // LLVM-LABEL: test_mm_roti_epi8
37 // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <16 x i8>
38 // LLVM: call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %[[CASTED_VAR]], <16 x i8> %[[CASTED_VAR]], <16 x i8> splat (i8 1))
39
40 // OGCG-LABEL: test_mm_roti_epi8
41 // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <16 x i8>
42 // OGCG: call <16 x i8> @llvm.fshl.v16i8(<16 x i8> %[[CASTED_VAR]], <16 x i8> %[[CASTED_VAR]], <16 x i8> splat (i8 1))
43 return _mm_roti_epi8(a, 1);
44 }
45
46 __m128i test_mm_roti_epi16(__m128i a) {
47 // CIR-LABEL: test_mm_roti_epi16
48 // CIR: cir.vec.splat %{{.*}} : !{{[us]}}16i, !cir.vector<8 x !u16i>
49 // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<8 x !{{[su]}}16i>, !cir.vector<8 x !{{[su]}}16i>, !cir.vector<8 x !u16i>) -> !cir.vector<8 x !{{[su]}}16i>
50
51 // LLVM-LABEL: test_mm_roti_epi16
52 // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <8 x i16>
53 // LLVM: call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %[[CASTED_VAR]], <8 x i16> %[[CASTED_VAR]], <8 x i16> splat (i16 50))
54
55 // OGCG-LABEL: test_mm_roti_epi16
56 // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <8 x i16>
57 // OGCG: call <8 x i16> @llvm.fshl.v8i16(<8 x i16> %[[CASTED_VAR]], <8 x i16> %[[CASTED_VAR]], <8 x i16> splat (i16 50))
58 return _mm_roti_epi16(a, 50);
59 }
60
61 __m128i test_mm_roti_epi32(__m128i a) {
62 // CIR-LABEL: test_mm_roti_epi32
63 // CIR: cir.vec.splat %{{.*}} : !{{[us]}}32i, !cir.vector<4 x !u32i>
64 // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<4 x !{{[su]}}32i>, !cir.vector<4 x !{{[su]}}32i>, !cir.vector<4 x !u32i>) -> !cir.vector<4 x !{{[su]}}32i>
65
66 // LLVM-LABEL: test_mm_roti_epi32
67 // LLVM: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
68 // LLVM: call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 226))
69
70 // OGCG-LABEL: test_mm_roti_epi32
71 // OGCG: %[[CASTED_VAR:.*]] = bitcast <2 x i64> %{{.*}} to <4 x i32>
72 // OGCG: call <4 x i32> @llvm.fshl.v4i32(<4 x i32> %[[CASTED_VAR]], <4 x i32> %[[CASTED_VAR]], <4 x i32> splat (i32 226))
73 return _mm_roti_epi32(a, -30);
74 }
75
76 __m128i test_mm_roti_epi64(__m128i a) {
77 // CIR-LABEL: test_mm_roti_epi64
78 // CIR: cir.vec.splat %{{.*}} : !u64i, !cir.vector<2 x !u64i>
79 // CIR: cir.call_llvm_intrinsic "fshl" %{{.*}} : (!cir.vector<2 x !{{[su]}}64i>, !cir.vector<2 x !{{[su]}}64i>, !cir.vector<2 x !u64i>) -> !cir.vector<2 x !s64i>
80
81 // LLVM-LABEL: test_mm_roti_epi64
82 // LLVM: %[[VAR:.*]] = load <2 x i64>, ptr %{{.*}}, align 16
83 // LLVM: call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %[[VAR]], <2 x i64> %[[VAR]], <2 x i64> splat (i64 100))
84
85 // OGCG-LABEL: test_mm_roti_epi64
86 // OGCG: %[[VAR:.*]] = load <2 x i64>, ptr %{{.*}}, align 16
87 // OGCG: call <2 x i64> @llvm.fshl.v2i64(<2 x i64> %[[VAR]], <2 x i64> %[[VAR]], <2 x i64> splat (i64 100))
88 return _mm_roti_epi64(a, 100);
89 }
90
91 __m128i test_mm_com_epu8(__m128i a, __m128i b) {
92 // CIR-LABEL: test_mm_com_epu8
93 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !u8i>, !cir.vector<16 x !s8i>
94 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<16 x !s8i> -> !cir.vector<2 x !s64i>
95
96 // LLVM-LABEL: test_mm_com_epu8
97 // LLVM: %[[CMP:.*]] = icmp ult <16 x i8> %{{.*}}, %{{.*}}
98 // LLVM: %[[RES:.*]] = sext <16 x i1> %[[CMP]] to <16 x i8>
99 // LLVM: %{{.*}} = bitcast <16 x i8> %[[RES]] to <2 x i64>
100
101 // OGCG-LABEL: test_mm_com_epu8
102 // OGCG: %[[CMP:.*]] = icmp ult <16 x i8> %{{.*}}, %{{.*}}
103 // OGCG: %[[RES:.*]] = sext <16 x i1> %[[CMP]] to <16 x i8>
104 // OGCG: %{{.*}} = bitcast <16 x i8> %[[RES]] to <2 x i64>
105 return _mm_com_epu8(a, b, 0);
106 }
107
108 __m128i test_mm_com_epu16(__m128i a, __m128i b) {
109 // CIR-LABEL: test_mm_com_epu16
110 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s16i> -> !cir.vector<8 x !u16i>
111 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<8 x !s16i> -> !cir.vector<8 x !u16i>
112 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %[[VAL1]], %[[VAL2]]) : !cir.vector<8 x !u16i>, !cir.vector<8 x !s16i>
113 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<8 x !s16i> -> !cir.vector<2 x !s64i>
114
115 // LLVM-LABEL: test_mm_com_epu16
116 // LLVM: %[[CMP:.*]] = icmp ult <8 x i16> %{{.*}}, %{{.*}}
117 // LLVM: %[[RES:.*]] = sext <8 x i1> %[[CMP]] to <8 x i16>
118 // LLVM: %{{.*}} = bitcast <8 x i16> %[[RES]] to <2 x i64>
119
120 // OGCG-LABEL: test_mm_com_epu16
121 // OGCG: %[[CMP:.*]] = icmp ult <8 x i16> %{{.*}}, %{{.*}}
122 // OGCG: %[[RES:.*]] = sext <8 x i1> %[[CMP]] to <8 x i16>
123 // OGCG: %{{.*}} = bitcast <8 x i16> %[[RES]] to <2 x i64>
124 return _mm_com_epu16(a, b, 0);
125 }
126
127 __m128i test_mm_com_epu32(__m128i a, __m128i b) {
128 // CIR-LABEL: test_mm_com_epu32
129 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<4 x !s32i> -> !cir.vector<4 x !u32i>
130 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<4 x !s32i> -> !cir.vector<4 x !u32i>
131 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %[[VAL1]], %[[VAL2]]) : !cir.vector<4 x !u32i>, !cir.vector<4 x !s32i>
132 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
133
134 // LLVM-LABEL: test_mm_com_epu32
135 // LLVM: %[[CMP:.*]] = icmp ult <4 x i32> %{{.*}}, %{{.*}}
136 // LLVM: %[[RES:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
137 // LLVM: %{{.*}} = bitcast <4 x i32> %[[RES]] to <2 x i64>
138
139 // OGCG-LABEL: test_mm_com_epu32
140 // OGCG: %[[CMP:.*]] = icmp ult <4 x i32> %{{.*}}, %{{.*}}
141 // OGCG: %[[RES:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
142 // OGCG: %{{.*}} = bitcast <4 x i32> %[[RES]] to <2 x i64>
143 return _mm_com_epu32(a, b, 0);
144 }
145
146 __m128i test_mm_com_epu64(__m128i a, __m128i b) {
147 // CIR-LABEL: test_mm_com_epu64
148 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
149 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
150 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
151
152 // LLVM-LABEL: test_mm_com_epu64
153 // LLVM: %[[CMP:.*]] = icmp ult <2 x i64> %{{.*}}, %{{.*}}
154 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
155
156 // OGCG-LABEL: test_mm_com_epu64
157 // OGCG: %[[CMP:.*]] = icmp ult <2 x i64> %{{.*}}, %{{.*}}
158 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
159 a = _mm_com_epu64(a, b, 0);
160
161 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
162 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
163 // CIR: %[[CMP:.*]] = cir.vec.cmp(le, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
164
165 // LLVM: %[[CMP:.*]] = icmp ule <2 x i64> %{{.*}}, %{{.*}}
166 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
167
168 // OGCG: %[[CMP:.*]] = icmp ule <2 x i64> %{{.*}}, %{{.*}}
169 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
170 a = _mm_com_epu64(a, b, 1);
171
172 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
173 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
174 // CIR: %[[CMP:.*]] = cir.vec.cmp(gt, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
175
176 // LLVM: %[[CMP:.*]] = icmp ugt <2 x i64> %{{.*}}, %{{.*}}
177 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
178
179 // OGCG: %[[CMP:.*]] = icmp ugt <2 x i64> %{{.*}}, %{{.*}}
180 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
181 a = _mm_com_epu64(a, b, 2);
182
183 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
184 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
185 // CIR: %[[CMP:.*]] = cir.vec.cmp(ge, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
186
187 // LLVM: %[[CMP:.*]] = icmp uge <2 x i64> %{{.*}}, %{{.*}}
188 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
189
190 // OGCG: %[[CMP:.*]] = icmp uge <2 x i64> %{{.*}}, %{{.*}}
191 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
192 a = _mm_com_epu64(a, b, 3);
193
194 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
195 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
196 // CIR: %[[CMP:.*]] = cir.vec.cmp(eq, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
197
198 // LLVM: %[[CMP:.*]] = icmp eq <2 x i64> %{{.*}}, %{{.*}}
199 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
200
201 // OGCG: %[[CMP:.*]] = icmp eq <2 x i64> %{{.*}}, %{{.*}}
202 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
203 a = _mm_com_epu64(a, b, 4);
204
205 // CIR: %[[VAL1:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
206 // CIR: %[[VAL2:.*]] = cir.cast bitcast %{{.*}} : !cir.vector<2 x !s64i> -> !cir.vector<2 x !u64i>
207 // CIR: %[[CMP:.*]] = cir.vec.cmp(ne, %[[VAL1]], %[[VAL2]]) : !cir.vector<2 x !u64i>, !cir.vector<2 x !s64i>
208
209 // LLVM: %[[CMP:.*]] = icmp ne <2 x i64> %{{.*}}, %{{.*}}
210 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
211
212 // OGCG: %[[CMP:.*]] = icmp ne <2 x i64> %{{.*}}, %{{.*}}
213 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
214 return _mm_com_epu64(a, b, 5);
215 }
216
217 __m128i test_mm_com_epi8(__m128i a, __m128i b) {
218 // CIR-LABEL: test_mm_com_epi8
219 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<16 x !s8i>, !cir.vector<16 x !s8i>
220 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<16 x !s8i> -> !cir.vector<2 x !s64i>
221
222 // LLVM-LABEL: test_mm_com_epi8
223 // LLVM: %[[CMP:.*]] = icmp slt <16 x i8> %{{.*}}, %{{.*}}
224 // LLVM: %[[RES:.*]] = sext <16 x i1> %[[CMP]] to <16 x i8>
225 // LLVM: %{{.*}} = bitcast <16 x i8> %[[RES]] to <2 x i64>
226
227 // OGCG-LABEL: test_mm_com_epi8
228 // OGCG: %[[CMP:.*]] = icmp slt <16 x i8> %{{.*}}, %{{.*}}
229 // OGCG: %[[RES:.*]] = sext <16 x i1> %[[CMP]] to <16 x i8>
230 // OGCG: %{{.*}} = bitcast <16 x i8> %[[RES]] to <2 x i64>
231 return _mm_com_epi8(a, b, 0);
232 }
233
234 __m128i test_mm_com_epi16(__m128i a, __m128i b) {
235 // CIR-LABEL: test_mm_com_epi16
236 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<8 x !s16i>, !cir.vector<8 x !s16i>
237 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<8 x !s16i> -> !cir.vector<2 x !s64i>
238
239 // LLVM-LABEL: test_mm_com_epi16
240 // LLVM: %[[CMP:.*]] = icmp slt <8 x i16> %{{.*}}, %{{.*}}
241 // LLVM: %[[RES:.*]] = sext <8 x i1> %[[CMP]] to <8 x i16>
242 // LLVM: %{{.*}} = bitcast <8 x i16> %[[RES]] to <2 x i64>
243
244 // OGCG-LABEL: test_mm_com_epi16
245 // OGCG: %[[CMP:.*]] = icmp slt <8 x i16> %{{.*}}, %{{.*}}
246 // OGCG: %[[RES:.*]] = sext <8 x i1> %[[CMP]] to <8 x i16>
247 // OGCG: %{{.*}} = bitcast <8 x i16> %[[RES]] to <2 x i64>
248 return _mm_com_epi16(a, b, 0);
249 }
250
251 __m128i test_mm_com_epi32(__m128i a, __m128i b) {
252 // CIR-LABEL: test_mm_com_epi32
253 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
254 // CIR: %[[RES:.*]] = cir.cast bitcast %[[CMP]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
255
256 // LLVM-LABEL: test_mm_com_epi32
257 // LLVM: %[[CMP:.*]] = icmp slt <4 x i32> %{{.*}}, %{{.*}}
258 // LLVM: %[[RES:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
259 // LLVM: %{{.*}} = bitcast <4 x i32> %[[RES]] to <2 x i64>
260
261 // OGCG-LABEL: test_mm_com_epi32
262 // OGCG: %[[CMP:.*]] = icmp slt <4 x i32> %{{.*}}, %{{.*}}
263 // OGCG: %[[RES:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
264 // OGCG: %{{.*}} = bitcast <4 x i32> %[[RES]] to <2 x i64>
265 return _mm_com_epi32(a, b, 0);
266 }
267
268 __m128i test_mm_com_epi64(__m128i a, __m128i b) {
269 // CIR-LABEL: test_mm_com_epi64
270 // CIR: %[[CMP:.*]] = cir.vec.cmp(lt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
271
272 // LLVM-LABEL: test_mm_com_epi64
273 // LLVM: %[[CMP:.*]] = icmp slt <2 x i64> %{{.*}}, %{{.*}}
274 // LLVM: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
275
276 // OGCG-LABEL: test_mm_com_epi64
277 // OGCG: %[[CMP:.*]] = icmp slt <2 x i64> %{{.*}}, %{{.*}}
278 // OGCG: %[[RES:.*]] = sext <2 x i1> %[[CMP]] to <2 x i64>
279 a = _mm_com_epi64(a, b, 0);
280
281 // CIR: %[[CMP1:.*]] = cir.vec.cmp(le, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
282
283 // LLVM: %[[CMP1:.*]] = icmp sle <2 x i64> %{{.*}}, %{{.*}}
284 // LLVM: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
285
286 // OGCG: %[[CMP1:.*]] = icmp sle <2 x i64> %{{.*}}, %{{.*}}
287 // OGCG: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
288 a = _mm_com_epi64(a, b, 1);
289
290 // CIR: %[[CMP1:.*]] = cir.vec.cmp(gt, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
291
292 // LLVM: %[[CMP1:.*]] = icmp sgt <2 x i64> %{{.*}}, %{{.*}}
293 // LLVM: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
294
295 // OGCG: %[[CMP1:.*]] = icmp sgt <2 x i64> %{{.*}}, %{{.*}}
296 // OGCG: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
297 a = _mm_com_epi64(a, b, 2);
298
299 // CIR: %[[CMP1:.*]] = cir.vec.cmp(ge, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
300
301 // LLVM: %[[CMP1:.*]] = icmp sge <2 x i64> %{{.*}}, %{{.*}}
302 // LLVM: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
303
304 // OGCG: %[[CMP1:.*]] = icmp sge <2 x i64> %{{.*}}, %{{.*}}
305 // OGCG: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
306 a = _mm_com_epi64(a, b, 3);
307
308 // CIR: %[[CMP1:.*]] = cir.vec.cmp(eq, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
309
310 // LLVM: %[[CMP1:.*]] = icmp eq <2 x i64> %{{.*}}, %{{.*}}
311 // LLVM: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
312
313 // OGCG: %[[CMP1:.*]] = icmp eq <2 x i64> %{{.*}}, %{{.*}}
314 // OGCG: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
315 a = _mm_com_epi64(a, b, 4);
316
317 // CIR: %[[CMP1:.*]] = cir.vec.cmp(ne, %{{.*}}, %{{.*}}) : !cir.vector<2 x !s64i>, !cir.vector<2 x !s64i>
318
319 // LLVM: %[[CMP1:.*]] = icmp ne <2 x i64> %{{.*}}, %{{.*}}
320 // LLVM: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
321
322 // OGCG: %[[CMP1:.*]] = icmp ne <2 x i64> %{{.*}}, %{{.*}}
323 // OGCG: %[[RES1:.*]] = sext <2 x i1> %[[CMP1]] to <2 x i64>
324 return _mm_com_epi64(a, b, 5);
325 }
326
327 __m128i test_mm_com_epi32_false(__m128i a, __m128i b) {
328 // CIR-LABEL: test_mm_com_epi32_false
329 // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<4 x !s32i>
330 // CIR: %{{.*}} = cir.cast bitcast %[[ZERO]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
331
332 // LLVM-LABEL: test_mm_com_epi32_false
333 // LLVM: store <2 x i64> zeroinitializer, ptr %[[A:.*]], align 16
334 // LLVM: %[[ZERO:.*]] = load <2 x i64>, ptr %[[A]], align 16
335 // LLVM: ret <2 x i64> %[[ZERO]]
336
337 // OGCG-LABEL: test_mm_com_epi32_false
338 // OGCG: ret <2 x i64> zeroinitializer
339 return _mm_com_epi32(a, b, 6);
340 }
341
342 __m128i test_mm_com_epu32_false(__m128i a, __m128i b) {
343 // CIR-LABEL: test_mm_com_epu32_false
344 // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !cir.vector<4 x !s32i>
345 // CIR: %{{.*}} = cir.cast bitcast %[[ZERO]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
346
347 // LLVM-LABEL: test_mm_com_epu32_false
348 // LLVM: store <2 x i64> zeroinitializer, ptr %[[A:.*]], align 16
349 // LLVM: %[[ZERO:.*]] = load <2 x i64>, ptr %[[A]], align 16
350 // LLVM: ret <2 x i64> %[[ZERO]]
351
352 // OGCG-LABEL: test_mm_com_epu32_false
353 // OGCG: ret <2 x i64> zeroinitializer
354 return _mm_com_epu32(a, b, 6);
355 }
356
357 __m128i test_mm_com_epi32_true(__m128i a, __m128i b) {
358 // CIR-LABEL: test_mm_com_epi32_true
359 // CIR: %[[VAL:.*]] = cir.const #cir.int<-1> : !s32i
360 // CIR: %[[SPLAT:.*]] = cir.vec.splat %[[VAL]] : !s32i, !cir.vector<4 x !s32i>
361 // CIR: %{{.*}} = cir.cast bitcast %[[SPLAT]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
362
363 // LLVM-LABEL: test_mm_com_epi32_true
364 // LLVM: store <2 x i64> splat (i64 -1), ptr %[[VAL:.*]], align 16
365 // LLVM: %[[SPLAT:.*]] = load <2 x i64>, ptr %[[VAL]], align 16
366 // LLVM: ret <2 x i64> %[[SPLAT]]
367
368 // OGCG-LABEL: test_mm_com_epi32_true
369 // OGCG: ret <2 x i64> splat (i64 -1)
370 return _mm_com_epi32(a, b, 7);
371 }
372
373 __m128i test_mm_com_epu32_true(__m128i a, __m128i b) {
374 // CIR-LABEL: test_mm_com_epu32_true
375 // CIR: %[[VAL:.*]] = cir.const #cir.int<-1> : !s32i
376 // CIR: %[[SPLAT:.*]] = cir.vec.splat %[[VAL]] : !s32i, !cir.vector<4 x !s32i>
377 // CIR: %{{.*}} = cir.cast bitcast %[[SPLAT]] : !cir.vector<4 x !s32i> -> !cir.vector<2 x !s64i>
378
379 // LLVM-LABEL: test_mm_com_epu32_true
380 // LLVM: store <2 x i64> splat (i64 -1), ptr %[[VAL:.*]], align 16
381 // LLVM: %[[SPLAT:.*]] = load <2 x i64>, ptr %[[VAL]], align 16
382 // LLVM: ret <2 x i64> %[[SPLAT]]
383
384 // OGCG-LABEL: test_mm_com_epu32_true
385 // OGCG: ret <2 x i64> splat (i64 -1)
386 return _mm_com_epu32(a, b, 7);
387 }