1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64 -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -mattr=+avx512fp16 | FileCheck %s --check-prefix=CHECK_UNSAFE
3 ; RUN: llc < %s -mtriple=x86_64 -mattr=+avx512fp16 | FileCheck %s --check-prefix=CHECK
5 define <32 x half> @test_max_v32f16(ptr %a_ptr, <32 x half> %b) {
6 ; CHECK_UNSAFE-LABEL: test_max_v32f16:
7 ; CHECK_UNSAFE: # %bb.0:
8 ; CHECK_UNSAFE-NEXT: vmaxph (%rdi), %zmm0, %zmm0
9 ; CHECK_UNSAFE-NEXT: retq
11 ; CHECK-LABEL: test_max_v32f16:
13 ; CHECK-NEXT: vmovaps (%rdi), %zmm1
14 ; CHECK-NEXT: vmaxph %zmm0, %zmm1, %zmm0
16 %a = load <32 x half>, ptr %a_ptr
17 %tmp = fcmp fast ogt <32 x half> %a, %b
18 %tmp4 = select <32 x i1> %tmp, <32 x half> %a, <32 x half> %b
19 ret <32 x half> %tmp4;
22 define <32 x half> @test_min_v32f16(ptr %a_ptr, <32 x half> %b) {
23 ; CHECK_UNSAFE-LABEL: test_min_v32f16:
24 ; CHECK_UNSAFE: # %bb.0:
25 ; CHECK_UNSAFE-NEXT: vminph (%rdi), %zmm0, %zmm0
26 ; CHECK_UNSAFE-NEXT: retq
28 ; CHECK-LABEL: test_min_v32f16:
30 ; CHECK-NEXT: vmovaps (%rdi), %zmm1
31 ; CHECK-NEXT: vminph %zmm0, %zmm1, %zmm0
33 %a = load <32 x half>, ptr %a_ptr
34 %tmp = fcmp fast olt <32 x half> %a, %b
35 %tmp4 = select <32 x i1> %tmp, <32 x half> %a, <32 x half> %b
36 ret <32 x half> %tmp4;
39 define <16 x half> @test_max_v16f16(ptr %a_ptr, <16 x half> %b) {
40 ; CHECK_UNSAFE-LABEL: test_max_v16f16:
41 ; CHECK_UNSAFE: # %bb.0:
42 ; CHECK_UNSAFE-NEXT: vmaxph (%rdi), %ymm0, %ymm0
43 ; CHECK_UNSAFE-NEXT: retq
45 ; CHECK-LABEL: test_max_v16f16:
47 ; CHECK-NEXT: vmovaps (%rdi), %ymm1
48 ; CHECK-NEXT: vmaxph %ymm0, %ymm1, %ymm0
50 %a = load <16 x half>, ptr %a_ptr
51 %tmp = fcmp fast ogt <16 x half> %a, %b
52 %tmp4 = select <16 x i1> %tmp, <16 x half> %a, <16 x half> %b
53 ret <16 x half> %tmp4;
56 define <16 x half> @test_min_v16f16(ptr %a_ptr, <16 x half> %b) {
57 ; CHECK_UNSAFE-LABEL: test_min_v16f16:
58 ; CHECK_UNSAFE: # %bb.0:
59 ; CHECK_UNSAFE-NEXT: vminph (%rdi), %ymm0, %ymm0
60 ; CHECK_UNSAFE-NEXT: retq
62 ; CHECK-LABEL: test_min_v16f16:
64 ; CHECK-NEXT: vmovaps (%rdi), %ymm1
65 ; CHECK-NEXT: vminph %ymm0, %ymm1, %ymm0
67 %a = load <16 x half>, ptr %a_ptr
68 %tmp = fcmp fast olt <16 x half> %a, %b
69 %tmp4 = select <16 x i1> %tmp, <16 x half> %a, <16 x half> %b
70 ret <16 x half> %tmp4;
73 define <8 x half> @test_max_v8f16(ptr %a_ptr, <8 x half> %b) {
74 ; CHECK_UNSAFE-LABEL: test_max_v8f16:
75 ; CHECK_UNSAFE: # %bb.0:
76 ; CHECK_UNSAFE-NEXT: vmaxph (%rdi), %xmm0, %xmm0
77 ; CHECK_UNSAFE-NEXT: retq
79 ; CHECK-LABEL: test_max_v8f16:
81 ; CHECK-NEXT: vmovaps (%rdi), %xmm1
82 ; CHECK-NEXT: vmaxph %xmm0, %xmm1, %xmm0
84 %a = load <8 x half>, ptr %a_ptr
85 %tmp = fcmp fast ogt <8 x half> %a, %b
86 %tmp4 = select <8 x i1> %tmp, <8 x half> %a, <8 x half> %b
90 define <8 x half> @test_min_v8f16(ptr %a_ptr, <8 x half> %b) {
91 ; CHECK_UNSAFE-LABEL: test_min_v8f16:
92 ; CHECK_UNSAFE: # %bb.0:
93 ; CHECK_UNSAFE-NEXT: vminph (%rdi), %xmm0, %xmm0
94 ; CHECK_UNSAFE-NEXT: retq
96 ; CHECK-LABEL: test_min_v8f16:
98 ; CHECK-NEXT: vmovaps (%rdi), %xmm1
99 ; CHECK-NEXT: vminph %xmm0, %xmm1, %xmm0
101 %a = load <8 x half>, ptr %a_ptr
102 %tmp = fcmp fast olt <8 x half> %a, %b
103 %tmp4 = select <8 x i1> %tmp, <8 x half> %a, <8 x half> %b
104 ret <8 x half> %tmp4;
107 define half @test_max_f16(half %a, ptr %ptr) {
108 ; CHECK_UNSAFE-LABEL: test_max_f16:
109 ; CHECK_UNSAFE: # %bb.0: # %entry
110 ; CHECK_UNSAFE-NEXT: vmaxsh (%rdi), %xmm0, %xmm0
111 ; CHECK_UNSAFE-NEXT: retq
113 ; CHECK-LABEL: test_max_f16:
114 ; CHECK: # %bb.0: # %entry
115 ; CHECK-NEXT: vmovsh (%rdi), %xmm1
116 ; CHECK-NEXT: vmaxsh %xmm0, %xmm1, %xmm0
119 %0 = load half, ptr %ptr
120 %1 = fcmp fast ogt half %0, %a
121 %2 = select i1 %1, half %0, half %a
125 define half @test_min_f16(half %a, ptr %ptr) {
126 ; CHECK_UNSAFE-LABEL: test_min_f16:
127 ; CHECK_UNSAFE: # %bb.0: # %entry
128 ; CHECK_UNSAFE-NEXT: vminsh (%rdi), %xmm0, %xmm0
129 ; CHECK_UNSAFE-NEXT: retq
131 ; CHECK-LABEL: test_min_f16:
132 ; CHECK: # %bb.0: # %entry
133 ; CHECK-NEXT: vmovsh (%rdi), %xmm1
134 ; CHECK-NEXT: vminsh %xmm0, %xmm1, %xmm0
137 %0 = load half, ptr %ptr
138 %1 = fcmp fast olt half %0, %a
139 %2 = select i1 %1, half %0, half %a