1; Test that floating-point instructions that set cc are used to
2; eliminate compares for load complement, load negative and load
3; positive.
4;
5; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
6; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
7
8; Load complement (sign-bit flipped).
9; Test f32
10define float @f1(float %a, float %b, float %f) {
11; CHECK-LABEL: f1:
12; CHECK: lcebr
13; CHECK-NEXT: je
14  %neg = fsub float -0.0, %f
15  %cond = fcmp oeq float %neg, 0.0
16  %res = select i1 %cond, float %a, float %b
17  ret float %res
18}
19
20; Test f64
21define double @f2(double %a, double %b, double %f) {
22; CHECK-LABEL: f2:
23; CHECK: lcdbr
24; CHECK-NEXT: je
25  %neg = fsub double -0.0, %f
26  %cond = fcmp oeq double %neg, 0.0
27  %res = select i1 %cond, double %a, double %b
28  ret double %res
29}
30
31; Negation of floating-point absolute.
32; Test f32
33declare float @llvm.fabs.f32(float %f)
34define float @f3(float %a, float %b, float %f) {
35; CHECK-LABEL: f3:
36; CHECK: lnebr
37; CHECK-NEXT: je
38  %abs = call float @llvm.fabs.f32(float %f)
39  %neg = fsub float -0.0, %abs
40  %cond = fcmp oeq float %neg, 0.0
41  %res = select i1 %cond, float %a, float %b
42  ret float %res
43}
44
45; Test f64
46declare double @llvm.fabs.f64(double %f)
47define double @f4(double %a, double %b, double %f) {
48; CHECK-LABEL: f4:
49; CHECK: lndbr
50; CHECK-NEXT: je
51  %abs = call double @llvm.fabs.f64(double %f)
52  %neg = fsub double -0.0, %abs
53  %cond = fcmp oeq double %neg, 0.0
54  %res = select i1 %cond, double %a, double %b
55  ret double %res
56}
57
58; Absolute floating-point value.
59; Test f32
60define float @f5(float %a, float %b, float %f) {
61; CHECK-LABEL: f5:
62; CHECK: lpebr
63; CHECK-NEXT: je
64  %abs = call float @llvm.fabs.f32(float %f)
65  %cond = fcmp oeq float %abs, 0.0
66  %res = select i1 %cond, float %a, float %b
67  ret float %res
68}
69
70; Test f64
71define double @f6(double %a, double %b, double %f) {
72; CHECK-LABEL: f6:
73; CHECK: lpdbr
74; CHECK-NEXT: je
75  %abs = call double @llvm.fabs.f64(double %f)
76  %cond = fcmp oeq double %abs, 0.0
77  %res = select i1 %cond, double %a, double %b
78  ret double %res
79}
80
81