1 // REQUIRES: powerpc-registered-target
2
3 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
4 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
5 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
6 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
7
8 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
9 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
10 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
11 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
12
13 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr10 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
14 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefix=P10
15 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr10 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
16 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefix=P10
17
18 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
19 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
20 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
21 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
22
23 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-ibm-aix -mcpu=pwr10 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
24 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefix=P10
25 // RUN: %clang -Xclang -no-opaque-pointers -S -emit-llvm -target powerpc64-ibm-aix -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
26 // RUN: -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
27
28 #include <smmintrin.h>
29
30 __m128 mn1, mn2;
31 __m128d md1, md2;
32 __m128i mi, m1, m2;
33
34 void __attribute__((noinline))
test_extract()35 test_extract() {
36 _mm_extract_epi8(mi, 0);
37 _mm_extract_epi32(mi, 0);
38 _mm_extract_epi64(mi, 0);
39 _mm_extract_ps((__m128)mi, 0);
40 }
41
42 // CHECK-LABEL: @test_extract
43
44 // CHECK-LABEL: define available_externally signext i32 @_mm_extract_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
45 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 15
46 // CHECK: %[[EXT:[0-9a-zA-Z_.]+]] = extractelement <16 x i8> %{{[0-9a-zA-Z_.]+}}, i32 %[[AND]]
47 // CHECK: zext i8 %[[EXT]] to i32
48
49 // CHECK-LABEL: define available_externally signext i32 @_mm_extract_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
50 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 3
51 // CHECK: extractelement <4 x i32> %{{[0-9a-zA-Z_.]+}}, i32 %[[AND]]
52
53 // CHECK-LABEL: define available_externally signext i32 @_mm_extract_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
54 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 1
55 // CHECK: %[[EXT:[0-9a-zA-Z_.]+]] = extractelement <2 x i64> %{{[0-9a-zA-Z_.]+}}, i32 %[[AND]]
56 // CHECK: trunc i64 %[[EXT]] to i32
57
58 // CHECK-LABEL: define available_externally signext i32 @_mm_extract_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
59 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 3
60 // CHECK: extractelement <4 x i32> %{{[0-9a-zA-Z_.]+}}, i32 %[[AND]]
61
62 void __attribute__((noinline))
test_blend()63 test_blend() {
64 _mm_blend_epi16(m1, m2, 0);
65 _mm_blendv_epi8(m1, m2, mi);
66 _mm_blend_ps(mn1, mn2, 0);
67 _mm_blendv_ps(mn1, mn2, mn1);
68 _mm_blend_pd(md1, md2, 0);
69 _mm_blendv_pd(md1, md2, md1);
70 }
71
72 // CHECK-LABEL: @test_blend
73
74 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
75 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
76 // CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext %[[TRUNC]])
77 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
78 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char vector[16])
79 // CHECK: store <8 x i16> %[[PACK]], <8 x i16>* %{{[0-9a-zA-Z_.]+}}, align 16
80 // BE: %[[REVE:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_reve(unsigned short vector[8])
81 // BE: store <8 x i16> %[[REVE]], <8 x i16>* %{{[0-9a-zA-Z_.]+}}, align 16
82 // CHECK: call <8 x i16> @vec_sel(unsigned short vector[8], unsigned short vector[8], unsigned short vector[8])
83
84 // P10-LABEL: define available_externally <2 x i64> @_mm_blendv_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
85 // P10: call <16 x i8> @vec_blendv(signed char vector[16], signed char vector[16], unsigned char vector[16])(<16 x i8> noundef %{{[0-9a-zA-Z_.]+}}, <16 x i8> noundef %{{[0-9a-zA-Z_.]+}}, <16 x i8> noundef %{{[0-9a-zA-Z_.]+}})
86
87 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blendv_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
88 // CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext 7)
89 // CHECK: call <16 x i8> @vec_sra(unsigned char vector[16], unsigned char vector[16])
90 // CHECK: call <16 x i8> @vec_sel(signed char vector[16], signed char vector[16], unsigned char vector[16])
91
92 void __attribute__((noinline))
test_insert()93 test_insert() {
94 _mm_insert_epi8(m1, 1, 0);
95 _mm_insert_epi32(m1, 1, 0);
96 _mm_insert_epi64(m1, 0xFFFFFFFF1L, 0);
97 }
98
99 // CHECK-LABEL: @test_insert
100
101 // CHECK-LABEL: define available_externally <2 x i64> @_mm_insert_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
102 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
103 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 15
104 // CHECK: insertelement <16 x i8> %{{[0-9a-zA-Z_.]+}}, i8 %[[TRUNC]], i32 %[[AND]]
105
106 // CHECK-LABEL: define available_externally <2 x i64> @_mm_insert_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
107 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 3
108 // CHECK: insertelement <4 x i32> %{{[0-9a-zA-Z_.]+}}, i32 %{{[0-9a-zA-Z_.]+}}, i32 %[[AND]]
109
110 // CHECK-LABEL: define available_externally <2 x i64> @_mm_insert_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i64 noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
111 // CHECK: %[[AND:[0-9a-zA-Z_.]+]] = and i32 %{{[0-9a-zA-Z_.]+}}, 1
112 // CHECK: insertelement <2 x i64> %{{[0-9a-zA-Z_.]+}}, i64 %{{[0-9a-zA-Z_.]+}}, i32 %[[AND:[0-9a-zA-Z_.]+]]
113
114 void __attribute__((noinline))
test_convert()115 test_convert() {
116 _mm_cvtepi16_epi32(m1);
117 _mm_cvtepi16_epi64(m1);
118 _mm_cvtepi32_epi64(m1);
119 _mm_cvtepi8_epi16(m1);
120 _mm_cvtepi8_epi32(m1);
121 _mm_cvtepi8_epi64(m1);
122 _mm_cvtepu16_epi32(m1);
123 _mm_cvtepu16_epi64(m1);
124 _mm_cvtepu32_epi64(m1);
125 _mm_cvtepu8_epi16(m1);
126 _mm_cvtepu8_epi32(m1);
127 _mm_cvtepu8_epi64(m1);
128 }
129
130 // CHECK-LABEL: @test_convert
131
132 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi16_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
133 // CHECK: call <4 x i32> @vec_unpackh(short vector[8])
134
135 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi16_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
136 // CHECK: call <4 x i32> @vec_unpackh(short vector[8])
137 // CHECK: call <2 x i64> @vec_unpackh(int vector[4])
138
139 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi32_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
140 // CHECK: call <2 x i64> @vec_unpackh(int vector[4])
141
142 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi8_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
143 // CHECK: call <8 x i16> @vec_unpackh(signed char vector[16])
144
145 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi8_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
146 // CHECK: call <8 x i16> @vec_unpackh(signed char vector[16])
147 // CHECK: call <4 x i32> @vec_unpackh(short vector[8])
148
149 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepi8_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
150 // CHECK: call <8 x i16> @vec_unpackh(signed char vector[16])
151 // CHECK: call <4 x i32> @vec_unpackh(short vector[8])
152 // CHECK: call <2 x i64> @vec_unpackh(int vector[4])
153
154 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu16_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
155 // LE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef %{{[0-9a-zA-Z_.]+}}, <8 x i16> noundef zeroinitializer)
156 // BE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef zeroinitializer, <8 x i16> noundef %{{[0-9a-zA-Z_.]+}})
157
158 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu16_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
159 // LE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef %{{[0-9a-zA-Z_.]+}}, <8 x i16> noundef zeroinitializer)
160 // LE: call <4 x i32> @vec_mergeh(unsigned int vector[4], unsigned int vector[4])(<4 x i32> noundef %{{[0-9a-zA-Z_.]+}}, <4 x i32> noundef zeroinitializer)
161 // BE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef zeroinitializer, <8 x i16> noundef %{{[0-9a-zA-Z_.]+}})
162 // BE: call <4 x i32> @vec_mergeh(unsigned int vector[4], unsigned int vector[4])(<4 x i32> noundef zeroinitializer, <4 x i32> noundef %{{[0-9a-zA-Z_.]+}})
163
164 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu32_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
165 // LE: call <4 x i32> @vec_mergeh(unsigned int vector[4], unsigned int vector[4])(<4 x i32> noundef %{{[0-9a-zA-Z_.]+}}, <4 x i32> noundef zeroinitializer)
166 // BE: call <4 x i32> @vec_mergeh(unsigned int vector[4], unsigned int vector[4])(<4 x i32> noundef zeroinitializer, <4 x i32> noundef %{{[0-9a-zA-Z_.]+}})
167
168 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu8_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
169 // LE: call <16 x i8> @vec_mergeh(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef %{{[0-9a-zA-Z_.]+}}, <16 x i8> noundef zeroinitializer)
170 // BE: call <16 x i8> @vec_mergeh(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef zeroinitializer, <16 x i8> noundef %{{[0-9a-zA-Z_.]+}})
171
172 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu8_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
173 // LE: call <16 x i8> @vec_mergeh(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef %{{[0-9a-zA-Z_.]+}}, <16 x i8> noundef zeroinitializer)
174 // LE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef %{{[0-9a-zA-Z_.]+}}, <8 x i16> noundef zeroinitializer)
175 // BE: call <16 x i8> @vec_mergeh(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef zeroinitializer, <16 x i8> noundef %{{[0-9a-zA-Z_.]+}})
176 // BE: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])(<8 x i16> noundef zeroinitializer, <8 x i16> noundef %{{[0-9a-zA-Z_.]+}})
177
178 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cvtepu8_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
179 // CHECK: call <16 x i8> @vec_mergeh(unsigned char vector[16], unsigned char vector[16])
180 // CHECK: call <8 x i16> @vec_mergeh(unsigned short vector[8], unsigned short vector[8])
181 // CHECK: call <4 x i32> @vec_mergeh(unsigned int vector[4], unsigned int vector[4])
182
183 void __attribute__((noinline))
test_minmax()184 test_minmax() {
185 _mm_max_epi32(m1, m2);
186 _mm_max_epi8(m1, m2);
187 _mm_max_epu16(m1, m2);
188 _mm_max_epu32(m1, m2);
189 _mm_min_epi32(m1, m2);
190 _mm_min_epi8(m1, m2);
191 _mm_min_epu16(m1, m2);
192 _mm_min_epu32(m1, m2);
193 _mm_minpos_epu16(m1);
194 }
195
196 // CHECK-LABEL: @test_minmax
197
198 // CHECK-LABEL: define available_externally <2 x i64> @_mm_max_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
199 // CHECK: call <4 x i32> @vec_max(int vector[4], int vector[4])
200
201 // CHECK-LABEL: define available_externally <2 x i64> @_mm_max_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
202 // CHECK: call <16 x i8> @vec_max(signed char vector[16], signed char vector[16])
203
204 // CHECK-LABEL: define available_externally <2 x i64> @_mm_max_epu16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
205 // CHECK: call <8 x i16> @vec_max(unsigned short vector[8], unsigned short vector[8])
206
207 // CHECK-LABEL: define available_externally <2 x i64> @_mm_max_epu32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
208 // CHECK: call <4 x i32> @vec_max(unsigned int vector[4], unsigned int vector[4])
209
210 // CHECK-LABEL: define available_externally <2 x i64> @_mm_min_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
211 // CHECK: call <4 x i32> @vec_min(int vector[4], int vector[4])
212
213 // CHECK-LABEL: define available_externally <2 x i64> @_mm_min_epi8(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
214 // CHECK: call <16 x i8> @vec_min(signed char vector[16], signed char vector[16])
215
216 // CHECK-LABEL: define available_externally <2 x i64> @_mm_min_epu16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
217 // CHECK: call <8 x i16> @vec_min(unsigned short vector[8], unsigned short vector[8])
218
219 // CHECK-LABEL: define available_externally <2 x i64> @_mm_min_epu32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
220 // CHECK: call <4 x i32> @vec_min(unsigned int vector[4], unsigned int vector[4])
221
222 // CHECK-LABEL: define available_externally <2 x i64> @_mm_minpos_epu16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
223 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 16 %{{[0-9a-zA-Z_.]+}}, i8 0, i64 16, i1 false)
224 // CHECK: extractelement <8 x i16> %{{[0-9a-zA-Z_.]+}}, i16 %{{[0-9a-zA-Z_.]+}}
225 // CHECK: %[[VEXT:[0-9a-zA-Z_.]+]] = extractelement <8 x i16> %{{[0-9a-zA-Z_.]+}}, i64 %{{[0-9a-zA-Z_.]+}}
226 // CHECK: zext i16 %[[VEXT]] to i32
227 // CHECK: zext i16 %{{[0-9a-zA-Z_.]+}} to i32
228 // CHECK: extractelement <8 x i16> %{{[0-9a-zA-Z_.]+}}, i64 %{{[0-9a-zA-Z_.]+}}
229 // CHECK: add i64 %{{[0-9a-zA-Z_.]+}}, 1
230
231 void __attribute__((noinline))
test_round()232 test_round() {
233 _mm_round_ps(mn1, 0);
234 _mm_round_ss(mn1, mn2, 0);
235 _mm_round_pd(mn1, 0);
236 _mm_round_sd(mn1, mn2, 0);
237 }
238
239 // CHECK-LABEL: @test_round
240
241 // CHECK-LABEL: define available_externally <4 x float> @_mm_round_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
242 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffs to i32 ()*)()
243 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mtfsf to i32 (i32, double)*)(i32 noundef signext 3, double noundef %{{[0-9a-zA-Z_.]+}})
244 // CHECK: %{{[0-9a-zA-Z_.]+}} = call <4 x float> asm "", "=^wa,0"
245 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffsl to i32 ()*)()
246 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_set_fpscr_rn to i32 (i32)*)(i32 noundef signext 0)
247 // CHECK: %{{[0-9a-zA-Z_.]+}} = call <4 x float> asm "", "=^wa,0"
248 // CHECK: call <4 x float> @vec_rint(float vector[4])
249 // CHECK: call void asm sideeffect "", "^wa"
250 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_set_fpscr_rn to i32 (i64)*)(i64 noundef %{{[0-9a-zA-Z_.]+}})
251 // CHECK: call <4 x float> @vec_floor(float vector[4])
252 // CHECK: call <4 x float> @vec_ceil(float vector[4])
253 // CHECK: call <4 x float> @vec_trunc(float vector[4])
254 // CHECK: call <4 x float> @vec_rint(float vector[4])
255 // CHECK: call void asm sideeffect "", "^wa"
256 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffsl to i32 ()*)()
257 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mtfsf to i32 (i32, double)*)(i32 noundef signext 3, double noundef %{{[0-9a-zA-Z_.]+}})
258
259 // CHECK-LABEL: define available_externally <4 x float> @_mm_round_ss(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, <4 x float> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
260 // CHECK: call <4 x float> @_mm_round_ps(<4 x float> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
261 // CHECK: extractelement <4 x float> %{{[0-9a-zA-Z_.]+}}, i32 0
262
263 // CHECK-LABEL: define available_externally <2 x double> @_mm_round_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
264 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffs to i32 ()*)()
265 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mtfsf to i32 (i32, double)*)(i32 noundef signext 3, double noundef %{{[0-9a-zA-Z_.]+}})
266 // CHECK: %{{[0-9a-zA-Z_.]+}} = call <2 x double> asm "", "=^wa,0"
267 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffsl to i32 ()*)()
268 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_set_fpscr_rn to i32 (i32)*)(i32 noundef signext 0)
269 // CHECK: %{{[0-9a-zA-Z_.]+}} = call <2 x double> asm "", "=^wa,0"
270 // CHECK: call <2 x double> @vec_rint(double vector[2])
271 // CHECK: call void asm sideeffect "", "^wa"
272 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_set_fpscr_rn to i32 (i64)*)(i64 noundef %{{[0-9a-zA-Z_.]+}})
273 // CHECK: call <2 x double> @vec_floor(double vector[2])
274 // CHECK: call <2 x double> @vec_ceil(double vector[2])
275 // CHECK: call <2 x double> @vec_trunc(double vector[2])
276 // CHECK: call <2 x double> @vec_rint(double vector[2])
277 // CHECK: call void asm sideeffect "", "^wa"
278 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mffsl to i32 ()*)()
279 // CHECK: call signext i32 bitcast (i32 (...)* @__builtin_mtfsf to i32 (i32, double)*)(i32 noundef signext 3, double noundef %{{[0-9a-zA-Z_.]+}})
280
281 // CHECK-LABEL: define available_externally <2 x double> @_mm_round_sd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, <2 x double> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
282 // CHECK: call <2 x double> @_mm_round_pd(<2 x double> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
283 // CHECK: extractelement <2 x double> %{{[0-9a-zA-Z_.]+}}, i32 0
284 // CHECK: extractelement <2 x double> %{{[0-9a-zA-Z_.]+}}, i32 1
285
286 void __attribute__((noinline))
test_testing()287 test_testing() {
288 _mm_testc_si128(m1, m2);
289 _mm_testnzc_si128(m1, m2);
290 _mm_testz_si128(m1, m2);
291 }
292
293 // CHECK-LABEL: @test_testing
294
295 // CHECK-LABEL: define available_externally signext i32 @_mm_testc_si128(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
296 // CHECK: call <16 x i8> @vec_nor(unsigned char vector[16], unsigned char vector[16])
297 // CHECK: call <16 x i8> @vec_and(unsigned char vector[16], unsigned char vector[16])
298 // CHECK: call signext i32 @vec_all_eq(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef %call1, <16 x i8> noundef zeroinitializer)
299
300 // CHECK-LABEL: define available_externally signext i32 @_mm_testnzc_si128(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
301 // CHECK: call signext i32 @_mm_testz_si128(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
302 // CHECK: call signext i32 @_mm_testc_si128(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
303 // CHECK: zext i1 %{{[0-9a-zA-Z_.]+}} to i32
304
305 // CHECK-LABEL: define available_externally signext i32 @_mm_testz_si128(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
306 // CHECK: call <16 x i8> @vec_and(unsigned char vector[16], unsigned char vector[16])
307 // CHECK: call signext i32 @vec_all_eq(unsigned char vector[16], unsigned char vector[16])(<16 x i8> noundef %call, <16 x i8> noundef zeroinitializer)
308
309 void __attribute__((noinline))
test_compare()310 test_compare() {
311 _mm_cmpeq_epi64(m1, m2);
312 _mm_cmpgt_epi64(m1, m2);
313 }
314
315 // CHECK-LABEL: @test_compare
316
317 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cmpeq_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
318 // CHECK: call <2 x i64> @vec_cmpeq(long long vector[2], long long vector[2])
319
320 // CHECK-LABEL: define available_externally <2 x i64> @_mm_cmpgt_epi64(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
321 // CHECK: call <2 x i64> @vec_cmpgt(long long vector[2], long long vector[2])
322
323 void __attribute__((noinline))
test_mul()324 test_mul() {
325 _mm_mul_epi32(m1, m2);
326 _mm_mullo_epi32(m1, m2);
327 }
328
329 // CHECK-LABEL: @test_mul
330
331 // CHECK-LABEL: define available_externally <2 x i64> @_mm_mul_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
332 // CHECK: %call = call <2 x i64> @vec_mule(int vector[4], int vector[4])
333
334 // CHECK-LABEL: define available_externally <2 x i64> @_mm_mullo_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
335 // CHECK: %call = call <4 x i32> @vec_mul(unsigned int vector[4], unsigned int vector[4])
336
337 void __attribute__((noinline))
test_packus()338 test_packus() {
339 _mm_packus_epi32(m1, m2);
340 }
341
342 // CHECK-LABEL: @test_packus
343
344 // CHECK-LABEL: define available_externally <2 x i64> @_mm_packus_epi32(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
345 // CHECK: call <8 x i16> @vec_packsu(int vector[4], int vector[4])(<4 x i32> noundef %1, <4 x i32> noundef %3)
346
347 // To test smmintrin.h includes tmmintrin.h
348
349 void __attribute__((noinline))
test_abs_ssse3()350 test_abs_ssse3() {
351 _mm_abs_epi16(m1);
352 }
353
354 // CHECK-LABEL: @test_abs_ssse3
355
356 // CHECK-LABEL: define available_externally <2 x i64> @_mm_abs_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}})
357