blob: 48a068e49e8f37dc02586e4387311654339b7294 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 8-bit unsigned comparisons between memory and constants.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check ordered comparisons near the low end of the unsigned 8-bit range.
6define double @f1(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: cli 0(%r2), 1
Richard Sandiford586f4172013-05-21 08:53:17 +00009; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: br %r14
11 %val = load i8 *%ptr
12 %cond = icmp ugt i8 %val, 1
13 %res = select i1 %cond, double %a, double %b
14 ret double %res
15}
16
17; Check ordered comparisons near the high end of the unsigned 8-bit range.
18define double @f2(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000019; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000020; CHECK: cli 0(%r2), 254
Richard Sandiford586f4172013-05-21 08:53:17 +000021; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: br %r14
23 %val = load i8 *%ptr
24 %cond = icmp ult i8 %val, 254
25 %res = select i1 %cond, double %a, double %b
26 ret double %res
27}
28
29; Check tests for negative bytes.
30define double @f3(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000031; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000032; CHECK: cli 0(%r2), 127
Richard Sandiford586f4172013-05-21 08:53:17 +000033; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: br %r14
35 %val = load i8 *%ptr
36 %cond = icmp slt i8 %val, 0
37 %res = select i1 %cond, double %a, double %b
38 ret double %res
39}
40
41; ...and an alternative form.
42define double @f4(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000043; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000044; CHECK: cli 0(%r2), 127
Richard Sandiford586f4172013-05-21 08:53:17 +000045; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000046; CHECK: br %r14
47 %val = load i8 *%ptr
48 %cond = icmp sle i8 %val, -1
49 %res = select i1 %cond, double %a, double %b
50 ret double %res
51}
52
53; Check tests for non-negative bytes.
54define double @f5(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000055; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000056; CHECK: cli 0(%r2), 128
Richard Sandiford586f4172013-05-21 08:53:17 +000057; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058; CHECK: br %r14
59 %val = load i8 *%ptr
60 %cond = icmp sge i8 %val, 0
61 %res = select i1 %cond, double %a, double %b
62 ret double %res
63}
64
65; ...and an alternative form.
66define double @f6(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000067; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000068; CHECK: cli 0(%r2), 128
Richard Sandiford586f4172013-05-21 08:53:17 +000069; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000070; CHECK: br %r14
71 %val = load i8 *%ptr
72 %cond = icmp sgt i8 %val, -1
73 %res = select i1 %cond, double %a, double %b
74 ret double %res
75}
76
77; Check equality comparisons at the low end of the signed 8-bit range.
78define double @f7(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000079; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000080; CHECK: cli 0(%r2), 128
Richard Sandiford586f4172013-05-21 08:53:17 +000081; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000082; CHECK: br %r14
83 %val = load i8 *%ptr
84 %cond = icmp eq i8 %val, -128
85 %res = select i1 %cond, double %a, double %b
86 ret double %res
87}
88
89; Check equality comparisons at the low end of the unsigned 8-bit range.
90define double @f8(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000091; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000092; CHECK: cli 0(%r2), 0
Richard Sandiford586f4172013-05-21 08:53:17 +000093; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000094; CHECK: br %r14
95 %val = load i8 *%ptr
96 %cond = icmp eq i8 %val, 0
97 %res = select i1 %cond, double %a, double %b
98 ret double %res
99}
100
101; Check equality comparisons at the high end of the signed 8-bit range.
102define double @f9(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000103; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000104; CHECK: cli 0(%r2), 127
Richard Sandiford586f4172013-05-21 08:53:17 +0000105; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000106; CHECK: br %r14
107 %val = load i8 *%ptr
108 %cond = icmp eq i8 %val, 127
109 %res = select i1 %cond, double %a, double %b
110 ret double %res
111}
112
113; Check equality comparisons at the high end of the unsigned 8-bit range.
114define double @f10(double %a, double %b, i8 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000115; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000116; CHECK: cli 0(%r2), 255
Richard Sandiford586f4172013-05-21 08:53:17 +0000117; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000118; CHECK: br %r14
119 %val = load i8 *%ptr
120 %cond = icmp eq i8 %val, 255
121 %res = select i1 %cond, double %a, double %b
122 ret double %res
123}
124
125; Check the high end of the CLI range.
126define double @f11(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000127; CHECK-LABEL: f11:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000128; CHECK: cli 4095(%r2), 127
129; CHECK: br %r14
130 %ptr = getelementptr i8 *%src, i64 4095
131 %val = load i8 *%ptr
132 %cond = icmp ult i8 %val, 127
133 %res = select i1 %cond, double %a, double %b
134 ret double %res
135}
136
137; Check the next byte up, which should use CLIY instead of CLI.
138define double @f12(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000139; CHECK-LABEL: f12:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000140; CHECK: cliy 4096(%r2), 127
141; CHECK: br %r14
142 %ptr = getelementptr i8 *%src, i64 4096
143 %val = load i8 *%ptr
144 %cond = icmp ult i8 %val, 127
145 %res = select i1 %cond, double %a, double %b
146 ret double %res
147}
148
149; Check the high end of the CLIY range.
150define double @f13(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000151; CHECK-LABEL: f13:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000152; CHECK: cliy 524287(%r2), 127
153; CHECK: br %r14
154 %ptr = getelementptr i8 *%src, i64 524287
155 %val = load i8 *%ptr
156 %cond = icmp ult i8 %val, 127
157 %res = select i1 %cond, double %a, double %b
158 ret double %res
159}
160
161; Check the next byte up, which needs separate address logic.
162; Other sequences besides this one would be OK.
163define double @f14(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000164; CHECK-LABEL: f14:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000165; CHECK: agfi %r2, 524288
166; CHECK: cli 0(%r2), 127
167; CHECK: br %r14
168 %ptr = getelementptr i8 *%src, i64 524288
169 %val = load i8 *%ptr
170 %cond = icmp ult i8 %val, 127
171 %res = select i1 %cond, double %a, double %b
172 ret double %res
173}
174
175; Check the high end of the negative CLIY range.
176define double @f15(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000177; CHECK-LABEL: f15:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000178; CHECK: cliy -1(%r2), 127
179; CHECK: br %r14
180 %ptr = getelementptr i8 *%src, i64 -1
181 %val = load i8 *%ptr
182 %cond = icmp ult i8 %val, 127
183 %res = select i1 %cond, double %a, double %b
184 ret double %res
185}
186
187; Check the low end of the CLIY range.
188define double @f16(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000189; CHECK-LABEL: f16:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000190; CHECK: cliy -524288(%r2), 127
191; CHECK: br %r14
192 %ptr = getelementptr i8 *%src, i64 -524288
193 %val = load i8 *%ptr
194 %cond = icmp ult i8 %val, 127
195 %res = select i1 %cond, double %a, double %b
196 ret double %res
197}
198
199; Check the next byte down, which needs separate address logic.
200; Other sequences besides this one would be OK.
201define double @f17(double %a, double %b, i8 *%src) {
Stephen Lind24ab202013-07-14 06:24:09 +0000202; CHECK-LABEL: f17:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000203; CHECK: agfi %r2, -524289
204; CHECK: cli 0(%r2), 127
205; CHECK: br %r14
206 %ptr = getelementptr i8 *%src, i64 -524289
207 %val = load i8 *%ptr
208 %cond = icmp ult i8 %val, 127
209 %res = select i1 %cond, double %a, double %b
210 ret double %res
211}
212
213; Check that CLI does not allow an index
214define double @f18(double %a, double %b, i64 %base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +0000215; CHECK-LABEL: f18:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000216; CHECK: agr %r2, %r3
217; CHECK: cli 4095(%r2), 127
218; CHECK: br %r14
219 %add1 = add i64 %base, %index
220 %add2 = add i64 %add1, 4095
221 %ptr = inttoptr i64 %add2 to i8 *
222 %val = load i8 *%ptr
223 %cond = icmp ult i8 %val, 127
224 %res = select i1 %cond, double %a, double %b
225 ret double %res
226}
227
228; Check that CLIY does not allow an index
229define double @f19(double %a, double %b, i64 %base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +0000230; CHECK-LABEL: f19:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000231; CHECK: agr %r2, %r3
232; CHECK: cliy 4096(%r2), 127
233; CHECK: br %r14
234 %add1 = add i64 %base, %index
235 %add2 = add i64 %add1, 4096
236 %ptr = inttoptr i64 %add2 to i8 *
237 %val = load i8 *%ptr
238 %cond = icmp ult i8 %val, 127
239 %res = select i1 %cond, double %a, double %b
240 ret double %res
241}