1 ; Test 8-bit unsigned comparisons between memory and constants.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check ordered comparisons near the low end of the unsigned 8-bit range.
6 define double @f1(double %a, double %b, i8 *%ptr) {
11 %val = load i8, i8 *%ptr
12 %cond = icmp ugt i8 %val, 1
13 %res = select i1 %cond, double %a, double %b
17 ; Check ordered comparisons near the high end of the unsigned 8-bit range.
18 define double @f2(double %a, double %b, i8 *%ptr) {
20 ; CHECK: cli 0(%r2), 254
21 ; CHECK-NEXT: blr %r14
23 %val = load i8, i8 *%ptr
24 %cond = icmp ult i8 %val, 254
25 %res = select i1 %cond, double %a, double %b
29 ; Check tests for negative bytes.
30 define double @f3(double %a, double %b, i8 *%ptr) {
32 ; CHECK: cli 0(%r2), 127
33 ; CHECK-NEXT: bhr %r14
35 %val = load i8, i8 *%ptr
36 %cond = icmp slt i8 %val, 0
37 %res = select i1 %cond, double %a, double %b
41 ; ...and an alternative form.
42 define double @f4(double %a, double %b, i8 *%ptr) {
44 ; CHECK: cli 0(%r2), 127
45 ; CHECK-NEXT: bhr %r14
47 %val = load i8, i8 *%ptr
48 %cond = icmp sle i8 %val, -1
49 %res = select i1 %cond, double %a, double %b
53 ; Check tests for non-negative bytes.
54 define double @f5(double %a, double %b, i8 *%ptr) {
56 ; CHECK: cli 0(%r2), 128
57 ; CHECK-NEXT: blr %r14
59 %val = load i8, i8 *%ptr
60 %cond = icmp sge i8 %val, 0
61 %res = select i1 %cond, double %a, double %b
65 ; ...and an alternative form.
66 define double @f6(double %a, double %b, i8 *%ptr) {
68 ; CHECK: cli 0(%r2), 128
69 ; CHECK-NEXT: blr %r14
71 %val = load i8, i8 *%ptr
72 %cond = icmp sgt i8 %val, -1
73 %res = select i1 %cond, double %a, double %b
77 ; Check equality comparisons at the low end of the signed 8-bit range.
78 define double @f7(double %a, double %b, i8 *%ptr) {
80 ; CHECK: cli 0(%r2), 128
81 ; CHECK-NEXT: ber %r14
83 %val = load i8, i8 *%ptr
84 %cond = icmp eq i8 %val, -128
85 %res = select i1 %cond, double %a, double %b
89 ; Check equality comparisons at the low end of the unsigned 8-bit range.
90 define double @f8(double %a, double %b, i8 *%ptr) {
92 ; CHECK: cli 0(%r2), 0
93 ; CHECK-NEXT: ber %r14
95 %val = load i8, i8 *%ptr
96 %cond = icmp eq i8 %val, 0
97 %res = select i1 %cond, double %a, double %b
101 ; Check equality comparisons at the high end of the signed 8-bit range.
102 define double @f9(double %a, double %b, i8 *%ptr) {
104 ; CHECK: cli 0(%r2), 127
105 ; CHECK-NEXT: ber %r14
107 %val = load i8, i8 *%ptr
108 %cond = icmp eq i8 %val, 127
109 %res = select i1 %cond, double %a, double %b
113 ; Check equality comparisons at the high end of the unsigned 8-bit range.
114 define double @f10(double %a, double %b, i8 *%ptr) {
116 ; CHECK: cli 0(%r2), 255
117 ; CHECK-NEXT: ber %r14
119 %val = load i8, i8 *%ptr
120 %cond = icmp eq i8 %val, 255
121 %res = select i1 %cond, double %a, double %b
125 ; Check the high end of the CLI range.
126 define double @f11(double %a, double %b, i8 *%src) {
128 ; CHECK: cli 4095(%r2), 127
130 %ptr = getelementptr i8, i8 *%src, i64 4095
131 %val = load i8, i8 *%ptr
132 %cond = icmp ult i8 %val, 127
133 %res = select i1 %cond, double %a, double %b
137 ; Check the next byte up, which should use CLIY instead of CLI.
138 define double @f12(double %a, double %b, i8 *%src) {
140 ; CHECK: cliy 4096(%r2), 127
142 %ptr = getelementptr i8, i8 *%src, i64 4096
143 %val = load i8, i8 *%ptr
144 %cond = icmp ult i8 %val, 127
145 %res = select i1 %cond, double %a, double %b
149 ; Check the high end of the CLIY range.
150 define double @f13(double %a, double %b, i8 *%src) {
152 ; CHECK: cliy 524287(%r2), 127
154 %ptr = getelementptr i8, i8 *%src, i64 524287
155 %val = load i8, i8 *%ptr
156 %cond = icmp ult i8 %val, 127
157 %res = select i1 %cond, double %a, double %b
161 ; Check the next byte up, which needs separate address logic.
162 ; Other sequences besides this one would be OK.
163 define double @f14(double %a, double %b, i8 *%src) {
165 ; CHECK: agfi %r2, 524288
166 ; CHECK: cli 0(%r2), 127
168 %ptr = getelementptr i8, i8 *%src, i64 524288
169 %val = load i8, i8 *%ptr
170 %cond = icmp ult i8 %val, 127
171 %res = select i1 %cond, double %a, double %b
175 ; Check the high end of the negative CLIY range.
176 define double @f15(double %a, double %b, i8 *%src) {
178 ; CHECK: cliy -1(%r2), 127
180 %ptr = getelementptr i8, i8 *%src, i64 -1
181 %val = load i8, i8 *%ptr
182 %cond = icmp ult i8 %val, 127
183 %res = select i1 %cond, double %a, double %b
187 ; Check the low end of the CLIY range.
188 define double @f16(double %a, double %b, i8 *%src) {
190 ; CHECK: cliy -524288(%r2), 127
192 %ptr = getelementptr i8, i8 *%src, i64 -524288
193 %val = load i8, i8 *%ptr
194 %cond = icmp ult i8 %val, 127
195 %res = select i1 %cond, double %a, double %b
199 ; Check the next byte down, which needs separate address logic.
200 ; Other sequences besides this one would be OK.
201 define double @f17(double %a, double %b, i8 *%src) {
203 ; CHECK: agfi %r2, -524289
204 ; CHECK: cli 0(%r2), 127
206 %ptr = getelementptr i8, i8 *%src, i64 -524289
207 %val = load i8, i8 *%ptr
208 %cond = icmp ult i8 %val, 127
209 %res = select i1 %cond, double %a, double %b
213 ; Check that CLI does not allow an index
214 define double @f18(double %a, double %b, i64 %base, i64 %index) {
216 ; CHECK: agr %r2, %r3
217 ; CHECK: cli 4095(%r2), 127
219 %add1 = add i64 %base, %index
220 %add2 = add i64 %add1, 4095
221 %ptr = inttoptr i64 %add2 to i8 *
222 %val = load i8, i8 *%ptr
223 %cond = icmp ult i8 %val, 127
224 %res = select i1 %cond, double %a, double %b
228 ; Check that CLIY does not allow an index
229 define double @f19(double %a, double %b, i64 %base, i64 %index) {
231 ; CHECK: agr %r2, %r3
232 ; CHECK: cliy 4096(%r2), 127
234 %add1 = add i64 %base, %index
235 %add2 = add i64 %add1, 4096
236 %ptr = inttoptr i64 %add2 to i8 *
237 %val = load i8, i8 *%ptr
238 %cond = icmp ult i8 %val, 127
239 %res = select i1 %cond, double %a, double %b