[SystemZ] Register compare-and-branch support
[oota-llvm.git] / test / CodeGen / SystemZ / int-cmp-14.ll
1 ; Test 64-bit inequality comparisons in which the second operand is a constant.
2 ;
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5 ; Check comparisons with 0.
6 define double @f1(double %a, double %b, i64 %i1) {
7 ; CHECK: f1:
8 ; CHECK: cghi %r2, 0
9 ; CHECK-NEXT: jlh
10 ; CHECK: ldr %f0, %f2
11 ; CHECK: br %r14
12   %cond = icmp ne i64 %i1, 0
13   %res = select i1 %cond, double %a, double %b
14   ret double %res
15 }
16
17 ; Check the high end of the CGHI range.
18 define double @f2(double %a, double %b, i64 %i1) {
19 ; CHECK: f2:
20 ; CHECK: cghi %r2, 32767
21 ; CHECK-NEXT: jlh
22 ; CHECK: ldr %f0, %f2
23 ; CHECK: br %r14
24   %cond = icmp ne i64 %i1, 32767
25   %res = select i1 %cond, double %a, double %b
26   ret double %res
27 }
28
29 ; Check the next value up, which must use CGFI.
30 define double @f3(double %a, double %b, i64 %i1) {
31 ; CHECK: f3:
32 ; CHECK: cgfi %r2, 32768
33 ; CHECK-NEXT: jlh
34 ; CHECK: ldr %f0, %f2
35 ; CHECK: br %r14
36   %cond = icmp ne i64 %i1, 32768
37   %res = select i1 %cond, double %a, double %b
38   ret double %res
39 }
40
41 ; Check the high end of the CGFI range.
42 define double @f4(double %a, double %b, i64 %i1) {
43 ; CHECK: f4:
44 ; CHECK: cgfi %r2, 2147483647
45 ; CHECK-NEXT: jlh
46 ; CHECK: ldr %f0, %f2
47 ; CHECK: br %r14
48   %cond = icmp ne i64 %i1, 2147483647
49   %res = select i1 %cond, double %a, double %b
50   ret double %res
51 }
52
53 ; Check the next value up, which should use CLGFI instead.
54 define double @f5(double %a, double %b, i64 %i1) {
55 ; CHECK: f5:
56 ; CHECK: clgfi %r2, 2147483648
57 ; CHECK-NEXT: jlh
58 ; CHECK: ldr %f0, %f2
59 ; CHECK: br %r14
60   %cond = icmp ne i64 %i1, 2147483648
61   %res = select i1 %cond, double %a, double %b
62   ret double %res
63 }
64
65 ; Check the high end of the CLGFI range.
66 define double @f6(double %a, double %b, i64 %i1) {
67 ; CHECK: f6:
68 ; CHECK: clgfi %r2, 4294967295
69 ; CHECK-NEXT: jlh
70 ; CHECK: ldr %f0, %f2
71 ; CHECK: br %r14
72   %cond = icmp ne i64 %i1, 4294967295
73   %res = select i1 %cond, double %a, double %b
74   ret double %res
75 }
76
77 ; Check the next value up, which must use a register comparison.
78 define double @f7(double %a, double %b, i64 %i1) {
79 ; CHECK: f7:
80 ; CHECK: cgrjlh %r2,
81 ; CHECK: ldr %f0, %f2
82 ; CHECK: br %r14
83   %cond = icmp ne i64 %i1, 4294967296
84   %res = select i1 %cond, double %a, double %b
85   ret double %res
86 }
87
88 ; Check the high end of the negative CGHI range.
89 define double @f8(double %a, double %b, i64 %i1) {
90 ; CHECK: f8:
91 ; CHECK: cghi %r2, -1
92 ; CHECK-NEXT: jlh
93 ; CHECK: ldr %f0, %f2
94 ; CHECK: br %r14
95   %cond = icmp ne i64 %i1, -1
96   %res = select i1 %cond, double %a, double %b
97   ret double %res
98 }
99
100 ; Check the low end of the CGHI range.
101 define double @f9(double %a, double %b, i64 %i1) {
102 ; CHECK: f9:
103 ; CHECK: cghi %r2, -32768
104 ; CHECK-NEXT: jlh
105 ; CHECK: ldr %f0, %f2
106 ; CHECK: br %r14
107   %cond = icmp ne i64 %i1, -32768
108   %res = select i1 %cond, double %a, double %b
109   ret double %res
110 }
111
112 ; Check the next value down, which must use CGFI instead.
113 define double @f10(double %a, double %b, i64 %i1) {
114 ; CHECK: f10:
115 ; CHECK: cgfi %r2, -32769
116 ; CHECK-NEXT: jlh
117 ; CHECK: ldr %f0, %f2
118 ; CHECK: br %r14
119   %cond = icmp ne i64 %i1, -32769
120   %res = select i1 %cond, double %a, double %b
121   ret double %res
122 }
123
124 ; Check the low end of the CGFI range.
125 define double @f11(double %a, double %b, i64 %i1) {
126 ; CHECK: f11:
127 ; CHECK: cgfi %r2, -2147483648
128 ; CHECK-NEXT: jlh
129 ; CHECK: ldr %f0, %f2
130 ; CHECK: br %r14
131   %cond = icmp ne i64 %i1, -2147483648
132   %res = select i1 %cond, double %a, double %b
133   ret double %res
134 }
135
136 ; Check the next value down, which must use register comparison.
137 define double @f12(double %a, double %b, i64 %i1) {
138 ; CHECK: f12:
139 ; CHECK: cgrjlh
140 ; CHECK: ldr %f0, %f2
141 ; CHECK: br %r14
142   %cond = icmp ne i64 %i1, -2147483649
143   %res = select i1 %cond, double %a, double %b
144   ret double %res
145 }