1 ; Test 32-bit ordered comparisons that are really between a memory byte
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Check unsigned comparison near the low end of the CLI range, using zero
8 define double @f1(double %a, double %b, i8 *%ptr) {
10 ; CHECK: cli 0(%r2), 1
11 ; CHECK-NEXT: bhr %r14
13 %val = load i8, i8 *%ptr
14 %ext = zext i8 %val to i32
15 %cond = icmp ugt i32 %ext, 1
16 %res = select i1 %cond, double %a, double %b
20 ; Check unsigned comparison near the low end of the CLI range, using sign
22 define double @f2(double %a, double %b, i8 *%ptr) {
24 ; CHECK: cli 0(%r2), 1
25 ; CHECK-NEXT: bhr %r14
27 %val = load i8, i8 *%ptr
28 %ext = sext i8 %val to i32
29 %cond = icmp ugt i32 %ext, 1
30 %res = select i1 %cond, double %a, double %b
34 ; Check unsigned comparison near the high end of the CLI range, using zero
36 define double @f3(double %a, double %b, i8 *%ptr) {
38 ; CHECK: cli 0(%r2), 254
39 ; CHECK-NEXT: blr %r14
41 %val = load i8, i8 *%ptr
42 %ext = zext i8 %val to i32
43 %cond = icmp ult i32 %ext, 254
44 %res = select i1 %cond, double %a, double %b
48 ; Check unsigned comparison near the high end of the CLI range, using sign
50 define double @f4(double %a, double %b, i8 *%ptr) {
52 ; CHECK: cli 0(%r2), 254
53 ; CHECK-NEXT: blr %r14
55 %val = load i8, i8 *%ptr
56 %ext = sext i8 %val to i32
57 %cond = icmp ult i32 %ext, -2
58 %res = select i1 %cond, double %a, double %b
62 ; Check unsigned comparison above the high end of the CLI range, using zero
63 ; extension. The condition is always true.
64 define double @f5(double %a, double %b, i8 *%ptr) {
66 ; CHECK-NOT: cli {{.*}}
68 %val = load i8, i8 *%ptr
69 %ext = zext i8 %val to i32
70 %cond = icmp ult i32 %ext, 256
71 %res = select i1 %cond, double %a, double %b
75 ; When using unsigned comparison with sign extension, equality with values
76 ; in the range [128, MAX-129] is impossible, and ordered comparisons with
77 ; those values are effectively sign tests. Since such comparisons are
78 ; unlikely to occur in practice, we don't bother optimizing the second case,
79 ; and simply ignore CLI for this range. First check the low end of the range.
80 define double @f6(double %a, double %b, i8 *%ptr) {
82 ; CHECK-NOT: cli {{.*}}
84 %val = load i8, i8 *%ptr
85 %ext = sext i8 %val to i32
86 %cond = icmp ult i32 %ext, 128
87 %res = select i1 %cond, double %a, double %b
91 ; ...and then the high end.
92 define double @f7(double %a, double %b, i8 *%ptr) {
94 ; CHECK-NOT: cli {{.*}}
96 %val = load i8, i8 *%ptr
97 %ext = sext i8 %val to i32
98 %cond = icmp ult i32 %ext, -129
99 %res = select i1 %cond, double %a, double %b
103 ; Check signed comparison near the low end of the CLI range, using zero
104 ; extension. This is equivalent to unsigned comparison.
105 define double @f8(double %a, double %b, i8 *%ptr) {
107 ; CHECK: cli 0(%r2), 1
108 ; CHECK-NEXT: bhr %r14
110 %val = load i8, i8 *%ptr
111 %ext = zext i8 %val to i32
112 %cond = icmp sgt i32 %ext, 1
113 %res = select i1 %cond, double %a, double %b
117 ; Check signed comparison near the low end of the CLI range, using sign
118 ; extension. This cannot use CLI.
119 define double @f9(double %a, double %b, i8 *%ptr) {
121 ; CHECK-NOT: cli {{.*}}
123 %val = load i8, i8 *%ptr
124 %ext = sext i8 %val to i32
125 %cond = icmp sgt i32 %ext, 1
126 %res = select i1 %cond, double %a, double %b
130 ; Check signed comparison near the high end of the CLI range, using zero
131 ; extension. This is equivalent to unsigned comparison.
132 define double @f10(double %a, double %b, i8 *%ptr) {
134 ; CHECK: cli 0(%r2), 254
135 ; CHECK-NEXT: blr %r14
137 %val = load i8, i8 *%ptr
138 %ext = zext i8 %val to i32
139 %cond = icmp slt i32 %ext, 254
140 %res = select i1 %cond, double %a, double %b
144 ; Check signed comparison near the high end of the CLI range, using sign
145 ; extension. This cannot use CLI.
146 define double @f11(double %a, double %b, i8 *%ptr) {
148 ; CHECK-NOT: cli {{.*}}
150 %val = load i8, i8 *%ptr
151 %ext = sext i8 %val to i32
152 %cond = icmp slt i32 %ext, -2
153 %res = select i1 %cond, double %a, double %b
157 ; Check signed comparison above the high end of the CLI range, using zero
158 ; extension. The condition is always true.
159 define double @f12(double %a, double %b, i8 *%ptr) {
161 ; CHECK-NOT: cli {{.*}}
163 %val = load i8, i8 *%ptr
164 %ext = zext i8 %val to i32
165 %cond = icmp slt i32 %ext, 256
166 %res = select i1 %cond, double %a, double %b
170 ; Check tests for nonnegative values.
171 define double @f13(double %a, double %b, i8 *%ptr) {
173 ; CHECK: cli 0(%r2), 128
174 ; CHECK-NEXT: blr %r14
176 %val = load i8, i8 *%ptr
177 %ext = sext i8 %val to i32
178 %cond = icmp sge i32 %ext, 0
179 %res = select i1 %cond, double %a, double %b
183 ; ...and another form
184 define double @f14(double %a, double %b, i8 *%ptr) {
186 ; CHECK: cli 0(%r2), 128
187 ; CHECK-NEXT: blr %r14
189 %val = load i8, i8 *%ptr
190 %ext = sext i8 %val to i32
191 %cond = icmp sgt i32 %ext, -1
192 %res = select i1 %cond, double %a, double %b
196 ; Check tests for negative values.
197 define double @f15(double %a, double %b, i8 *%ptr) {
199 ; CHECK: cli 0(%r2), 127
200 ; CHECK-NEXT: bhr %r14
202 %val = load i8, i8 *%ptr
203 %ext = sext i8 %val to i32
204 %cond = icmp slt i32 %ext, 0
205 %res = select i1 %cond, double %a, double %b
209 ; ...and another form
210 define double @f16(double %a, double %b, i8 *%ptr) {
212 ; CHECK: cli 0(%r2), 127
213 ; CHECK-NEXT: bhr %r14
215 %val = load i8, i8 *%ptr
216 %ext = sext i8 %val to i32
217 %cond = icmp sle i32 %ext, -1
218 %res = select i1 %cond, double %a, double %b