1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -verify-machineinstrs -mtriple=x86_64-unknown-unknown -mattr=+avx512fp16 | FileCheck %s
4 declare half @llvm.minimum.f16(half, half)
5 declare half @llvm.maximum.f16(half, half)
6 declare <8 x half> @llvm.minimum.v8f16(<8 x half>, <8 x half>)
7 declare <8 x half> @llvm.maximum.v8f16(<8 x half>, <8 x half>)
9 define half @test_fminimum(half %x, half %y) {
10 ; CHECK-LABEL: test_fminimum:
12 ; CHECK-NEXT: vmovw %xmm0, %eax
13 ; CHECK-NEXT: testw %ax, %ax
14 ; CHECK-NEXT: sets %al
15 ; CHECK-NEXT: kmovd %eax, %k1
16 ; CHECK-NEXT: vmovaps %xmm1, %xmm2
17 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm2 {%k1}
18 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
19 ; CHECK-NEXT: vminsh %xmm2, %xmm0, %xmm1
20 ; CHECK-NEXT: vcmpunordsh %xmm0, %xmm0, %k1
21 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
22 ; CHECK-NEXT: vmovaps %xmm1, %xmm0
24 %z = call half @llvm.minimum.f16(half %x, half %y)
28 define <8 x half> @test_fminimum_scalarize(<8 x half> %x, <8 x half> %y) "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {
29 ; CHECK-LABEL: test_fminimum_scalarize:
31 ; CHECK-NEXT: vcmpltph %xmm1, %xmm0, %k1
32 ; CHECK-NEXT: vpblendmw %xmm0, %xmm1, %xmm2 {%k1}
33 ; CHECK-NEXT: vpbroadcastw {{.*#+}} xmm3 = [32768,32768,32768,32768,32768,32768,32768,32768]
34 ; CHECK-NEXT: vpcmpeqw %xmm3, %xmm0, %k1
35 ; CHECK-NEXT: vpblendmw %xmm0, %xmm2, %xmm0 {%k1}
36 ; CHECK-NEXT: vpcmpeqw %xmm3, %xmm1, %k1
37 ; CHECK-NEXT: vmovdqu16 %xmm1, %xmm0 {%k1}
38 ; CHECK-NEXT: vxorps %xmm1, %xmm1, %xmm1
39 ; CHECK-NEXT: vcmpeqph %xmm1, %xmm2, %k1
40 ; CHECK-NEXT: vmovdqu16 %xmm0, %xmm2 {%k1}
41 ; CHECK-NEXT: vmovdqa %xmm2, %xmm0
43 %r = call <8 x half> @llvm.minimum.v8f16(<8 x half> %x, <8 x half> %y)
47 define half @test_fminimum_nnan(half %x, half %y) "no-nans-fp-math"="true" {
48 ; CHECK-LABEL: test_fminimum_nnan:
50 ; CHECK-NEXT: vfpclasssh $5, %xmm1, %k1
51 ; CHECK-NEXT: vmovaps %xmm0, %xmm2
52 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm2 {%k1}
53 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
54 ; CHECK-NEXT: vminsh %xmm2, %xmm1, %xmm0
56 %1 = tail call half @llvm.minimum.f16(half %x, half %y)
60 define half @test_fminimum_zero(half %x, half %y) {
61 ; CHECK-LABEL: test_fminimum_zero:
63 ; CHECK-NEXT: vcmpunordsh %xmm1, %xmm1, %k1
64 ; CHECK-NEXT: vminsh {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0
65 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
67 %1 = tail call half @llvm.minimum.f16(half -0.0, half %y)
71 define half @test_fminimum_nsz(half %x, half %y) {
72 ; CHECK-LABEL: test_fminimum_nsz:
74 ; CHECK-NEXT: vminsh %xmm1, %xmm0, %xmm1
75 ; CHECK-NEXT: vcmpunordsh %xmm0, %xmm0, %k1
76 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
77 ; CHECK-NEXT: vmovaps %xmm1, %xmm0
79 %1 = tail call nsz half @llvm.minimum.f16(half %x, half %y)
83 define half @test_fminimum_combine_cmps(half %x, half %y) {
84 ; CHECK-LABEL: test_fminimum_combine_cmps:
86 ; CHECK-NEXT: vdivsh %xmm0, %xmm1, %xmm1
87 ; CHECK-NEXT: vfpclasssh $5, %xmm0, %k1
88 ; CHECK-NEXT: vmovaps %xmm1, %xmm2
89 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm2 {%k1}
90 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
91 ; CHECK-NEXT: vminsh %xmm2, %xmm0, %xmm0
93 %1 = fdiv nnan half %y, %x
94 %2 = tail call half @llvm.minimum.f16(half %x, half %1)
98 define half @test_fmaximum(half %x, half %y) {
99 ; CHECK-LABEL: test_fmaximum:
101 ; CHECK-NEXT: vmovw %xmm0, %eax
102 ; CHECK-NEXT: testw %ax, %ax
103 ; CHECK-NEXT: sets %al
104 ; CHECK-NEXT: kmovd %eax, %k1
105 ; CHECK-NEXT: vmovaps %xmm0, %xmm2
106 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm2 {%k1}
107 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
108 ; CHECK-NEXT: vmaxsh %xmm2, %xmm1, %xmm0
109 ; CHECK-NEXT: vcmpunordsh %xmm1, %xmm1, %k1
110 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
112 %r = call half @llvm.maximum.f16(half %x, half %y)
116 define <8 x half> @test_fmaximum_scalarize(<8 x half> %x, <8 x half> %y) "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {
117 ; CHECK-LABEL: test_fmaximum_scalarize:
119 ; CHECK-NEXT: vcmpltph %xmm0, %xmm1, %k1
120 ; CHECK-NEXT: vpblendmw %xmm0, %xmm1, %xmm2 {%k1}
121 ; CHECK-NEXT: vptestnmw %xmm0, %xmm0, %k1
122 ; CHECK-NEXT: vpblendmw %xmm0, %xmm2, %xmm0 {%k1}
123 ; CHECK-NEXT: vptestnmw %xmm1, %xmm1, %k1
124 ; CHECK-NEXT: vmovdqu16 %xmm1, %xmm0 {%k1}
125 ; CHECK-NEXT: vxorps %xmm1, %xmm1, %xmm1
126 ; CHECK-NEXT: vcmpeqph %xmm1, %xmm2, %k1
127 ; CHECK-NEXT: vmovdqu16 %xmm0, %xmm2 {%k1}
128 ; CHECK-NEXT: vmovdqa %xmm2, %xmm0
130 %r = call <8 x half> @llvm.maximum.v8f16(<8 x half> %x, <8 x half> %y)
134 define half @test_fmaximum_nnan(half %x, half %y) {
135 ; CHECK-LABEL: test_fmaximum_nnan:
137 ; CHECK-NEXT: vaddsh %xmm1, %xmm0, %xmm2
138 ; CHECK-NEXT: vsubsh %xmm1, %xmm0, %xmm0
139 ; CHECK-NEXT: vfpclasssh $3, %xmm0, %k1
140 ; CHECK-NEXT: vmovaps %xmm2, %xmm1
141 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
142 ; CHECK-NEXT: vmovsh %xmm2, %xmm0, %xmm0 {%k1}
143 ; CHECK-NEXT: vmaxsh %xmm1, %xmm0, %xmm0
145 %1 = fadd nnan half %x, %y
146 %2 = fsub nnan half %x, %y
147 %3 = tail call half @llvm.maximum.f16(half %1, half %2)
151 define half @test_fmaximum_zero(half %x, half %y) {
152 ; CHECK-LABEL: test_fmaximum_zero:
154 ; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0
155 ; CHECK-NEXT: vmaxsh %xmm0, %xmm1, %xmm0
156 ; CHECK-NEXT: vcmpunordsh %xmm1, %xmm1, %k1
157 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
159 %1 = tail call half @llvm.maximum.f16(half 0.0, half %y)
163 define half @test_fmaximum_nsz(half %x, half %y) "no-signed-zeros-fp-math"="true" {
164 ; CHECK-LABEL: test_fmaximum_nsz:
166 ; CHECK-NEXT: vmaxsh %xmm1, %xmm0, %xmm1
167 ; CHECK-NEXT: vcmpunordsh %xmm0, %xmm0, %k1
168 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm1 {%k1}
169 ; CHECK-NEXT: vmovaps %xmm1, %xmm0
171 %1 = tail call half @llvm.maximum.f16(half %x, half %y)
175 define half @test_fmaximum_combine_cmps(half %x, half %y) {
176 ; CHECK-LABEL: test_fmaximum_combine_cmps:
178 ; CHECK-NEXT: vdivsh %xmm0, %xmm1, %xmm1
179 ; CHECK-NEXT: vfpclasssh $3, %xmm0, %k1
180 ; CHECK-NEXT: vmovaps %xmm1, %xmm2
181 ; CHECK-NEXT: vmovsh %xmm0, %xmm0, %xmm2 {%k1}
182 ; CHECK-NEXT: vmovsh %xmm1, %xmm0, %xmm0 {%k1}
183 ; CHECK-NEXT: vmaxsh %xmm2, %xmm0, %xmm0
185 %1 = fdiv nnan half %y, %x
186 %2 = tail call half @llvm.maximum.f16(half %x, half %1)