1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s --check-prefixes=AVX,AVX512,AVX512F
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512dq | FileCheck %s --check-prefixes=AVX,AVX512,AVX512DQ
6 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=X86
8 declare float @llvm.maximum.f32(float, float)
9 declare double @llvm.maximum.f64(double, double)
10 declare float @llvm.minimum.f32(float, float)
11 declare double @llvm.minimum.f64(double, double)
12 declare <2 x double> @llvm.minimum.v2f64(<2 x double>, <2 x double>)
13 declare <4 x float> @llvm.maximum.v4f32(<4 x float>, <4 x float>)
19 define float @test_fmaximum(float %x, float %y) nounwind {
20 ; SSE2-LABEL: test_fmaximum:
22 ; SSE2-NEXT: movdqa %xmm0, %xmm2
23 ; SSE2-NEXT: movd %xmm0, %eax
24 ; SSE2-NEXT: testl %eax, %eax
25 ; SSE2-NEXT: movdqa %xmm0, %xmm3
26 ; SSE2-NEXT: js .LBB0_2
28 ; SSE2-NEXT: movdqa %xmm1, %xmm3
30 ; SSE2-NEXT: movdqa %xmm3, %xmm0
31 ; SSE2-NEXT: cmpunordss %xmm3, %xmm0
32 ; SSE2-NEXT: movaps %xmm0, %xmm4
33 ; SSE2-NEXT: andps %xmm3, %xmm4
34 ; SSE2-NEXT: js .LBB0_4
36 ; SSE2-NEXT: movdqa %xmm2, %xmm1
38 ; SSE2-NEXT: maxss %xmm1, %xmm3
39 ; SSE2-NEXT: andnps %xmm3, %xmm0
40 ; SSE2-NEXT: orps %xmm4, %xmm0
43 ; AVX1-LABEL: test_fmaximum:
45 ; AVX1-NEXT: vmovd %xmm0, %eax
46 ; AVX1-NEXT: testl %eax, %eax
47 ; AVX1-NEXT: js .LBB0_1
49 ; AVX1-NEXT: vmovdqa %xmm0, %xmm2
50 ; AVX1-NEXT: jmp .LBB0_3
52 ; AVX1-NEXT: vmovdqa %xmm1, %xmm2
53 ; AVX1-NEXT: vmovdqa %xmm0, %xmm1
55 ; AVX1-NEXT: vmaxss %xmm2, %xmm1, %xmm0
56 ; AVX1-NEXT: vcmpunordss %xmm1, %xmm1, %xmm2
57 ; AVX1-NEXT: vblendvps %xmm2, %xmm1, %xmm0, %xmm0
60 ; AVX512-LABEL: test_fmaximum:
62 ; AVX512-NEXT: vmovd %xmm0, %eax
63 ; AVX512-NEXT: testl %eax, %eax
64 ; AVX512-NEXT: sets %al
65 ; AVX512-NEXT: kmovw %eax, %k1
66 ; AVX512-NEXT: vmovdqa %xmm0, %xmm2
67 ; AVX512-NEXT: vmovss %xmm1, %xmm2, %xmm2 {%k1}
68 ; AVX512-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
69 ; AVX512-NEXT: vmaxss %xmm2, %xmm1, %xmm0
70 ; AVX512-NEXT: vcmpunordss %xmm1, %xmm1, %k1
71 ; AVX512-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
74 ; X86-LABEL: test_fmaximum:
76 ; X86-NEXT: pushl %eax
77 ; X86-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
78 ; X86-NEXT: vmovd {{.*#+}} xmm2 = mem[0],zero,zero,zero
79 ; X86-NEXT: vmovd %xmm2, %eax
80 ; X86-NEXT: testl %eax, %eax
81 ; X86-NEXT: js .LBB0_1
83 ; X86-NEXT: vmovdqa %xmm2, %xmm1
84 ; X86-NEXT: jmp .LBB0_3
86 ; X86-NEXT: vmovdqa %xmm0, %xmm1
87 ; X86-NEXT: vmovdqa %xmm2, %xmm0
89 ; X86-NEXT: vmaxss %xmm1, %xmm0, %xmm1
90 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
91 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
92 ; X86-NEXT: vmovss %xmm0, (%esp)
93 ; X86-NEXT: flds (%esp)
96 %1 = tail call float @llvm.maximum.f32(float %x, float %y)
100 define <4 x float> @test_fmaximum_scalarize(<4 x float> %x, <4 x float> %y) "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {
101 ; SSE2-LABEL: test_fmaximum_scalarize:
103 ; SSE2-NEXT: maxps %xmm1, %xmm0
106 ; AVX-LABEL: test_fmaximum_scalarize:
108 ; AVX-NEXT: vmaxps %xmm1, %xmm0, %xmm0
111 ; X86-LABEL: test_fmaximum_scalarize:
113 ; X86-NEXT: vmaxps %xmm1, %xmm0, %xmm0
115 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> %y)
119 define float @test_fmaximum_nan0(float %x, float %y) {
120 ; SSE2-LABEL: test_fmaximum_nan0:
122 ; SSE2-NEXT: movss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
125 ; AVX-LABEL: test_fmaximum_nan0:
127 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
130 ; X86-LABEL: test_fmaximum_nan0:
132 ; X86-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}
134 %1 = tail call float @llvm.maximum.f32(float 0x7fff000000000000, float %y)
138 define float @test_fmaximum_nan1(float %x, float %y) {
139 ; SSE2-LABEL: test_fmaximum_nan1:
141 ; SSE2-NEXT: movss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
144 ; AVX-LABEL: test_fmaximum_nan1:
146 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
149 ; X86-LABEL: test_fmaximum_nan1:
151 ; X86-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}
153 %1 = tail call float @llvm.maximum.f32(float %x, float 0x7fff000000000000)
157 define float @test_fmaximum_nnan(float %x, float %y) nounwind {
158 ; SSE2-LABEL: test_fmaximum_nnan:
160 ; SSE2-NEXT: movaps %xmm0, %xmm2
161 ; SSE2-NEXT: addss %xmm1, %xmm2
162 ; SSE2-NEXT: subss %xmm1, %xmm0
163 ; SSE2-NEXT: movd %xmm2, %eax
164 ; SSE2-NEXT: testl %eax, %eax
165 ; SSE2-NEXT: js .LBB4_1
166 ; SSE2-NEXT: # %bb.2:
167 ; SSE2-NEXT: maxss %xmm2, %xmm0
169 ; SSE2-NEXT: .LBB4_1:
170 ; SSE2-NEXT: movaps %xmm0, %xmm1
171 ; SSE2-NEXT: movaps %xmm2, %xmm0
172 ; SSE2-NEXT: maxss %xmm1, %xmm0
175 ; AVX1-LABEL: test_fmaximum_nnan:
177 ; AVX1-NEXT: vaddss %xmm1, %xmm0, %xmm2
178 ; AVX1-NEXT: vsubss %xmm1, %xmm0, %xmm0
179 ; AVX1-NEXT: vmovd %xmm2, %eax
180 ; AVX1-NEXT: testl %eax, %eax
181 ; AVX1-NEXT: js .LBB4_1
182 ; AVX1-NEXT: # %bb.2:
183 ; AVX1-NEXT: vmaxss %xmm2, %xmm0, %xmm0
185 ; AVX1-NEXT: .LBB4_1:
186 ; AVX1-NEXT: vmovaps %xmm0, %xmm1
187 ; AVX1-NEXT: vmaxss %xmm1, %xmm2, %xmm0
190 ; AVX512F-LABEL: test_fmaximum_nnan:
192 ; AVX512F-NEXT: vaddss %xmm1, %xmm0, %xmm2
193 ; AVX512F-NEXT: vsubss %xmm1, %xmm0, %xmm0
194 ; AVX512F-NEXT: vmovd %xmm2, %eax
195 ; AVX512F-NEXT: testl %eax, %eax
196 ; AVX512F-NEXT: sets %al
197 ; AVX512F-NEXT: kmovw %eax, %k1
198 ; AVX512F-NEXT: vmovaps %xmm2, %xmm1
199 ; AVX512F-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
200 ; AVX512F-NEXT: vmovss %xmm2, %xmm0, %xmm0 {%k1}
201 ; AVX512F-NEXT: vmaxss %xmm1, %xmm0, %xmm0
204 ; AVX512DQ-LABEL: test_fmaximum_nnan:
206 ; AVX512DQ-NEXT: vaddss %xmm1, %xmm0, %xmm2
207 ; AVX512DQ-NEXT: vsubss %xmm1, %xmm0, %xmm0
208 ; AVX512DQ-NEXT: vfpclassss $3, %xmm0, %k0
209 ; AVX512DQ-NEXT: kmovw %k0, %k1
210 ; AVX512DQ-NEXT: vmovaps %xmm2, %xmm1
211 ; AVX512DQ-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
212 ; AVX512DQ-NEXT: vmovss %xmm2, %xmm0, %xmm0 {%k1}
213 ; AVX512DQ-NEXT: vmaxss %xmm1, %xmm0, %xmm0
214 ; AVX512DQ-NEXT: retq
216 ; X86-LABEL: test_fmaximum_nnan:
218 ; X86-NEXT: pushl %eax
219 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
220 ; X86-NEXT: vmovss {{.*#+}} xmm2 = mem[0],zero,zero,zero
221 ; X86-NEXT: vaddss %xmm0, %xmm2, %xmm1
222 ; X86-NEXT: vsubss %xmm0, %xmm2, %xmm0
223 ; X86-NEXT: vmovd %xmm1, %eax
224 ; X86-NEXT: testl %eax, %eax
225 ; X86-NEXT: js .LBB4_1
227 ; X86-NEXT: vmovaps %xmm1, %xmm2
228 ; X86-NEXT: jmp .LBB4_3
230 ; X86-NEXT: vmovaps %xmm0, %xmm2
231 ; X86-NEXT: vmovaps %xmm1, %xmm0
233 ; X86-NEXT: vmaxss %xmm2, %xmm0, %xmm0
234 ; X86-NEXT: vmovss %xmm0, (%esp)
235 ; X86-NEXT: flds (%esp)
236 ; X86-NEXT: popl %eax
238 %1 = fadd nnan float %x, %y
239 %2 = fsub nnan float %x, %y
240 %3 = tail call float @llvm.maximum.f32(float %1, float %2)
244 define double @test_fmaximum_zero0(double %x, double %y) nounwind {
245 ; SSE2-LABEL: test_fmaximum_zero0:
247 ; SSE2-NEXT: movapd %xmm1, %xmm0
248 ; SSE2-NEXT: cmpunordsd %xmm1, %xmm0
249 ; SSE2-NEXT: movapd %xmm0, %xmm2
250 ; SSE2-NEXT: andpd %xmm1, %xmm2
251 ; SSE2-NEXT: xorpd %xmm3, %xmm3
252 ; SSE2-NEXT: maxsd %xmm3, %xmm1
253 ; SSE2-NEXT: andnpd %xmm1, %xmm0
254 ; SSE2-NEXT: orpd %xmm2, %xmm0
257 ; AVX1-LABEL: test_fmaximum_zero0:
259 ; AVX1-NEXT: vxorpd %xmm0, %xmm0, %xmm0
260 ; AVX1-NEXT: vmaxsd %xmm0, %xmm1, %xmm0
261 ; AVX1-NEXT: vcmpunordsd %xmm1, %xmm1, %xmm2
262 ; AVX1-NEXT: vblendvpd %xmm2, %xmm1, %xmm0, %xmm0
265 ; AVX512-LABEL: test_fmaximum_zero0:
267 ; AVX512-NEXT: vxorpd %xmm0, %xmm0, %xmm0
268 ; AVX512-NEXT: vmaxsd %xmm0, %xmm1, %xmm0
269 ; AVX512-NEXT: vcmpunordsd %xmm1, %xmm1, %k1
270 ; AVX512-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
273 ; X86-LABEL: test_fmaximum_zero0:
275 ; X86-NEXT: pushl %ebp
276 ; X86-NEXT: movl %esp, %ebp
277 ; X86-NEXT: andl $-8, %esp
278 ; X86-NEXT: subl $8, %esp
279 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
280 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
281 ; X86-NEXT: vmaxsd %xmm1, %xmm0, %xmm1
282 ; X86-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm2
283 ; X86-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
284 ; X86-NEXT: vmovlpd %xmm0, (%esp)
285 ; X86-NEXT: fldl (%esp)
286 ; X86-NEXT: movl %ebp, %esp
287 ; X86-NEXT: popl %ebp
289 %1 = tail call double @llvm.maximum.f64(double 0.0, double %y)
293 define double @test_fmaximum_zero1(double %x, double %y) nounwind {
294 ; SSE2-LABEL: test_fmaximum_zero1:
296 ; SSE2-NEXT: movapd %xmm0, %xmm1
297 ; SSE2-NEXT: cmpunordsd %xmm0, %xmm1
298 ; SSE2-NEXT: movapd %xmm1, %xmm2
299 ; SSE2-NEXT: andpd %xmm0, %xmm2
300 ; SSE2-NEXT: xorpd %xmm3, %xmm3
301 ; SSE2-NEXT: maxsd %xmm3, %xmm0
302 ; SSE2-NEXT: andnpd %xmm0, %xmm1
303 ; SSE2-NEXT: orpd %xmm2, %xmm1
304 ; SSE2-NEXT: movapd %xmm1, %xmm0
307 ; AVX1-LABEL: test_fmaximum_zero1:
309 ; AVX1-NEXT: vxorpd %xmm1, %xmm1, %xmm1
310 ; AVX1-NEXT: vmaxsd %xmm1, %xmm0, %xmm1
311 ; AVX1-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm2
312 ; AVX1-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
315 ; AVX512-LABEL: test_fmaximum_zero1:
317 ; AVX512-NEXT: vxorpd %xmm1, %xmm1, %xmm1
318 ; AVX512-NEXT: vmaxsd %xmm1, %xmm0, %xmm1
319 ; AVX512-NEXT: vcmpunordsd %xmm0, %xmm0, %k1
320 ; AVX512-NEXT: vmovsd %xmm0, %xmm1, %xmm1 {%k1}
321 ; AVX512-NEXT: vmovapd %xmm1, %xmm0
324 ; X86-LABEL: test_fmaximum_zero1:
326 ; X86-NEXT: pushl %ebp
327 ; X86-NEXT: movl %esp, %ebp
328 ; X86-NEXT: andl $-8, %esp
329 ; X86-NEXT: subl $8, %esp
330 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
331 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
332 ; X86-NEXT: vmaxsd %xmm1, %xmm0, %xmm1
333 ; X86-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm2
334 ; X86-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
335 ; X86-NEXT: vmovlpd %xmm0, (%esp)
336 ; X86-NEXT: fldl (%esp)
337 ; X86-NEXT: movl %ebp, %esp
338 ; X86-NEXT: popl %ebp
340 %1 = tail call double @llvm.maximum.f64(double %x, double 0.0)
344 define double @test_fmaximum_zero2(double %x, double %y) {
345 ; SSE2-LABEL: test_fmaximum_zero2:
347 ; SSE2-NEXT: xorps %xmm0, %xmm0
350 ; AVX-LABEL: test_fmaximum_zero2:
352 ; AVX-NEXT: vxorps %xmm0, %xmm0, %xmm0
355 ; X86-LABEL: test_fmaximum_zero2:
359 %1 = tail call double @llvm.maximum.f64(double 0.0, double -0.0)
363 define float @test_fmaximum_nsz(float %x, float %y) "no-signed-zeros-fp-math"="true" nounwind {
364 ; SSE2-LABEL: test_fmaximum_nsz:
366 ; SSE2-NEXT: movaps %xmm0, %xmm2
367 ; SSE2-NEXT: cmpunordss %xmm0, %xmm2
368 ; SSE2-NEXT: movaps %xmm2, %xmm3
369 ; SSE2-NEXT: andps %xmm0, %xmm3
370 ; SSE2-NEXT: maxss %xmm1, %xmm0
371 ; SSE2-NEXT: andnps %xmm0, %xmm2
372 ; SSE2-NEXT: orps %xmm3, %xmm2
373 ; SSE2-NEXT: movaps %xmm2, %xmm0
376 ; AVX1-LABEL: test_fmaximum_nsz:
378 ; AVX1-NEXT: vmaxss %xmm1, %xmm0, %xmm1
379 ; AVX1-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
380 ; AVX1-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
383 ; AVX512-LABEL: test_fmaximum_nsz:
385 ; AVX512-NEXT: vmaxss %xmm1, %xmm0, %xmm1
386 ; AVX512-NEXT: vcmpunordss %xmm0, %xmm0, %k1
387 ; AVX512-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
388 ; AVX512-NEXT: vmovaps %xmm1, %xmm0
391 ; X86-LABEL: test_fmaximum_nsz:
393 ; X86-NEXT: pushl %eax
394 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
395 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm1
396 ; X86-NEXT: vmaxss {{[0-9]+}}(%esp), %xmm0, %xmm2
397 ; X86-NEXT: vblendvps %xmm1, %xmm0, %xmm2, %xmm0
398 ; X86-NEXT: vmovss %xmm0, (%esp)
399 ; X86-NEXT: flds (%esp)
400 ; X86-NEXT: popl %eax
402 %1 = tail call float @llvm.maximum.f32(float %x, float %y)
406 define float @test_fmaximum_combine_cmps(float %x, float %y) nounwind {
407 ; SSE2-LABEL: test_fmaximum_combine_cmps:
409 ; SSE2-NEXT: divss %xmm0, %xmm1
410 ; SSE2-NEXT: movd %xmm0, %eax
411 ; SSE2-NEXT: testl %eax, %eax
412 ; SSE2-NEXT: movaps %xmm0, %xmm3
413 ; SSE2-NEXT: js .LBB9_2
414 ; SSE2-NEXT: # %bb.1:
415 ; SSE2-NEXT: movaps %xmm1, %xmm3
416 ; SSE2-NEXT: .LBB9_2:
417 ; SSE2-NEXT: movaps %xmm3, %xmm2
418 ; SSE2-NEXT: cmpunordss %xmm3, %xmm2
419 ; SSE2-NEXT: movaps %xmm2, %xmm4
420 ; SSE2-NEXT: andps %xmm3, %xmm4
421 ; SSE2-NEXT: js .LBB9_4
422 ; SSE2-NEXT: # %bb.3:
423 ; SSE2-NEXT: movaps %xmm0, %xmm1
424 ; SSE2-NEXT: .LBB9_4:
425 ; SSE2-NEXT: maxss %xmm1, %xmm3
426 ; SSE2-NEXT: andnps %xmm3, %xmm2
427 ; SSE2-NEXT: orps %xmm4, %xmm2
428 ; SSE2-NEXT: movaps %xmm2, %xmm0
431 ; AVX1-LABEL: test_fmaximum_combine_cmps:
433 ; AVX1-NEXT: vdivss %xmm0, %xmm1, %xmm1
434 ; AVX1-NEXT: vmovd %xmm0, %eax
435 ; AVX1-NEXT: testl %eax, %eax
436 ; AVX1-NEXT: js .LBB9_1
437 ; AVX1-NEXT: # %bb.2:
438 ; AVX1-NEXT: vmovaps %xmm0, %xmm2
439 ; AVX1-NEXT: jmp .LBB9_3
440 ; AVX1-NEXT: .LBB9_1:
441 ; AVX1-NEXT: vmovaps %xmm1, %xmm2
442 ; AVX1-NEXT: vmovaps %xmm0, %xmm1
443 ; AVX1-NEXT: .LBB9_3:
444 ; AVX1-NEXT: vmaxss %xmm2, %xmm1, %xmm0
445 ; AVX1-NEXT: vcmpunordss %xmm1, %xmm1, %xmm2
446 ; AVX1-NEXT: vblendvps %xmm2, %xmm1, %xmm0, %xmm0
449 ; AVX512F-LABEL: test_fmaximum_combine_cmps:
451 ; AVX512F-NEXT: vdivss %xmm0, %xmm1, %xmm1
452 ; AVX512F-NEXT: vmovd %xmm0, %eax
453 ; AVX512F-NEXT: testl %eax, %eax
454 ; AVX512F-NEXT: sets %al
455 ; AVX512F-NEXT: kmovw %eax, %k1
456 ; AVX512F-NEXT: vmovaps %xmm0, %xmm2
457 ; AVX512F-NEXT: vmovss %xmm1, %xmm2, %xmm2 {%k1}
458 ; AVX512F-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
459 ; AVX512F-NEXT: vmaxss %xmm2, %xmm1, %xmm0
460 ; AVX512F-NEXT: vcmpunordss %xmm1, %xmm1, %k1
461 ; AVX512F-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
464 ; AVX512DQ-LABEL: test_fmaximum_combine_cmps:
466 ; AVX512DQ-NEXT: vdivss %xmm0, %xmm1, %xmm1
467 ; AVX512DQ-NEXT: vfpclassss $3, %xmm0, %k0
468 ; AVX512DQ-NEXT: kmovw %k0, %k1
469 ; AVX512DQ-NEXT: vmovaps %xmm1, %xmm2
470 ; AVX512DQ-NEXT: vmovss %xmm0, %xmm2, %xmm2 {%k1}
471 ; AVX512DQ-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
472 ; AVX512DQ-NEXT: vmaxss %xmm2, %xmm0, %xmm0
473 ; AVX512DQ-NEXT: retq
475 ; X86-LABEL: test_fmaximum_combine_cmps:
477 ; X86-NEXT: pushl %eax
478 ; X86-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
479 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
480 ; X86-NEXT: vdivss %xmm1, %xmm0, %xmm0
481 ; X86-NEXT: vmovd %xmm1, %eax
482 ; X86-NEXT: testl %eax, %eax
483 ; X86-NEXT: js .LBB9_1
485 ; X86-NEXT: vmovaps %xmm1, %xmm2
486 ; X86-NEXT: jmp .LBB9_3
488 ; X86-NEXT: vmovaps %xmm0, %xmm2
489 ; X86-NEXT: vmovaps %xmm1, %xmm0
491 ; X86-NEXT: vmaxss %xmm2, %xmm0, %xmm1
492 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
493 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
494 ; X86-NEXT: vmovss %xmm0, (%esp)
495 ; X86-NEXT: flds (%esp)
496 ; X86-NEXT: popl %eax
498 %1 = fdiv nnan float %y, %x
499 %2 = tail call float @llvm.maximum.f32(float %x, float %1)
507 define float @test_fminimum(float %x, float %y) nounwind {
508 ; SSE2-LABEL: test_fminimum:
510 ; SSE2-NEXT: movd %xmm0, %eax
511 ; SSE2-NEXT: testl %eax, %eax
512 ; SSE2-NEXT: movdqa %xmm1, %xmm3
513 ; SSE2-NEXT: js .LBB10_2
514 ; SSE2-NEXT: # %bb.1:
515 ; SSE2-NEXT: movdqa %xmm0, %xmm3
516 ; SSE2-NEXT: .LBB10_2:
517 ; SSE2-NEXT: movdqa %xmm3, %xmm2
518 ; SSE2-NEXT: cmpunordss %xmm3, %xmm2
519 ; SSE2-NEXT: movaps %xmm2, %xmm4
520 ; SSE2-NEXT: andps %xmm3, %xmm4
521 ; SSE2-NEXT: js .LBB10_4
522 ; SSE2-NEXT: # %bb.3:
523 ; SSE2-NEXT: movdqa %xmm1, %xmm0
524 ; SSE2-NEXT: .LBB10_4:
525 ; SSE2-NEXT: minss %xmm0, %xmm3
526 ; SSE2-NEXT: andnps %xmm3, %xmm2
527 ; SSE2-NEXT: orps %xmm4, %xmm2
528 ; SSE2-NEXT: movaps %xmm2, %xmm0
531 ; AVX1-LABEL: test_fminimum:
533 ; AVX1-NEXT: vmovd %xmm0, %eax
534 ; AVX1-NEXT: testl %eax, %eax
535 ; AVX1-NEXT: js .LBB10_1
536 ; AVX1-NEXT: # %bb.2:
537 ; AVX1-NEXT: vmovdqa %xmm1, %xmm2
538 ; AVX1-NEXT: jmp .LBB10_3
539 ; AVX1-NEXT: .LBB10_1:
540 ; AVX1-NEXT: vmovdqa %xmm0, %xmm2
541 ; AVX1-NEXT: vmovdqa %xmm1, %xmm0
542 ; AVX1-NEXT: .LBB10_3:
543 ; AVX1-NEXT: vminss %xmm2, %xmm0, %xmm1
544 ; AVX1-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
545 ; AVX1-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
548 ; AVX512-LABEL: test_fminimum:
550 ; AVX512-NEXT: vmovd %xmm0, %eax
551 ; AVX512-NEXT: testl %eax, %eax
552 ; AVX512-NEXT: sets %al
553 ; AVX512-NEXT: kmovw %eax, %k1
554 ; AVX512-NEXT: vmovaps %xmm1, %xmm2
555 ; AVX512-NEXT: vmovss %xmm0, %xmm2, %xmm2 {%k1}
556 ; AVX512-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
557 ; AVX512-NEXT: vminss %xmm2, %xmm0, %xmm1
558 ; AVX512-NEXT: vcmpunordss %xmm0, %xmm0, %k1
559 ; AVX512-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
560 ; AVX512-NEXT: vmovaps %xmm1, %xmm0
563 ; X86-LABEL: test_fminimum:
565 ; X86-NEXT: pushl %eax
566 ; X86-NEXT: vmovd {{.*#+}} xmm1 = mem[0],zero,zero,zero
567 ; X86-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
568 ; X86-NEXT: vmovd %xmm0, %eax
569 ; X86-NEXT: testl %eax, %eax
570 ; X86-NEXT: js .LBB10_1
572 ; X86-NEXT: vmovdqa %xmm1, %xmm2
573 ; X86-NEXT: jmp .LBB10_3
574 ; X86-NEXT: .LBB10_1:
575 ; X86-NEXT: vmovdqa %xmm0, %xmm2
576 ; X86-NEXT: vmovdqa %xmm1, %xmm0
577 ; X86-NEXT: .LBB10_3:
578 ; X86-NEXT: vminss %xmm2, %xmm0, %xmm1
579 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
580 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
581 ; X86-NEXT: vmovss %xmm0, (%esp)
582 ; X86-NEXT: flds (%esp)
583 ; X86-NEXT: popl %eax
585 %1 = tail call float @llvm.minimum.f32(float %x, float %y)
589 define <2 x double> @test_fminimum_scalarize(<2 x double> %x, <2 x double> %y) "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {
590 ; SSE2-LABEL: test_fminimum_scalarize:
592 ; SSE2-NEXT: minpd %xmm1, %xmm0
595 ; AVX-LABEL: test_fminimum_scalarize:
597 ; AVX-NEXT: vminpd %xmm1, %xmm0, %xmm0
600 ; X86-LABEL: test_fminimum_scalarize:
602 ; X86-NEXT: vminpd %xmm1, %xmm0, %xmm0
604 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> %y)
608 define float @test_fminimum_nan0(float %x, float %y) {
609 ; SSE2-LABEL: test_fminimum_nan0:
611 ; SSE2-NEXT: movss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
614 ; AVX-LABEL: test_fminimum_nan0:
616 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
619 ; X86-LABEL: test_fminimum_nan0:
621 ; X86-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}
623 %1 = tail call float @llvm.minimum.f32(float 0x7fff000000000000, float %y)
627 define float @test_fminimum_nan1(float %x, float %y) {
628 ; SSE2-LABEL: test_fminimum_nan1:
630 ; SSE2-NEXT: movss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
633 ; AVX-LABEL: test_fminimum_nan1:
635 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = [NaN,0.0E+0,0.0E+0,0.0E+0]
638 ; X86-LABEL: test_fminimum_nan1:
640 ; X86-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}
642 %1 = tail call float @llvm.minimum.f32(float %x, float 0x7fff000000000000)
646 define double @test_fminimum_nnan(double %x, double %y) "no-nans-fp-math"="true" nounwind {
647 ; SSE2-LABEL: test_fminimum_nnan:
649 ; SSE2-NEXT: movq %xmm0, %rax
650 ; SSE2-NEXT: testq %rax, %rax
651 ; SSE2-NEXT: js .LBB14_1
652 ; SSE2-NEXT: # %bb.2:
653 ; SSE2-NEXT: minsd %xmm1, %xmm0
655 ; SSE2-NEXT: .LBB14_1:
656 ; SSE2-NEXT: movdqa %xmm0, %xmm2
657 ; SSE2-NEXT: movapd %xmm1, %xmm0
658 ; SSE2-NEXT: minsd %xmm2, %xmm0
661 ; AVX1-LABEL: test_fminimum_nnan:
663 ; AVX1-NEXT: vmovq %xmm0, %rax
664 ; AVX1-NEXT: testq %rax, %rax
665 ; AVX1-NEXT: js .LBB14_1
666 ; AVX1-NEXT: # %bb.2:
667 ; AVX1-NEXT: vminsd %xmm1, %xmm0, %xmm0
669 ; AVX1-NEXT: .LBB14_1:
670 ; AVX1-NEXT: vmovdqa %xmm0, %xmm2
671 ; AVX1-NEXT: vminsd %xmm2, %xmm1, %xmm0
674 ; AVX512F-LABEL: test_fminimum_nnan:
676 ; AVX512F-NEXT: vmovq %xmm0, %rax
677 ; AVX512F-NEXT: testq %rax, %rax
678 ; AVX512F-NEXT: sets %al
679 ; AVX512F-NEXT: kmovw %eax, %k1
680 ; AVX512F-NEXT: vmovapd %xmm1, %xmm2
681 ; AVX512F-NEXT: vmovsd %xmm0, %xmm2, %xmm2 {%k1}
682 ; AVX512F-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
683 ; AVX512F-NEXT: vminsd %xmm2, %xmm0, %xmm0
686 ; AVX512DQ-LABEL: test_fminimum_nnan:
688 ; AVX512DQ-NEXT: vfpclasssd $5, %xmm1, %k0
689 ; AVX512DQ-NEXT: kmovw %k0, %k1
690 ; AVX512DQ-NEXT: vmovapd %xmm0, %xmm2
691 ; AVX512DQ-NEXT: vmovsd %xmm1, %xmm2, %xmm2 {%k1}
692 ; AVX512DQ-NEXT: vmovsd %xmm0, %xmm1, %xmm1 {%k1}
693 ; AVX512DQ-NEXT: vminsd %xmm2, %xmm1, %xmm0
694 ; AVX512DQ-NEXT: retq
696 ; X86-LABEL: test_fminimum_nnan:
698 ; X86-NEXT: pushl %ebp
699 ; X86-NEXT: movl %esp, %ebp
700 ; X86-NEXT: andl $-8, %esp
701 ; X86-NEXT: subl $8, %esp
702 ; X86-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
703 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
704 ; X86-NEXT: vextractps $1, %xmm0, %eax
705 ; X86-NEXT: testl %eax, %eax
706 ; X86-NEXT: js .LBB14_1
708 ; X86-NEXT: vmovapd %xmm1, %xmm2
709 ; X86-NEXT: jmp .LBB14_3
710 ; X86-NEXT: .LBB14_1:
711 ; X86-NEXT: vmovapd %xmm0, %xmm2
712 ; X86-NEXT: vmovapd %xmm1, %xmm0
713 ; X86-NEXT: .LBB14_3:
714 ; X86-NEXT: vminsd %xmm2, %xmm0, %xmm0
715 ; X86-NEXT: vmovsd %xmm0, (%esp)
716 ; X86-NEXT: fldl (%esp)
717 ; X86-NEXT: movl %ebp, %esp
718 ; X86-NEXT: popl %ebp
720 %1 = tail call double @llvm.minimum.f64(double %x, double %y)
724 define double @test_fminimum_zero0(double %x, double %y) nounwind {
725 ; SSE2-LABEL: test_fminimum_zero0:
727 ; SSE2-NEXT: movapd %xmm1, %xmm0
728 ; SSE2-NEXT: cmpunordsd %xmm1, %xmm0
729 ; SSE2-NEXT: movapd %xmm0, %xmm2
730 ; SSE2-NEXT: andpd %xmm1, %xmm2
731 ; SSE2-NEXT: minsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
732 ; SSE2-NEXT: andnpd %xmm1, %xmm0
733 ; SSE2-NEXT: orpd %xmm2, %xmm0
736 ; AVX1-LABEL: test_fminimum_zero0:
738 ; AVX1-NEXT: vcmpunordsd %xmm1, %xmm1, %xmm0
739 ; AVX1-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm2
740 ; AVX1-NEXT: vblendvpd %xmm0, %xmm1, %xmm2, %xmm0
743 ; AVX512-LABEL: test_fminimum_zero0:
745 ; AVX512-NEXT: vcmpunordsd %xmm1, %xmm1, %k1
746 ; AVX512-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0
747 ; AVX512-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
750 ; X86-LABEL: test_fminimum_zero0:
752 ; X86-NEXT: pushl %ebp
753 ; X86-NEXT: movl %esp, %ebp
754 ; X86-NEXT: andl $-8, %esp
755 ; X86-NEXT: subl $8, %esp
756 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
757 ; X86-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm1
758 ; X86-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm2
759 ; X86-NEXT: vblendvpd %xmm1, %xmm0, %xmm2, %xmm0
760 ; X86-NEXT: vmovlpd %xmm0, (%esp)
761 ; X86-NEXT: fldl (%esp)
762 ; X86-NEXT: movl %ebp, %esp
763 ; X86-NEXT: popl %ebp
765 %1 = tail call double @llvm.minimum.f64(double -0.0, double %y)
769 define double @test_fminimum_zero1(double %x, double %y) nounwind {
770 ; SSE2-LABEL: test_fminimum_zero1:
772 ; SSE2-NEXT: movapd %xmm0, %xmm1
773 ; SSE2-NEXT: cmpunordsd %xmm0, %xmm1
774 ; SSE2-NEXT: movapd %xmm1, %xmm2
775 ; SSE2-NEXT: andpd %xmm0, %xmm2
776 ; SSE2-NEXT: minsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
777 ; SSE2-NEXT: andnpd %xmm0, %xmm1
778 ; SSE2-NEXT: orpd %xmm2, %xmm1
779 ; SSE2-NEXT: movapd %xmm1, %xmm0
782 ; AVX1-LABEL: test_fminimum_zero1:
784 ; AVX1-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm1
785 ; AVX1-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm2
786 ; AVX1-NEXT: vblendvpd %xmm1, %xmm0, %xmm2, %xmm0
789 ; AVX512-LABEL: test_fminimum_zero1:
791 ; AVX512-NEXT: vcmpunordsd %xmm0, %xmm0, %k1
792 ; AVX512-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1
793 ; AVX512-NEXT: vmovsd %xmm0, %xmm1, %xmm1 {%k1}
794 ; AVX512-NEXT: vmovapd %xmm1, %xmm0
797 ; X86-LABEL: test_fminimum_zero1:
799 ; X86-NEXT: pushl %ebp
800 ; X86-NEXT: movl %esp, %ebp
801 ; X86-NEXT: andl $-8, %esp
802 ; X86-NEXT: subl $8, %esp
803 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
804 ; X86-NEXT: vcmpunordsd %xmm0, %xmm0, %xmm1
805 ; X86-NEXT: vminsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm2
806 ; X86-NEXT: vblendvpd %xmm1, %xmm0, %xmm2, %xmm0
807 ; X86-NEXT: vmovlpd %xmm0, (%esp)
808 ; X86-NEXT: fldl (%esp)
809 ; X86-NEXT: movl %ebp, %esp
810 ; X86-NEXT: popl %ebp
812 %1 = tail call double @llvm.minimum.f64(double %x, double -0.0)
816 define double @test_fminimum_zero2(double %x, double %y) {
817 ; SSE2-LABEL: test_fminimum_zero2:
819 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = [-0.0E+0,0.0E+0]
822 ; AVX-LABEL: test_fminimum_zero2:
824 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = [-0.0E+0,0.0E+0]
827 ; X86-LABEL: test_fminimum_zero2:
832 %1 = tail call double @llvm.minimum.f64(double -0.0, double 0.0)
836 define float @test_fminimum_nsz(float %x, float %y) nounwind {
837 ; SSE2-LABEL: test_fminimum_nsz:
839 ; SSE2-NEXT: movaps %xmm0, %xmm2
840 ; SSE2-NEXT: cmpunordss %xmm0, %xmm2
841 ; SSE2-NEXT: movaps %xmm2, %xmm3
842 ; SSE2-NEXT: andps %xmm0, %xmm3
843 ; SSE2-NEXT: minss %xmm1, %xmm0
844 ; SSE2-NEXT: andnps %xmm0, %xmm2
845 ; SSE2-NEXT: orps %xmm3, %xmm2
846 ; SSE2-NEXT: movaps %xmm2, %xmm0
849 ; AVX1-LABEL: test_fminimum_nsz:
851 ; AVX1-NEXT: vminss %xmm1, %xmm0, %xmm1
852 ; AVX1-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
853 ; AVX1-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
856 ; AVX512-LABEL: test_fminimum_nsz:
858 ; AVX512-NEXT: vminss %xmm1, %xmm0, %xmm1
859 ; AVX512-NEXT: vcmpunordss %xmm0, %xmm0, %k1
860 ; AVX512-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
861 ; AVX512-NEXT: vmovaps %xmm1, %xmm0
864 ; X86-LABEL: test_fminimum_nsz:
866 ; X86-NEXT: pushl %eax
867 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
868 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm1
869 ; X86-NEXT: vminss {{[0-9]+}}(%esp), %xmm0, %xmm2
870 ; X86-NEXT: vblendvps %xmm1, %xmm0, %xmm2, %xmm0
871 ; X86-NEXT: vmovss %xmm0, (%esp)
872 ; X86-NEXT: flds (%esp)
873 ; X86-NEXT: popl %eax
875 %1 = tail call nsz float @llvm.minimum.f32(float %x, float %y)
879 define float @test_fminimum_combine_cmps(float %x, float %y) nounwind {
880 ; SSE2-LABEL: test_fminimum_combine_cmps:
882 ; SSE2-NEXT: divss %xmm0, %xmm1
883 ; SSE2-NEXT: movd %xmm0, %eax
884 ; SSE2-NEXT: testl %eax, %eax
885 ; SSE2-NEXT: movaps %xmm1, %xmm3
886 ; SSE2-NEXT: js .LBB19_2
887 ; SSE2-NEXT: # %bb.1:
888 ; SSE2-NEXT: movaps %xmm0, %xmm3
889 ; SSE2-NEXT: .LBB19_2:
890 ; SSE2-NEXT: movaps %xmm3, %xmm2
891 ; SSE2-NEXT: cmpunordss %xmm3, %xmm2
892 ; SSE2-NEXT: movaps %xmm2, %xmm4
893 ; SSE2-NEXT: andps %xmm3, %xmm4
894 ; SSE2-NEXT: js .LBB19_4
895 ; SSE2-NEXT: # %bb.3:
896 ; SSE2-NEXT: movaps %xmm1, %xmm0
897 ; SSE2-NEXT: .LBB19_4:
898 ; SSE2-NEXT: minss %xmm0, %xmm3
899 ; SSE2-NEXT: andnps %xmm3, %xmm2
900 ; SSE2-NEXT: orps %xmm4, %xmm2
901 ; SSE2-NEXT: movaps %xmm2, %xmm0
904 ; AVX1-LABEL: test_fminimum_combine_cmps:
906 ; AVX1-NEXT: vdivss %xmm0, %xmm1, %xmm2
907 ; AVX1-NEXT: vmovd %xmm0, %eax
908 ; AVX1-NEXT: testl %eax, %eax
909 ; AVX1-NEXT: js .LBB19_1
910 ; AVX1-NEXT: # %bb.2:
911 ; AVX1-NEXT: vmovaps %xmm2, %xmm1
912 ; AVX1-NEXT: jmp .LBB19_3
913 ; AVX1-NEXT: .LBB19_1:
914 ; AVX1-NEXT: vmovaps %xmm0, %xmm1
915 ; AVX1-NEXT: vmovaps %xmm2, %xmm0
916 ; AVX1-NEXT: .LBB19_3:
917 ; AVX1-NEXT: vminss %xmm1, %xmm0, %xmm1
918 ; AVX1-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
919 ; AVX1-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
922 ; AVX512F-LABEL: test_fminimum_combine_cmps:
924 ; AVX512F-NEXT: vdivss %xmm0, %xmm1, %xmm1
925 ; AVX512F-NEXT: vmovd %xmm0, %eax
926 ; AVX512F-NEXT: testl %eax, %eax
927 ; AVX512F-NEXT: sets %al
928 ; AVX512F-NEXT: kmovw %eax, %k1
929 ; AVX512F-NEXT: vmovaps %xmm1, %xmm2
930 ; AVX512F-NEXT: vmovss %xmm0, %xmm2, %xmm2 {%k1}
931 ; AVX512F-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
932 ; AVX512F-NEXT: vminss %xmm2, %xmm0, %xmm1
933 ; AVX512F-NEXT: vcmpunordss %xmm0, %xmm0, %k1
934 ; AVX512F-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
935 ; AVX512F-NEXT: vmovaps %xmm1, %xmm0
938 ; AVX512DQ-LABEL: test_fminimum_combine_cmps:
940 ; AVX512DQ-NEXT: vdivss %xmm0, %xmm1, %xmm1
941 ; AVX512DQ-NEXT: vfpclassss $5, %xmm0, %k0
942 ; AVX512DQ-NEXT: kmovw %k0, %k1
943 ; AVX512DQ-NEXT: vmovaps %xmm1, %xmm2
944 ; AVX512DQ-NEXT: vmovss %xmm0, %xmm2, %xmm2 {%k1}
945 ; AVX512DQ-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
946 ; AVX512DQ-NEXT: vminss %xmm2, %xmm0, %xmm0
947 ; AVX512DQ-NEXT: retq
949 ; X86-LABEL: test_fminimum_combine_cmps:
951 ; X86-NEXT: pushl %eax
952 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
953 ; X86-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
954 ; X86-NEXT: vdivss %xmm0, %xmm1, %xmm2
955 ; X86-NEXT: vmovd %xmm0, %eax
956 ; X86-NEXT: testl %eax, %eax
957 ; X86-NEXT: js .LBB19_1
959 ; X86-NEXT: vmovaps %xmm2, %xmm1
960 ; X86-NEXT: jmp .LBB19_3
961 ; X86-NEXT: .LBB19_1:
962 ; X86-NEXT: vmovaps %xmm0, %xmm1
963 ; X86-NEXT: vmovaps %xmm2, %xmm0
964 ; X86-NEXT: .LBB19_3:
965 ; X86-NEXT: vminss %xmm1, %xmm0, %xmm1
966 ; X86-NEXT: vcmpunordss %xmm0, %xmm0, %xmm2
967 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
968 ; X86-NEXT: vmovss %xmm0, (%esp)
969 ; X86-NEXT: flds (%esp)
970 ; X86-NEXT: popl %eax
972 %1 = fdiv nnan float %y, %x
973 %2 = tail call float @llvm.minimum.f32(float %x, float %1)
977 define <2 x double> @test_fminimum_vector(<2 x double> %x, <2 x double> %y) {
978 ; SSE2-LABEL: test_fminimum_vector:
980 ; SSE2-NEXT: movaps %xmm0, %xmm2
981 ; SSE2-NEXT: shufps {{.*#+}} xmm2 = xmm2[1,1],xmm0[3,3]
982 ; SSE2-NEXT: pxor %xmm3, %xmm3
983 ; SSE2-NEXT: pcmpgtd %xmm2, %xmm3
984 ; SSE2-NEXT: movdqa %xmm3, %xmm2
985 ; SSE2-NEXT: pandn %xmm1, %xmm2
986 ; SSE2-NEXT: movdqa %xmm3, %xmm4
987 ; SSE2-NEXT: pandn %xmm0, %xmm4
988 ; SSE2-NEXT: pand %xmm3, %xmm0
989 ; SSE2-NEXT: por %xmm2, %xmm0
990 ; SSE2-NEXT: pand %xmm1, %xmm3
991 ; SSE2-NEXT: por %xmm4, %xmm3
992 ; SSE2-NEXT: movdqa %xmm3, %xmm1
993 ; SSE2-NEXT: minpd %xmm0, %xmm1
994 ; SSE2-NEXT: movdqa %xmm3, %xmm0
995 ; SSE2-NEXT: cmpunordpd %xmm3, %xmm0
996 ; SSE2-NEXT: andpd %xmm0, %xmm3
997 ; SSE2-NEXT: andnpd %xmm1, %xmm0
998 ; SSE2-NEXT: orpd %xmm3, %xmm0
1001 ; AVX-LABEL: test_fminimum_vector:
1003 ; AVX-NEXT: vblendvpd %xmm0, %xmm0, %xmm1, %xmm2
1004 ; AVX-NEXT: vblendvpd %xmm0, %xmm1, %xmm0, %xmm0
1005 ; AVX-NEXT: vminpd %xmm2, %xmm0, %xmm1
1006 ; AVX-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm2
1007 ; AVX-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
1010 ; X86-LABEL: test_fminimum_vector:
1012 ; X86-NEXT: vblendvpd %xmm0, %xmm0, %xmm1, %xmm2
1013 ; X86-NEXT: vblendvpd %xmm0, %xmm1, %xmm0, %xmm0
1014 ; X86-NEXT: vminpd %xmm2, %xmm0, %xmm1
1015 ; X86-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm2
1016 ; X86-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
1018 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> %y)
1022 define <4 x float> @test_fmaximum_vector(<4 x float> %x, <4 x float> %y) "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {
1023 ; SSE2-LABEL: test_fmaximum_vector:
1025 ; SSE2-NEXT: maxps %xmm1, %xmm0
1028 ; AVX-LABEL: test_fmaximum_vector:
1030 ; AVX-NEXT: vmaxps %xmm1, %xmm0, %xmm0
1033 ; X86-LABEL: test_fmaximum_vector:
1035 ; X86-NEXT: vmaxps %xmm1, %xmm0, %xmm0
1037 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> %y)
1041 define <2 x double> @test_fminimum_vector_zero(<2 x double> %x) {
1042 ; SSE2-LABEL: test_fminimum_vector_zero:
1044 ; SSE2-NEXT: xorpd %xmm1, %xmm1
1045 ; SSE2-NEXT: minpd %xmm0, %xmm1
1046 ; SSE2-NEXT: movapd %xmm1, %xmm0
1049 ; AVX-LABEL: test_fminimum_vector_zero:
1051 ; AVX-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1052 ; AVX-NEXT: vminpd %xmm0, %xmm1, %xmm0
1055 ; X86-LABEL: test_fminimum_vector_zero:
1057 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1058 ; X86-NEXT: vminpd %xmm0, %xmm1, %xmm0
1060 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double 0., double 0.>)
1064 define <4 x float> @test_fmaximum_vector_signed_zero(<4 x float> %x) {
1065 ; SSE2-LABEL: test_fmaximum_vector_signed_zero:
1067 ; SSE2-NEXT: movaps {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1068 ; SSE2-NEXT: maxps %xmm0, %xmm1
1069 ; SSE2-NEXT: movaps %xmm1, %xmm0
1072 ; AVX-LABEL: test_fmaximum_vector_signed_zero:
1074 ; AVX-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1075 ; AVX-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1078 ; X86-LABEL: test_fmaximum_vector_signed_zero:
1080 ; X86-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1081 ; X86-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1083 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> <float -0., float -0., float -0., float -0.>)
1087 define <2 x double> @test_fminimum_vector_partially_zero(<2 x double> %x) {
1088 ; SSE2-LABEL: test_fminimum_vector_partially_zero:
1090 ; SSE2-NEXT: xorpd %xmm1, %xmm1
1091 ; SSE2-NEXT: movhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1092 ; SSE2-NEXT: minpd %xmm0, %xmm1
1093 ; SSE2-NEXT: movapd %xmm1, %xmm0
1096 ; AVX-LABEL: test_fminimum_vector_partially_zero:
1098 ; AVX-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1099 ; AVX-NEXT: vmovhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1100 ; AVX-NEXT: vminpd %xmm0, %xmm1, %xmm0
1103 ; X86-LABEL: test_fminimum_vector_partially_zero:
1105 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1106 ; X86-NEXT: vmovhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1107 ; X86-NEXT: vminpd %xmm0, %xmm1, %xmm0
1109 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double 0., double 5.>)
1113 define <2 x double> @test_fminimum_vector_different_zeros(<2 x double> %x) {
1114 ; SSE2-LABEL: test_fminimum_vector_different_zeros:
1116 ; SSE2-NEXT: movaps %xmm0, %xmm1
1117 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,1],xmm0[3,3]
1118 ; SSE2-NEXT: xorps %xmm2, %xmm2
1119 ; SSE2-NEXT: pxor %xmm3, %xmm3
1120 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm3
1121 ; SSE2-NEXT: movhps {{.*#+}} xmm2 = xmm2[0,1],mem[0,1]
1122 ; SSE2-NEXT: movdqa %xmm3, %xmm1
1123 ; SSE2-NEXT: pandn %xmm2, %xmm1
1124 ; SSE2-NEXT: movaps %xmm0, %xmm4
1125 ; SSE2-NEXT: andps %xmm3, %xmm4
1126 ; SSE2-NEXT: orps %xmm1, %xmm4
1127 ; SSE2-NEXT: pand %xmm0, %xmm2
1128 ; SSE2-NEXT: pandn %xmm0, %xmm3
1129 ; SSE2-NEXT: por %xmm2, %xmm3
1130 ; SSE2-NEXT: movdqa %xmm3, %xmm1
1131 ; SSE2-NEXT: minpd %xmm4, %xmm1
1132 ; SSE2-NEXT: movdqa %xmm3, %xmm0
1133 ; SSE2-NEXT: cmpunordpd %xmm3, %xmm0
1134 ; SSE2-NEXT: andpd %xmm0, %xmm3
1135 ; SSE2-NEXT: andnpd %xmm1, %xmm0
1136 ; SSE2-NEXT: orpd %xmm3, %xmm0
1139 ; AVX-LABEL: test_fminimum_vector_different_zeros:
1141 ; AVX-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1142 ; AVX-NEXT: vmovhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1143 ; AVX-NEXT: vblendvpd %xmm0, %xmm0, %xmm1, %xmm2
1144 ; AVX-NEXT: vblendvpd %xmm0, %xmm1, %xmm0, %xmm0
1145 ; AVX-NEXT: vminpd %xmm2, %xmm0, %xmm1
1146 ; AVX-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm2
1147 ; AVX-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
1150 ; X86-LABEL: test_fminimum_vector_different_zeros:
1152 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1153 ; X86-NEXT: vmovhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1154 ; X86-NEXT: vblendvpd %xmm0, %xmm0, %xmm1, %xmm2
1155 ; X86-NEXT: vblendvpd %xmm0, %xmm1, %xmm0, %xmm0
1156 ; X86-NEXT: vminpd %xmm2, %xmm0, %xmm1
1157 ; X86-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm2
1158 ; X86-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm0
1160 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double 0., double -0.>)
1164 define <4 x float> @test_fmaximum_vector_non_zero(<4 x float> %x) {
1165 ; SSE2-LABEL: test_fmaximum_vector_non_zero:
1167 ; SSE2-NEXT: movaps {{.*#+}} xmm1 = [5.0E+0,4.0E+0,3.0E+0,2.0E+0]
1168 ; SSE2-NEXT: maxps %xmm0, %xmm1
1169 ; SSE2-NEXT: movaps %xmm1, %xmm0
1172 ; AVX-LABEL: test_fmaximum_vector_non_zero:
1174 ; AVX-NEXT: vmovaps {{.*#+}} xmm1 = [5.0E+0,4.0E+0,3.0E+0,2.0E+0]
1175 ; AVX-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1178 ; X86-LABEL: test_fmaximum_vector_non_zero:
1180 ; X86-NEXT: vmovaps {{.*#+}} xmm1 = [5.0E+0,4.0E+0,3.0E+0,2.0E+0]
1181 ; X86-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1183 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> <float 5., float 4., float 3., float 2.>)
1187 define <2 x double> @test_fminimum_vector_nan(<2 x double> %x) {
1188 ; SSE2-LABEL: test_fminimum_vector_nan:
1190 ; SSE2-NEXT: movsd {{.*#+}} xmm2 = [NaN,0.0E+0]
1191 ; SSE2-NEXT: xorpd %xmm1, %xmm1
1192 ; SSE2-NEXT: unpcklpd {{.*#+}} xmm1 = xmm1[0],xmm2[0]
1193 ; SSE2-NEXT: minpd %xmm0, %xmm1
1194 ; SSE2-NEXT: unpcklpd {{.*#+}} xmm1 = xmm1[0],xmm2[0]
1195 ; SSE2-NEXT: movapd %xmm1, %xmm0
1198 ; AVX-LABEL: test_fminimum_vector_nan:
1200 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = [NaN,0.0E+0]
1201 ; AVX-NEXT: vxorpd %xmm2, %xmm2, %xmm2
1202 ; AVX-NEXT: vunpcklpd {{.*#+}} xmm2 = xmm2[0],xmm1[0]
1203 ; AVX-NEXT: vminpd %xmm0, %xmm2, %xmm0
1204 ; AVX-NEXT: vunpcklpd {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1207 ; X86-LABEL: test_fminimum_vector_nan:
1209 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1210 ; X86-NEXT: vmovhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
1211 ; X86-NEXT: vminpd %xmm0, %xmm1, %xmm0
1212 ; X86-NEXT: vcmpunordpd %xmm1, %xmm1, %xmm2
1213 ; X86-NEXT: vblendvpd %xmm2, %xmm1, %xmm0, %xmm0
1215 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double 0., double 0x7fff000000000000>)
1219 define <2 x double> @test_fminimum_vector_zero_first(<2 x double> %x) {
1220 ; SSE2-LABEL: test_fminimum_vector_zero_first:
1222 ; SSE2-NEXT: xorpd %xmm1, %xmm1
1223 ; SSE2-NEXT: minpd %xmm0, %xmm1
1224 ; SSE2-NEXT: movapd %xmm1, %xmm0
1227 ; AVX-LABEL: test_fminimum_vector_zero_first:
1229 ; AVX-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1230 ; AVX-NEXT: vminpd %xmm0, %xmm1, %xmm0
1233 ; X86-LABEL: test_fminimum_vector_zero_first:
1235 ; X86-NEXT: vxorpd %xmm1, %xmm1, %xmm1
1236 ; X86-NEXT: vminpd %xmm0, %xmm1, %xmm0
1238 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> <double 0., double 0.>, <2 x double> %x)
1242 define <2 x double> @test_fminimum_vector_signed_zero(<2 x double> %x) {
1243 ; SSE2-LABEL: test_fminimum_vector_signed_zero:
1245 ; SSE2-NEXT: movapd %xmm0, %xmm1
1246 ; SSE2-NEXT: minpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1247 ; SSE2-NEXT: movapd %xmm0, %xmm2
1248 ; SSE2-NEXT: cmpunordpd %xmm0, %xmm2
1249 ; SSE2-NEXT: andpd %xmm2, %xmm0
1250 ; SSE2-NEXT: andnpd %xmm1, %xmm2
1251 ; SSE2-NEXT: orpd %xmm2, %xmm0
1254 ; AVX-LABEL: test_fminimum_vector_signed_zero:
1256 ; AVX-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm1
1257 ; AVX-NEXT: vminpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm2
1258 ; AVX-NEXT: vblendvpd %xmm1, %xmm0, %xmm2, %xmm0
1261 ; X86-LABEL: test_fminimum_vector_signed_zero:
1263 ; X86-NEXT: vcmpunordpd %xmm0, %xmm0, %xmm1
1264 ; X86-NEXT: vminpd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm2
1265 ; X86-NEXT: vblendvpd %xmm1, %xmm0, %xmm2, %xmm0
1267 %r = call <2 x double> @llvm.minimum.v2f64(<2 x double> %x, <2 x double> <double -0., double -0.>)
1271 define <4 x float> @test_fmaximum_vector_signed_zero_first(<4 x float> %x) {
1272 ; SSE2-LABEL: test_fmaximum_vector_signed_zero_first:
1274 ; SSE2-NEXT: movaps {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1275 ; SSE2-NEXT: maxps %xmm0, %xmm1
1276 ; SSE2-NEXT: movaps %xmm1, %xmm0
1279 ; AVX-LABEL: test_fmaximum_vector_signed_zero_first:
1281 ; AVX-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1282 ; AVX-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1285 ; X86-LABEL: test_fmaximum_vector_signed_zero_first:
1287 ; X86-NEXT: vbroadcastss {{.*#+}} xmm1 = [-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
1288 ; X86-NEXT: vmaxps %xmm0, %xmm1, %xmm0
1290 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> <float -0., float -0., float -0., float -0.>, <4 x float> %x)
1294 define <4 x float> @test_fmaximum_vector_zero(<4 x float> %x) {
1295 ; SSE2-LABEL: test_fmaximum_vector_zero:
1297 ; SSE2-NEXT: xorps %xmm1, %xmm1
1298 ; SSE2-NEXT: movaps %xmm0, %xmm2
1299 ; SSE2-NEXT: maxps %xmm1, %xmm2
1300 ; SSE2-NEXT: movaps %xmm0, %xmm1
1301 ; SSE2-NEXT: cmpunordps %xmm0, %xmm1
1302 ; SSE2-NEXT: andps %xmm1, %xmm0
1303 ; SSE2-NEXT: andnps %xmm2, %xmm1
1304 ; SSE2-NEXT: orps %xmm1, %xmm0
1307 ; AVX-LABEL: test_fmaximum_vector_zero:
1309 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
1310 ; AVX-NEXT: vmaxps %xmm1, %xmm0, %xmm1
1311 ; AVX-NEXT: vcmpunordps %xmm0, %xmm0, %xmm2
1312 ; AVX-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
1315 ; X86-LABEL: test_fmaximum_vector_zero:
1317 ; X86-NEXT: vxorps %xmm1, %xmm1, %xmm1
1318 ; X86-NEXT: vmaxps %xmm1, %xmm0, %xmm1
1319 ; X86-NEXT: vcmpunordps %xmm0, %xmm0, %xmm2
1320 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
1322 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> <float 0., float 0., float 0., float 0.>)
1326 ; PR77805: Check that signed zeroes are handled correctly in this case (FIXME)
1327 define <4 x float> @test_fmaximum_v4f32_splat(<4 x float> %x, float %y) {
1328 ; SSE2-LABEL: test_fmaximum_v4f32_splat:
1330 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
1331 ; SSE2-NEXT: pxor %xmm2, %xmm2
1332 ; SSE2-NEXT: pcmpgtd %xmm0, %xmm2
1333 ; SSE2-NEXT: movdqa %xmm2, %xmm3
1334 ; SSE2-NEXT: pandn %xmm0, %xmm3
1335 ; SSE2-NEXT: movaps %xmm1, %xmm4
1336 ; SSE2-NEXT: andps %xmm2, %xmm4
1337 ; SSE2-NEXT: orps %xmm3, %xmm4
1338 ; SSE2-NEXT: pand %xmm2, %xmm0
1339 ; SSE2-NEXT: andnps %xmm1, %xmm2
1340 ; SSE2-NEXT: por %xmm2, %xmm0
1341 ; SSE2-NEXT: movdqa %xmm0, %xmm1
1342 ; SSE2-NEXT: maxps %xmm4, %xmm1
1343 ; SSE2-NEXT: movdqa %xmm0, %xmm2
1344 ; SSE2-NEXT: cmpunordps %xmm0, %xmm2
1345 ; SSE2-NEXT: andps %xmm2, %xmm0
1346 ; SSE2-NEXT: andnps %xmm1, %xmm2
1347 ; SSE2-NEXT: orps %xmm2, %xmm0
1350 ; AVX1-LABEL: test_fmaximum_v4f32_splat:
1352 ; AVX1-NEXT: vshufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
1353 ; AVX1-NEXT: vblendvps %xmm0, %xmm1, %xmm0, %xmm2
1354 ; AVX1-NEXT: vblendvps %xmm0, %xmm0, %xmm1, %xmm0
1355 ; AVX1-NEXT: vmaxps %xmm2, %xmm0, %xmm1
1356 ; AVX1-NEXT: vcmpunordps %xmm0, %xmm0, %xmm2
1357 ; AVX1-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
1360 ; AVX512-LABEL: test_fmaximum_v4f32_splat:
1362 ; AVX512-NEXT: vbroadcastss %xmm1, %xmm1
1363 ; AVX512-NEXT: vblendvps %xmm0, %xmm1, %xmm0, %xmm2
1364 ; AVX512-NEXT: vblendvps %xmm0, %xmm0, %xmm1, %xmm0
1365 ; AVX512-NEXT: vmaxps %xmm2, %xmm0, %xmm1
1366 ; AVX512-NEXT: vcmpunordps %xmm0, %xmm0, %xmm2
1367 ; AVX512-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
1370 ; X86-LABEL: test_fmaximum_v4f32_splat:
1372 ; X86-NEXT: vbroadcastss {{[0-9]+}}(%esp), %xmm1
1373 ; X86-NEXT: vblendvps %xmm0, %xmm1, %xmm0, %xmm2
1374 ; X86-NEXT: vblendvps %xmm0, %xmm0, %xmm1, %xmm0
1375 ; X86-NEXT: vmaxps %xmm2, %xmm0, %xmm1
1376 ; X86-NEXT: vcmpunordps %xmm0, %xmm0, %xmm2
1377 ; X86-NEXT: vblendvps %xmm2, %xmm0, %xmm1, %xmm0
1379 %splatinsert = insertelement <4 x float> poison, float %y, i64 0
1380 %vec = shufflevector <4 x float> %splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
1381 %r = call <4 x float> @llvm.maximum.v4f32(<4 x float> %x, <4 x float> %vec) readnone