1; Test that floating-point instructions that set cc are *not* used to
2; eliminate *strict* signaling compares for load complement, load negative
3; and load 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) #0 {
11; CHECK-LABEL: f1:
12; CHECK: kebr
13; CHECK-NEXT: ber %r14
14  %neg = fneg float %f
15  %cond = call i1 @llvm.experimental.constrained.fcmps.f32(
16                                               float %neg, float 0.0,
17                                               metadata !"oeq",
18                                               metadata !"fpexcept.strict") #0
19  %res = select i1 %cond, float %a, float %b
20  ret float %res
21}
22
23; Test f64
24define double @f2(double %a, double %b, double %f) #0 {
25; CHECK-LABEL: f2:
26; CHECK: kdbr
27; CHECK-NEXT: ber %r14
28  %neg = fneg double %f
29  %cond = call i1 @llvm.experimental.constrained.fcmps.f64(
30                                               double %neg, double 0.0,
31                                               metadata !"oeq",
32                                               metadata !"fpexcept.strict") #0
33  %res = select i1 %cond, double %a, double %b
34  ret double %res
35}
36
37; Negation of floating-point absolute.
38; Test f32
39declare float @llvm.fabs.f32(float %f)
40define float @f3(float %a, float %b, float %f) #0 {
41; CHECK-LABEL: f3:
42; CHECK: kebr
43; CHECK-NEXT: ber %r14
44  %abs = call float @llvm.fabs.f32(float %f) #0
45  %neg = fneg float %abs
46  %cond = call i1 @llvm.experimental.constrained.fcmps.f32(
47                                               float %neg, float 0.0,
48                                               metadata !"oeq",
49                                               metadata !"fpexcept.strict") #0
50  %res = select i1 %cond, float %a, float %b
51  ret float %res
52}
53
54; Test f64
55declare double @llvm.fabs.f64(double %f)
56define double @f4(double %a, double %b, double %f) #0 {
57; CHECK-LABEL: f4:
58; CHECK: kdbr
59; CHECK-NEXT: ber %r14
60  %abs = call double @llvm.fabs.f64(double %f) #0
61  %neg = fneg double %abs
62  %cond = call i1 @llvm.experimental.constrained.fcmps.f64(
63                                               double %neg, double 0.0,
64                                               metadata !"oeq",
65                                               metadata !"fpexcept.strict") #0
66  %res = select i1 %cond, double %a, double %b
67  ret double %res
68}
69
70; Absolute floating-point value.
71; Test f32
72define float @f5(float %a, float %b, float %f) #0 {
73; CHECK-LABEL: f5:
74; CHECK: kebr
75; CHECK-NEXT: ber %r14
76  %abs = call float @llvm.fabs.f32(float %f) #0
77  %cond = call i1 @llvm.experimental.constrained.fcmps.f32(
78                                               float %abs, float 0.0,
79                                               metadata !"oeq",
80                                               metadata !"fpexcept.strict") #0
81  %res = select i1 %cond, float %a, float %b
82  ret float %res
83}
84
85; Test f64
86define double @f6(double %a, double %b, double %f) #0 {
87; CHECK-LABEL: f6:
88; CHECK: kdbr
89; CHECK-NEXT: ber %r14
90  %abs = call double @llvm.fabs.f64(double %f) #0
91  %cond = call i1 @llvm.experimental.constrained.fcmps.f64(
92                                               double %abs, double 0.0,
93                                               metadata !"oeq",
94                                               metadata !"fpexcept.strict") #0
95  %res = select i1 %cond, double %a, double %b
96  ret double %res
97}
98
99attributes #0 = { strictfp }
100
101declare i1 @llvm.experimental.constrained.fcmps.f32(float, float, metadata, metadata)
102declare i1 @llvm.experimental.constrained.fcmps.f64(double, double, metadata, metadata)
103
104