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