1 ; Test that floating-point compares are omitted if CC already has the
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 -no-integrated-as | FileCheck %s
6 declare float @llvm.fabs.f32(float %f)
8 ; Test addition followed by EQ, which can use the CC result of the addition.
9 define float @f1(float %a, float %b, float *%dest) {
11 ; CHECK: aebr %f0, %f2
12 ; CHECK-NEXT: ber %r14
15 %res = fadd float %a, %b
16 %cmp = fcmp oeq float %res, 0.0
17 br i1 %cmp, label %exit, label %store
20 store float %b, float *%dest
27 ; ...and again with LT.
28 define float @f2(float %a, float %b, float *%dest) {
30 ; CHECK: aebr %f0, %f2
31 ; CHECK-NEXT: blr %r14
34 %res = fadd float %a, %b
35 %cmp = fcmp olt float %res, 0.0
36 br i1 %cmp, label %exit, label %store
39 store float %b, float *%dest
46 ; ...and again with GT.
47 define float @f3(float %a, float %b, float *%dest) {
49 ; CHECK: aebr %f0, %f2
50 ; CHECK-NEXT: bhr %r14
53 %res = fadd float %a, %b
54 %cmp = fcmp ogt float %res, 0.0
55 br i1 %cmp, label %exit, label %store
58 store float %b, float *%dest
65 ; ...and again with UEQ.
66 define float @f4(float %a, float %b, float *%dest) {
68 ; CHECK: aebr %f0, %f2
69 ; CHECK-NEXT: bnlhr %r14
72 %res = fadd float %a, %b
73 %cmp = fcmp ueq float %res, 0.0
74 br i1 %cmp, label %exit, label %store
77 store float %b, float *%dest
84 ; Subtraction also provides a zero-based CC value.
85 define float @f5(float %a, float %b, float *%dest) {
87 ; CHECK: seb %f0, 0(%r2)
88 ; CHECK-NEXT: bnher %r14
91 %cur = load float, float *%dest
92 %res = fsub float %a, %cur
93 %cmp = fcmp ult float %res, 0.0
94 br i1 %cmp, label %exit, label %store
97 store float %b, float *%dest
104 ; Test the result of LOAD POSITIVE.
105 define float @f6(float %dummy, float %a, float *%dest) {
107 ; CHECK: lpebr %f0, %f2
108 ; CHECK-NEXT: bhr %r14
111 %res = call float @llvm.fabs.f32(float %a)
112 %cmp = fcmp ogt float %res, 0.0
113 br i1 %cmp, label %exit, label %store
116 store float %res, float *%dest
123 ; Test the result of LOAD NEGATIVE.
124 define float @f7(float %dummy, float %a, float *%dest) {
126 ; CHECK: lnebr %f0, %f2
127 ; CHECK-NEXT: blr %r14
130 %abs = call float @llvm.fabs.f32(float %a)
131 %res = fsub float -0.0, %abs
132 %cmp = fcmp olt float %res, 0.0
133 br i1 %cmp, label %exit, label %store
136 store float %res, float *%dest
143 ; Test the result of LOAD COMPLEMENT.
144 define float @f8(float %dummy, float %a, float *%dest) {
146 ; CHECK: lcebr %f0, %f2
147 ; CHECK-NEXT: bler %r14
150 %res = fsub float -0.0, %a
151 %cmp = fcmp ole float %res, 0.0
152 br i1 %cmp, label %exit, label %store
155 store float %res, float *%dest
162 ; Multiplication (for example) does not modify CC.
163 define float @f9(float %a, float %b, float *%dest) {
165 ; CHECK: meebr %f0, %f2
166 ; CHECK-NEXT: ltebr %f0, %f0
167 ; CHECK-NEXT: blhr %r14
170 %res = fmul float %a, %b
171 %cmp = fcmp one float %res, 0.0
172 br i1 %cmp, label %exit, label %store
175 store float %b, float *%dest
182 ; Test a combination involving a CC-setting instruction followed by
183 ; a non-CC-setting instruction.
184 define float @f10(float %a, float %b, float %c, float *%dest) {
186 ; CHECK: aebr %f0, %f2
187 ; CHECK-NEXT: debr %f0, %f4
188 ; CHECK-NEXT: ltebr %f0, %f0
189 ; CHECK-NEXT: bner %r14
192 %add = fadd float %a, %b
193 %res = fdiv float %add, %c
194 %cmp = fcmp une float %res, 0.0
195 br i1 %cmp, label %exit, label %store
198 store float %b, float *%dest
205 ; Test a case where CC is set based on a different register from the
207 define float @f11(float %a, float %b, float %c, float *%dest1, float *%dest2) {
209 ; CHECK: aebr %f0, %f2
210 ; CHECK-NEXT: sebr %f4, %f0
211 ; CHECK-DAG: ste %f4, 0(%r2)
212 ; CHECK-DAG: ltebr %f0, %f0
213 ; CHECK-NEXT: ber %r14
216 %add = fadd float %a, %b
217 %sub = fsub float %c, %add
218 store float %sub, float *%dest1
219 %cmp = fcmp oeq float %add, 0.0
220 br i1 %cmp, label %exit, label %store
223 store float %sub, float *%dest2
230 ; Test that LER gets converted to LTEBR where useful.
231 define float @f12(float %dummy, float %val, float *%dest) {
233 ; CHECK: ltebr %f0, %f2
235 ; CHECK-NEXT: blah %f0
236 ; CHECK-NEXT: #NO_APP
237 ; CHECK-NEXT: blr %r14
240 call void asm sideeffect "blah $0", "{f0}"(float %val)
241 %cmp = fcmp olt float %val, 0.0
242 br i1 %cmp, label %exit, label %store
245 store float %val, float *%dest
252 ; Test that LDR gets converted to LTDBR where useful.
253 define double @f13(double %dummy, double %val, double *%dest) {
255 ; CHECK: ltdbr %f0, %f2
257 ; CHECK-NEXT: blah %f0
258 ; CHECK-NEXT: #NO_APP
259 ; CHECK-NEXT: blr %r14
262 call void asm sideeffect "blah $0", "{f0}"(double %val)
263 %cmp = fcmp olt double %val, 0.0
264 br i1 %cmp, label %exit, label %store
267 store double %val, double *%dest
274 ; Test that LXR gets converted to LTXBR where useful.
275 define void @f14(fp128 *%ptr1, fp128 *%ptr2) {
284 ; CHECK-NEXT: blr %r14
287 %val1 = load fp128, fp128 *%ptr1
288 %val2 = load fp128, fp128 *%ptr2
289 %div = fdiv fp128 %val1, %val2
290 store fp128 %div, fp128 *%ptr1
291 %mul = fmul fp128 %val1, %val2
292 store fp128 %mul, fp128 *%ptr2
293 %cmp = fcmp olt fp128 %val1, 0xL00000000000000000000000000000000
294 br i1 %cmp, label %exit, label %store
297 call void asm sideeffect "blah", ""()
304 ; Test a case where it is the source rather than destination of LER that
306 define float @f15(float %val, float %dummy, float *%dest) {
308 ; CHECK: ltebr %f2, %f0
310 ; CHECK-NEXT: blah %f2
311 ; CHECK-NEXT: #NO_APP
312 ; CHECK-NEXT: blr %r14
315 call void asm sideeffect "blah $0", "{f2}"(float %val)
316 %cmp = fcmp olt float %val, 0.0
317 br i1 %cmp, label %exit, label %store
320 store float %val, float *%dest
327 ; Test a case where it is the source rather than destination of LDR that
329 define double @f16(double %val, double %dummy, double *%dest) {
331 ; CHECK: ltdbr %f2, %f0
333 ; CHECK-NEXT: blah %f2
334 ; CHECK-NEXT: #NO_APP
335 ; CHECK-NEXT: blr %r14
338 call void asm sideeffect "blah $0", "{f2}"(double %val)
339 %cmp = fcmp olt double %val, 0.0
340 br i1 %cmp, label %exit, label %store
343 store double %val, double *%dest
350 ; Repeat f2 with a comparison against -0.
351 define float @f17(float %a, float %b, float *%dest) {
353 ; CHECK: aebr %f0, %f2
354 ; CHECK-NEXT: blr %r14
357 %res = fadd float %a, %b
358 %cmp = fcmp olt float %res, -0.0
359 br i1 %cmp, label %exit, label %store
362 store float %b, float *%dest
369 ; Test another form of f7 in which the condition is based on the unnegated
370 ; result. This is what InstCombine would produce.
371 define float @f18(float %dummy, float %a, float *%dest) {
373 ; CHECK: lnebr %f0, %f2
374 ; CHECK-NEXT: blr %r14
377 %abs = call float @llvm.fabs.f32(float %a)
378 %res = fsub float -0.0, %abs
379 %cmp = fcmp ogt float %abs, 0.0
380 br i1 %cmp, label %exit, label %store
383 store float %res, float *%dest
391 define float @f19(float %dummy, float %a, float *%dest) {
393 ; CHECK: lcebr %f0, %f2
394 ; CHECK-NEXT: bler %r14
397 %res = fsub float -0.0, %a
398 %cmp = fcmp oge float %a, 0.0
399 br i1 %cmp, label %exit, label %store
402 store float %res, float *%dest