1 ; Test 64-bit comparison in which the second operand is a sign-extended i32.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check signed register comparison.
6 define double @f1(double %a, double %b, i64 %i1, i32 %unext) {
12 %i2 = sext i32 %unext to i64
13 %cond = icmp slt i64 %i1, %i2
14 %res = select i1 %cond, double %a, double %b
18 ; Check unsigned register comparison, which can't use CGFR.
19 define double @f2(double %a, double %b, i64 %i1, i32 %unext) {
23 %i2 = sext i32 %unext to i64
24 %cond = icmp ult i64 %i1, %i2
25 %res = select i1 %cond, double %a, double %b
29 ; Check register equality.
30 define double @f3(double %a, double %b, i64 %i1, i32 %unext) {
32 ; CHECK: cgfr %r2, %r3
33 ; CHECK-NEXT: j{{g?}}e
36 %i2 = sext i32 %unext to i64
37 %cond = icmp eq i64 %i1, %i2
38 %res = select i1 %cond, double %a, double %b
42 ; Check register inequality.
43 define double @f4(double %a, double %b, i64 %i1, i32 %unext) {
45 ; CHECK: cgfr %r2, %r3
46 ; CHECK-NEXT: j{{g?}}lh
49 %i2 = sext i32 %unext to i64
50 %cond = icmp ne i64 %i1, %i2
51 %res = select i1 %cond, double %a, double %b
55 ; Check signed comparisonn with memory.
56 define double @f5(double %a, double %b, i64 %i1, i32 *%ptr) {
58 ; CHECK: cgf %r2, 0(%r3)
59 ; CHECK-NEXT: j{{g?}}l
62 %unext = load i32 *%ptr
63 %i2 = sext i32 %unext to i64
64 %cond = icmp slt i64 %i1, %i2
65 %res = select i1 %cond, double %a, double %b
69 ; Check unsigned comparison with memory.
70 define double @f6(double %a, double %b, i64 %i1, i32 *%ptr) {
74 %unext = load i32 *%ptr
75 %i2 = sext i32 %unext to i64
76 %cond = icmp ult i64 %i1, %i2
77 %res = select i1 %cond, double %a, double %b
81 ; Check memory equality.
82 define double @f7(double %a, double %b, i64 %i1, i32 *%ptr) {
84 ; CHECK: cgf %r2, 0(%r3)
85 ; CHECK-NEXT: j{{g?}}e
88 %unext = load i32 *%ptr
89 %i2 = sext i32 %unext to i64
90 %cond = icmp eq i64 %i1, %i2
91 %res = select i1 %cond, double %a, double %b
95 ; Check memory inequality.
96 define double @f8(double %a, double %b, i64 %i1, i32 *%ptr) {
98 ; CHECK: cgf %r2, 0(%r3)
99 ; CHECK-NEXT: j{{g?}}lh
100 ; CHECK: ldr %f0, %f2
102 %unext = load i32 *%ptr
103 %i2 = sext i32 %unext to i64
104 %cond = icmp ne i64 %i1, %i2
105 %res = select i1 %cond, double %a, double %b
109 ; Check the high end of the aligned CGF range.
110 define double @f9(double %a, double %b, i64 %i1, i32 *%base) {
112 ; CHECK: cgf %r2, 524284(%r3)
113 ; CHECK-NEXT: j{{g?}}l
114 ; CHECK: ldr %f0, %f2
116 %ptr = getelementptr i32 *%base, i64 131071
117 %unext = load i32 *%ptr
118 %i2 = sext i32 %unext to i64
119 %cond = icmp slt i64 %i1, %i2
120 %res = select i1 %cond, double %a, double %b
124 ; Check the next word up, which needs separate address logic.
125 ; Other sequences besides this one would be OK.
126 define double @f10(double %a, double %b, i64 %i1, i32 *%base) {
128 ; CHECK: agfi %r3, 524288
129 ; CHECK: cgf %r2, 0(%r3)
130 ; CHECK-NEXT: j{{g?}}l
131 ; CHECK: ldr %f0, %f2
133 %ptr = getelementptr i32 *%base, i64 131072
134 %unext = load i32 *%ptr
135 %i2 = sext i32 %unext to i64
136 %cond = icmp slt i64 %i1, %i2
137 %res = select i1 %cond, double %a, double %b
141 ; Check the high end of the negative aligned CGF range.
142 define double @f11(double %a, double %b, i64 %i1, i32 *%base) {
144 ; CHECK: cgf %r2, -4(%r3)
145 ; CHECK-NEXT: j{{g?}}l
146 ; CHECK: ldr %f0, %f2
148 %ptr = getelementptr i32 *%base, i64 -1
149 %unext = load i32 *%ptr
150 %i2 = sext i32 %unext to i64
151 %cond = icmp slt i64 %i1, %i2
152 %res = select i1 %cond, double %a, double %b
156 ; Check the low end of the CGF range.
157 define double @f12(double %a, double %b, i64 %i1, i32 *%base) {
159 ; CHECK: cgf %r2, -524288(%r3)
160 ; CHECK-NEXT: j{{g?}}l
161 ; CHECK: ldr %f0, %f2
163 %ptr = getelementptr i32 *%base, i64 -131072
164 %unext = load i32 *%ptr
165 %i2 = sext i32 %unext to i64
166 %cond = icmp slt i64 %i1, %i2
167 %res = select i1 %cond, double %a, double %b
171 ; Check the next word down, which needs separate address logic.
172 ; Other sequences besides this one would be OK.
173 define double @f13(double %a, double %b, i64 %i1, i32 *%base) {
175 ; CHECK: agfi %r3, -524292
176 ; CHECK: cgf %r2, 0(%r3)
177 ; CHECK-NEXT: j{{g?}}l
178 ; CHECK: ldr %f0, %f2
180 %ptr = getelementptr i32 *%base, i64 -131073
181 %unext = load i32 *%ptr
182 %i2 = sext i32 %unext to i64
183 %cond = icmp slt i64 %i1, %i2
184 %res = select i1 %cond, double %a, double %b
188 ; Check that CGF allows an index.
189 define double @f14(double %a, double %b, i64 %i1, i64 %base, i64 %index) {
191 ; CHECK: cgf %r2, 524284({{%r4,%r3|%r3,%r4}})
192 ; CHECK-NEXT: j{{g?}}l
193 ; CHECK: ldr %f0, %f2
195 %add1 = add i64 %base, %index
196 %add2 = add i64 %add1, 524284
197 %ptr = inttoptr i64 %add2 to i32 *
198 %unext = load i32 *%ptr
199 %i2 = sext i32 %unext to i64
200 %cond = icmp slt i64 %i1, %i2
201 %res = select i1 %cond, double %a, double %b