[SystemZ] Immediate compare-and-branch support
[oota-llvm.git] / test / CodeGen / SystemZ / int-cmp-09.ll
1 ; Test 32-bit signed comparison in which the second operand is 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, i32 %i1) {
7 ; CHECK: f1:
8 ; CHECK: cijl %r2, 0
9 ; CHECK: ldr %f0, %f2
10 ; CHECK: br %r14
11   %cond = icmp slt i32 %i1, 0
12   %res = select i1 %cond, double %a, double %b
13   ret double %res
14 }
15
16 ; Check comparisons with 1.
17 define double @f2(double %a, double %b, i32 %i1) {
18 ; CHECK: f2:
19 ; CHECK: cijl %r2, 1
20 ; CHECK: ldr %f0, %f2
21 ; CHECK: br %r14
22   %cond = icmp slt i32 %i1, 1
23   %res = select i1 %cond, double %a, double %b
24   ret double %res
25 }
26
27 ; Check the high end of the CIJ range.
28 define double @f3(double %a, double %b, i32 %i1) {
29 ; CHECK: f3:
30 ; CHECK: cijl %r2, 127
31 ; CHECK: ldr %f0, %f2
32 ; CHECK: br %r14
33   %cond = icmp slt i32 %i1, 127
34   %res = select i1 %cond, double %a, double %b
35   ret double %res
36 }
37
38 ; Check the next value up, which must use CHI instead.
39 define double @f4(double %a, double %b, i32 %i1) {
40 ; CHECK: f4:
41 ; CHECK: chi %r2, 128
42 ; CHECK-NEXT: jl
43 ; CHECK: ldr %f0, %f2
44 ; CHECK: br %r14
45   %cond = icmp slt i32 %i1, 128
46   %res = select i1 %cond, double %a, double %b
47   ret double %res
48 }
49
50 ; Check the high end of the CHI range.
51 define double @f5(double %a, double %b, i32 %i1) {
52 ; CHECK: f5:
53 ; CHECK: chi %r2, 32767
54 ; CHECK-NEXT: jl
55 ; CHECK: ldr %f0, %f2
56 ; CHECK: br %r14
57   %cond = icmp slt i32 %i1, 32767
58   %res = select i1 %cond, double %a, double %b
59   ret double %res
60 }
61
62 ; Check the next value up, which must use CFI.
63 define double @f6(double %a, double %b, i32 %i1) {
64 ; CHECK: f6:
65 ; CHECK: cfi %r2, 32768
66 ; CHECK-NEXT: jl
67 ; CHECK: ldr %f0, %f2
68 ; CHECK: br %r14
69   %cond = icmp slt i32 %i1, 32768
70   %res = select i1 %cond, double %a, double %b
71   ret double %res
72 }
73
74 ; Check the high end of the signed 32-bit range.
75 define double @f7(double %a, double %b, i32 %i1) {
76 ; CHECK: f7:
77 ; CHECK: cfi %r2, 2147483647
78 ; CHECK-NEXT: je
79 ; CHECK: ldr %f0, %f2
80 ; CHECK: br %r14
81   %cond = icmp eq i32 %i1, 2147483647
82   %res = select i1 %cond, double %a, double %b
83   ret double %res
84 }
85
86 ; Check the next value up, which should be treated as a negative value.
87 define double @f8(double %a, double %b, i32 %i1) {
88 ; CHECK: f8:
89 ; CHECK: cfi %r2, -2147483648
90 ; CHECK-NEXT: je
91 ; CHECK: ldr %f0, %f2
92 ; CHECK: br %r14
93   %cond = icmp eq i32 %i1, 2147483648
94   %res = select i1 %cond, double %a, double %b
95   ret double %res
96 }
97
98 ; Check the high end of the negative CIJ range.
99 define double @f9(double %a, double %b, i32 %i1) {
100 ; CHECK: f9:
101 ; CHECK: cijl %r2, -1
102 ; CHECK: ldr %f0, %f2
103 ; CHECK: br %r14
104   %cond = icmp slt i32 %i1, -1
105   %res = select i1 %cond, double %a, double %b
106   ret double %res
107 }
108
109 ; Check the low end of the CIJ range.
110 define double @f10(double %a, double %b, i32 %i1) {
111 ; CHECK: f10:
112 ; CHECK: cijl %r2, -128
113 ; CHECK: ldr %f0, %f2
114 ; CHECK: br %r14
115   %cond = icmp slt i32 %i1, -128
116   %res = select i1 %cond, double %a, double %b
117   ret double %res
118 }
119
120 ; Check the next value down, which must use CHI instead.
121 define double @f11(double %a, double %b, i32 %i1) {
122 ; CHECK: f11:
123 ; CHECK: chi %r2, -129
124 ; CHECK-NEXT: jl
125 ; CHECK: ldr %f0, %f2
126 ; CHECK: br %r14
127   %cond = icmp slt i32 %i1, -129
128   %res = select i1 %cond, double %a, double %b
129   ret double %res
130 }
131
132 ; Check the low end of the CHI range.
133 define double @f12(double %a, double %b, i32 %i1) {
134 ; CHECK: f12:
135 ; CHECK: chi %r2, -32768
136 ; CHECK-NEXT: jl
137 ; CHECK: ldr %f0, %f2
138 ; CHECK: br %r14
139   %cond = icmp slt i32 %i1, -32768
140   %res = select i1 %cond, double %a, double %b
141   ret double %res
142 }
143
144 ; Check the next value down, which must use CFI instead.
145 define double @f13(double %a, double %b, i32 %i1) {
146 ; CHECK: f13:
147 ; CHECK: cfi %r2, -32769
148 ; CHECK-NEXT: jl
149 ; CHECK: ldr %f0, %f2
150 ; CHECK: br %r14
151   %cond = icmp slt i32 %i1, -32769
152   %res = select i1 %cond, double %a, double %b
153   ret double %res
154 }
155
156 ; Check the low end of the signed 32-bit range.
157 define double @f14(double %a, double %b, i32 %i1) {
158 ; CHECK: f14:
159 ; CHECK: cfi %r2, -2147483648
160 ; CHECK-NEXT: je
161 ; CHECK: ldr %f0, %f2
162 ; CHECK: br %r14
163   %cond = icmp eq i32 %i1, -2147483648
164   %res = select i1 %cond, double %a, double %b
165   ret double %res
166 }
167
168 ; Check the next value down, which should be treated as a positive value.
169 define double @f15(double %a, double %b, i32 %i1) {
170 ; CHECK: f15:
171 ; CHECK: cfi %r2, 2147483647
172 ; CHECK-NEXT: je
173 ; CHECK: ldr %f0, %f2
174 ; CHECK: br %r14
175   %cond = icmp eq i32 %i1, -2147483649
176   %res = select i1 %cond, double %a, double %b
177   ret double %res
178 }