1 ; Test 32-bit unsigned comparison in which the second operand is a variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check register comparison.
6 define double @f1(double %a, double %b, i32 %i1, i32 %i2) {
8 ; CHECK: clrbl %r2, %r3, 0(%r14)
11 %cond = icmp ult i32 %i1, %i2
12 %res = select i1 %cond, double %a, double %b
16 ; Check the low end of the CL range.
17 define double @f2(double %a, double %b, i32 %i1, i32 *%ptr) {
19 ; CHECK: cl %r2, 0(%r3)
20 ; CHECK-NEXT: blr %r14
23 %i2 = load i32, i32 *%ptr
24 %cond = icmp ult i32 %i1, %i2
25 %res = select i1 %cond, double %a, double %b
29 ; Check the high end of the aligned CL range.
30 define double @f3(double %a, double %b, i32 %i1, i32 *%base) {
32 ; CHECK: cl %r2, 4092(%r3)
33 ; CHECK-NEXT: blr %r14
36 %ptr = getelementptr i32, i32 *%base, i64 1023
37 %i2 = load i32, i32 *%ptr
38 %cond = icmp ult i32 %i1, %i2
39 %res = select i1 %cond, double %a, double %b
43 ; Check the next word up, which should use CLY instead of CL.
44 define double @f4(double %a, double %b, i32 %i1, i32 *%base) {
46 ; CHECK: cly %r2, 4096(%r3)
47 ; CHECK-NEXT: blr %r14
50 %ptr = getelementptr i32, i32 *%base, i64 1024
51 %i2 = load i32, i32 *%ptr
52 %cond = icmp ult i32 %i1, %i2
53 %res = select i1 %cond, double %a, double %b
57 ; Check the high end of the aligned CLY range.
58 define double @f5(double %a, double %b, i32 %i1, i32 *%base) {
60 ; CHECK: cly %r2, 524284(%r3)
61 ; CHECK-NEXT: blr %r14
64 %ptr = getelementptr i32, i32 *%base, i64 131071
65 %i2 = load i32, i32 *%ptr
66 %cond = icmp ult i32 %i1, %i2
67 %res = select i1 %cond, double %a, double %b
71 ; Check the next word up, which needs separate address logic.
72 ; Other sequences besides this one would be OK.
73 define double @f6(double %a, double %b, i32 %i1, i32 *%base) {
75 ; CHECK: agfi %r3, 524288
76 ; CHECK: cl %r2, 0(%r3)
77 ; CHECK-NEXT: blr %r14
80 %ptr = getelementptr i32, i32 *%base, i64 131072
81 %i2 = load i32, i32 *%ptr
82 %cond = icmp ult i32 %i1, %i2
83 %res = select i1 %cond, double %a, double %b
87 ; Check the high end of the negative aligned CLY range.
88 define double @f7(double %a, double %b, i32 %i1, i32 *%base) {
90 ; CHECK: cly %r2, -4(%r3)
91 ; CHECK-NEXT: blr %r14
94 %ptr = getelementptr i32, i32 *%base, i64 -1
95 %i2 = load i32, i32 *%ptr
96 %cond = icmp ult i32 %i1, %i2
97 %res = select i1 %cond, double %a, double %b
101 ; Check the low end of the CLY range.
102 define double @f8(double %a, double %b, i32 %i1, i32 *%base) {
104 ; CHECK: cly %r2, -524288(%r3)
105 ; CHECK-NEXT: blr %r14
106 ; CHECK: ldr %f0, %f2
108 %ptr = getelementptr i32, i32 *%base, i64 -131072
109 %i2 = load i32, i32 *%ptr
110 %cond = icmp ult i32 %i1, %i2
111 %res = select i1 %cond, double %a, double %b
115 ; Check the next word down, which needs separate address logic.
116 ; Other sequences besides this one would be OK.
117 define double @f9(double %a, double %b, i32 %i1, i32 *%base) {
119 ; CHECK: agfi %r3, -524292
120 ; CHECK: cl %r2, 0(%r3)
121 ; CHECK-NEXT: blr %r14
122 ; CHECK: ldr %f0, %f2
124 %ptr = getelementptr i32, i32 *%base, i64 -131073
125 %i2 = load i32, i32 *%ptr
126 %cond = icmp ult i32 %i1, %i2
127 %res = select i1 %cond, double %a, double %b
131 ; Check that CL allows an index.
132 define double @f10(double %a, double %b, i32 %i1, i64 %base, i64 %index) {
134 ; CHECK: cl %r2, 4092({{%r4,%r3|%r3,%r4}})
135 ; CHECK-NEXT: blr %r14
136 ; CHECK: ldr %f0, %f2
138 %add1 = add i64 %base, %index
139 %add2 = add i64 %add1, 4092
140 %ptr = inttoptr i64 %add2 to i32 *
141 %i2 = load i32, i32 *%ptr
142 %cond = icmp ult i32 %i1, %i2
143 %res = select i1 %cond, double %a, double %b
147 ; Check that CLY allows an index.
148 define double @f11(double %a, double %b, i32 %i1, i64 %base, i64 %index) {
150 ; CHECK: cly %r2, 4096({{%r4,%r3|%r3,%r4}})
151 ; CHECK-NEXT: blr %r14
152 ; CHECK: ldr %f0, %f2
154 %add1 = add i64 %base, %index
155 %add2 = add i64 %add1, 4096
156 %ptr = inttoptr i64 %add2 to i32 *
157 %i2 = load i32, i32 *%ptr
158 %cond = icmp ult i32 %i1, %i2
159 %res = select i1 %cond, double %a, double %b
163 ; Check the comparison can be reversed if that allows CL to be used.
164 define double @f12(double %a, double %b, i32 %i2, i32 *%ptr) {
166 ; CHECK: cl %r2, 0(%r3)
167 ; CHECK-NEXT: bhr %r14
168 ; CHECK: ldr %f0, %f2
170 %i1 = load i32, i32 *%ptr
171 %cond = icmp ult i32 %i1, %i2
172 %res = select i1 %cond, double %a, double %b