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