1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
3 define float @fadd_zero_strict(float %x) {
4 ; CHECK-LABEL: fadd_zero_strict:
6 ; CHECK-NEXT: xorps %xmm1, %xmm1
7 ; CHECK-NEXT: addss %xmm1, %xmm0
9 %r = fadd float %x, 0.0
13 define float @fadd_negzero(float %x) {
14 ; CHECK-LABEL: fadd_negzero:
17 %r = fadd float %x, -0.0
21 define float @fadd_produce_zero(float %x) {
22 ; CHECK-LABEL: fadd_produce_zero:
24 ; CHECK-NEXT: xorps %xmm0, %xmm0
26 %neg = fsub nsz float 0.0, %x
27 %r = fadd nnan float %neg, %x
31 define float @fadd_reassociate(float %x) {
32 ; CHECK-LABEL: fadd_reassociate:
34 ; CHECK-NEXT: addss {{.*}}(%rip), %xmm0
36 %sum = fadd float %x, 8.0
37 %r = fadd reassoc nsz float %sum, 12.0
41 define float @fadd_negzero_nsz(float %x) {
42 ; CHECK-LABEL: fadd_negzero_nsz:
45 %r = fadd nsz float %x, -0.0
49 define float @fadd_zero_nsz(float %x) {
50 ; CHECK-LABEL: fadd_zero_nsz:
53 %r = fadd nsz float %x, 0.0
57 define float @fsub_zero(float %x) {
58 ; CHECK-LABEL: fsub_zero:
61 %r = fsub float %x, 0.0
65 define float @fsub_self(float %x) {
66 ; CHECK-LABEL: fsub_self:
68 ; CHECK-NEXT: xorps %xmm0, %xmm0
70 %r = fsub nnan float %x, %x
74 define float @fsub_neg_x_y(float %x, float %y) {
75 ; CHECK-LABEL: fsub_neg_x_y:
77 ; CHECK-NEXT: subss %xmm0, %xmm1
78 ; CHECK-NEXT: movaps %xmm1, %xmm0
80 %neg = fsub nsz float 0.0, %x
81 %r = fadd nsz float %neg, %y
85 define float @fsub_neg_y(float %x, float %y) {
86 ; CHECK-LABEL: fsub_neg_y:
88 ; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
90 %mul = fmul float %x, 5.0
91 %add = fadd float %mul, %y
92 %r = fsub nsz reassoc float %y, %add
96 define <4 x float> @fsub_neg_y_vector(<4 x float> %x, <4 x float> %y) {
97 ; CHECK-LABEL: fsub_neg_y_vector:
99 ; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
101 %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
102 %add = fadd <4 x float> %mul, %y
103 %r = fsub nsz reassoc <4 x float> %y, %add
107 define <4 x float> @fsub_neg_y_vector_nonuniform(<4 x float> %x, <4 x float> %y) {
108 ; CHECK-LABEL: fsub_neg_y_vector_nonuniform:
110 ; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
112 %mul = fmul <4 x float> %x, <float 5.0, float 6.0, float 7.0, float 8.0>
113 %add = fadd <4 x float> %mul, %y
114 %r = fsub nsz reassoc <4 x float> %y, %add
118 define float @fsub_neg_y_commute(float %x, float %y) {
119 ; CHECK-LABEL: fsub_neg_y_commute:
121 ; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
123 %mul = fmul float %x, 5.0
124 %add = fadd float %y, %mul
125 %r = fsub nsz reassoc float %y, %add
129 define <4 x float> @fsub_neg_y_commute_vector(<4 x float> %x, <4 x float> %y) {
130 ; CHECK-LABEL: fsub_neg_y_commute_vector:
132 ; CHECK-NEXT: mulps {{.*}}(%rip), %xmm0
134 %mul = fmul <4 x float> %x, <float 5.0, float 5.0, float 5.0, float 5.0>
135 %add = fadd <4 x float> %y, %mul
136 %r = fsub nsz reassoc <4 x float> %y, %add
142 define float @fsub_fadd_common_op_fneg(float %x, float %y) {
143 ; CHECK-LABEL: fsub_fadd_common_op_fneg:
145 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
147 %a = fadd float %x, %y
148 %r = fsub reassoc nsz float %y, %a
154 define <4 x float> @fsub_fadd_common_op_fneg_vec(<4 x float> %x, <4 x float> %y) {
155 ; CHECK-LABEL: fsub_fadd_common_op_fneg_vec:
157 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
159 %a = fadd <4 x float> %x, %y
160 %r = fsub nsz reassoc <4 x float> %y, %a
165 ; Commute operands of the 'add'.
167 define float @fsub_fadd_common_op_fneg_commute(float %x, float %y) {
168 ; CHECK-LABEL: fsub_fadd_common_op_fneg_commute:
170 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
172 %a = fadd float %y, %x
173 %r = fsub reassoc nsz float %y, %a
179 define <4 x float> @fsub_fadd_common_op_fneg_commute_vec(<4 x float> %x, <4 x float> %y) {
180 ; CHECK-LABEL: fsub_fadd_common_op_fneg_commute_vec:
182 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
184 %a = fadd <4 x float> %y, %x
185 %r = fsub reassoc nsz <4 x float> %y, %a
189 define float @fsub_negzero_strict(float %x) {
190 ; CHECK-LABEL: fsub_negzero_strict:
192 ; CHECK-NEXT: xorps %xmm1, %xmm1
193 ; CHECK-NEXT: addss %xmm1, %xmm0
195 %r = fsub float %x, -0.0
199 define float @fsub_negzero_nsz(float %x) {
200 ; CHECK-LABEL: fsub_negzero_nsz:
203 %r = fsub nsz float %x, -0.0
207 define <4 x float> @fsub_negzero_strict_vector(<4 x float> %x) {
208 ; CHECK-LABEL: fsub_negzero_strict_vector:
210 ; CHECK-NEXT: xorps %xmm1, %xmm1
211 ; CHECK-NEXT: addps %xmm1, %xmm0
213 %r = fsub <4 x float> %x, <float -0.0, float -0.0, float -0.0, float -0.0>
217 define <4 x float> @fsub_negzero_nsz_vector(<4 x float> %x) {
218 ; CHECK-LABEL: fsub_negzero_nsz_vector:
221 %r = fsub nsz <4 x float> %x, <float -0.0, float -0.0, float -0.0, float -0.0>
225 define float @fsub_zero_nsz_1(float %x) {
226 ; CHECK-LABEL: fsub_zero_nsz_1:
229 %r = fsub nsz float %x, 0.0
233 define float @fsub_zero_nsz_2(float %x) {
234 ; CHECK-LABEL: fsub_zero_nsz_2:
236 ; CHECK-NEXT: xorps {{.*}}(%rip), %xmm0
238 %r = fsub nsz float 0.0, %x
242 define float @fmul_zero(float %x) {
243 ; CHECK-LABEL: fmul_zero:
245 ; CHECK-NEXT: xorps %xmm0, %xmm0
247 %r = fmul nnan nsz float %x, 0.0
251 define float @fmul_one(float %x) {
252 ; CHECK-LABEL: fmul_one:
255 %r = fmul float %x, 1.0
259 define float @fmul_x_const_const(float %x) {
260 ; CHECK-LABEL: fmul_x_const_const:
262 ; CHECK-NEXT: mulss {{.*}}(%rip), %xmm0
264 %mul = fmul reassoc float %x, 9.0
265 %r = fmul reassoc float %mul, 4.0