1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=ANY,STRICT
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math | FileCheck %s --check-prefixes=ANY,UNSAFE
5 define float @fadd_zero(float %x) {
6 ; STRICT-LABEL: fadd_zero:
8 ; STRICT-NEXT: xorps %xmm1, %xmm1
9 ; STRICT-NEXT: addss %xmm1, %xmm0
12 ; UNSAFE-LABEL: fadd_zero:
15 %r = fadd float %x, 0.0
19 define float @fadd_negzero(float %x) {
20 ; ANY-LABEL: fadd_negzero:
23 %r = fadd float %x, -0.0
27 define float @fadd_produce_zero(float %x) {
28 ; ANY-LABEL: fadd_produce_zero:
30 ; ANY-NEXT: xorps %xmm0, %xmm0
32 %neg = fsub nsz float 0.0, %x
33 %r = fadd nnan float %neg, %x
37 define float @fadd_reassociate(float %x) {
38 ; ANY-LABEL: fadd_reassociate:
40 ; ANY-NEXT: addss {{.*}}(%rip), %xmm0
42 %sum = fadd float %x, 8.0
43 %r = fadd reassoc nsz float %sum, 12.0
47 define float @fadd_negzero_nsz(float %x) {
48 ; ANY-LABEL: fadd_negzero_nsz:
51 %r = fadd nsz float %x, -0.0
55 define float @fadd_zero_nsz(float %x) {
56 ; ANY-LABEL: fadd_zero_nsz:
59 %r = fadd nsz float %x, 0.0
63 define float @fsub_zero(float %x) {
64 ; ANY-LABEL: fsub_zero:
67 %r = fsub float %x, 0.0
71 define float @fsub_self(float %x) {
72 ; ANY-LABEL: fsub_self:
74 ; ANY-NEXT: xorps %xmm0, %xmm0
76 %r = fsub nnan float %x, %x
80 define float @fsub_neg_x_y(float %x, float %y) {
81 ; ANY-LABEL: fsub_neg_x_y:
83 ; ANY-NEXT: subss %xmm0, %xmm1
84 ; ANY-NEXT: movaps %xmm1, %xmm0
86 %neg = fsub nsz float 0.0, %x
87 %r = fadd nsz float %neg, %y
91 define float @fsub_neg_y(float %x, float %y) {
92 ; ANY-LABEL: fsub_neg_y:
94 ; ANY-NEXT: mulss {{.*}}(%rip), %xmm0
96 %mul = fmul float %x, 5.0
97 %add = fadd float %mul, %y
98 %r = fsub nsz reassoc float %y, %add
102 define <4 x float> @fsub_neg_y_vector(<4 x float> %x, <4 x float> %y) {
103 ; ANY-LABEL: fsub_neg_y_vector:
105 ; ANY-NEXT: mulps {{.*}}(%rip), %xmm0
107 %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
108 %add = fadd <4 x float> %mul, %y
109 %r = fsub nsz reassoc <4 x float> %y, %add
113 define <4 x float> @fsub_neg_y_vector_nonuniform(<4 x float> %x, <4 x float> %y) {
114 ; ANY-LABEL: fsub_neg_y_vector_nonuniform:
116 ; ANY-NEXT: mulps {{.*}}(%rip), %xmm0
118 %mul = fmul <4 x float> %x, <float 5.0, float 6.0, float 7.0, float 8.0>
119 %add = fadd <4 x float> %mul, %y
120 %r = fsub nsz reassoc <4 x float> %y, %add
124 define float @fsub_neg_y_commute(float %x, float %y) {
125 ; ANY-LABEL: fsub_neg_y_commute:
127 ; ANY-NEXT: mulss {{.*}}(%rip), %xmm0
129 %mul = fmul float %x, 5.0
130 %add = fadd float %y, %mul
131 %r = fsub nsz reassoc float %y, %add
135 define <4 x float> @fsub_neg_y_commute_vector(<4 x float> %x, <4 x float> %y) {
136 ; ANY-LABEL: fsub_neg_y_commute_vector:
138 ; ANY-NEXT: mulps {{.*}}(%rip), %xmm0
140 %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
141 %add = fadd <4 x float> %y, %mul
142 %r = fsub nsz reassoc <4 x float> %y, %add
148 define float @fsub_fadd_common_op_fneg(float %x, float %y) {
149 ; ANY-LABEL: fsub_fadd_common_op_fneg:
151 ; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
153 %a = fadd float %x, %y
154 %r = fsub reassoc nsz float %y, %a
160 define <4 x float> @fsub_fadd_common_op_fneg_vec(<4 x float> %x, <4 x float> %y) {
161 ; ANY-LABEL: fsub_fadd_common_op_fneg_vec:
163 ; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
165 %a = fadd <4 x float> %x, %y
166 %r = fsub nsz reassoc <4 x float> %y, %a
171 ; Commute operands of the 'add'.
173 define float @fsub_fadd_common_op_fneg_commute(float %x, float %y) {
174 ; ANY-LABEL: fsub_fadd_common_op_fneg_commute:
176 ; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
178 %a = fadd float %y, %x
179 %r = fsub reassoc nsz float %y, %a
185 define <4 x float> @fsub_fadd_common_op_fneg_commute_vec(<4 x float> %x, <4 x float> %y) {
186 ; ANY-LABEL: fsub_fadd_common_op_fneg_commute_vec:
188 ; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
190 %a = fadd <4 x float> %y, %x
191 %r = fsub reassoc nsz <4 x float> %y, %a
195 define float @fsub_negzero(float %x) {
196 ; STRICT-LABEL: fsub_negzero:
198 ; STRICT-NEXT: xorps %xmm1, %xmm1
199 ; STRICT-NEXT: addss %xmm1, %xmm0
202 ; UNSAFE-LABEL: fsub_negzero:
205 %r = fsub float %x, -0.0
209 define <4 x float> @fsub_negzero_vector(<4 x float> %x) {
210 ; STRICT-LABEL: fsub_negzero_vector:
212 ; STRICT-NEXT: xorps %xmm1, %xmm1
213 ; STRICT-NEXT: addps %xmm1, %xmm0
216 ; UNSAFE-LABEL: fsub_negzero_vector:
219 %r = fsub <4 x float> %x, <float -0.0, float -0.0, float -0.0, float -0.0>
223 define float @fsub_zero_nsz_1(float %x) {
224 ; ANY-LABEL: fsub_zero_nsz_1:
227 %r = fsub nsz float %x, 0.0
231 define float @fsub_zero_nsz_2(float %x) {
232 ; ANY-LABEL: fsub_zero_nsz_2:
234 ; ANY-NEXT: xorps {{.*}}(%rip), %xmm0
236 %r = fsub nsz float 0.0, %x
240 define float @fsub_negzero_nsz(float %x) {
241 ; ANY-LABEL: fsub_negzero_nsz:
244 %r = fsub nsz float %x, -0.0
248 define float @fmul_zero(float %x) {
249 ; ANY-LABEL: fmul_zero:
251 ; ANY-NEXT: xorps %xmm0, %xmm0
253 %r = fmul nnan nsz float %x, 0.0
257 define float @fmul_one(float %x) {
258 ; ANY-LABEL: fmul_one:
261 %r = fmul float %x, 1.0
265 define float @fmul_x_const_const(float %x) {
266 ; ANY-LABEL: fmul_x_const_const:
268 ; ANY-NEXT: mulss {{.*}}(%rip), %xmm0
270 %mul = fmul reassoc float %x, 9.0
271 %r = fmul reassoc float %mul, 4.0