1 ; Test 32-bit signed 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) {
11 %cond = icmp slt i32 %i1, %i2
12 %res = select i1 %cond, double %a, double %b
16 ; Check the low end of the C range.
17 define double @f2(double %a, double %b, i32 %i1, i32 *%ptr) {
19 ; CHECK: c %r2, 0(%r3)
24 %cond = icmp slt i32 %i1, %i2
25 %res = select i1 %cond, double %a, double %b
29 ; Check the high end of the aligned C range.
30 define double @f3(double %a, double %b, i32 %i1, i32 *%base) {
32 ; CHECK: c %r2, 4092(%r3)
36 %ptr = getelementptr i32 *%base, i64 1023
38 %cond = icmp slt i32 %i1, %i2
39 %res = select i1 %cond, double %a, double %b
43 ; Check the next word up, which should use CY instead of C.
44 define double @f4(double %a, double %b, i32 %i1, i32 *%base) {
46 ; CHECK: cy %r2, 4096(%r3)
50 %ptr = getelementptr i32 *%base, i64 1024
52 %cond = icmp slt i32 %i1, %i2
53 %res = select i1 %cond, double %a, double %b
57 ; Check the high end of the aligned CY range.
58 define double @f5(double %a, double %b, i32 %i1, i32 *%base) {
60 ; CHECK: cy %r2, 524284(%r3)
64 %ptr = getelementptr i32 *%base, i64 131071
66 %cond = icmp slt 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: c %r2, 0(%r3)
80 %ptr = getelementptr i32 *%base, i64 131072
82 %cond = icmp slt i32 %i1, %i2
83 %res = select i1 %cond, double %a, double %b
87 ; Check the high end of the negative aligned CY range.
88 define double @f7(double %a, double %b, i32 %i1, i32 *%base) {
90 ; CHECK: cy %r2, -4(%r3)
94 %ptr = getelementptr i32 *%base, i64 -1
96 %cond = icmp slt i32 %i1, %i2
97 %res = select i1 %cond, double %a, double %b
101 ; Check the low end of the CY range.
102 define double @f8(double %a, double %b, i32 %i1, i32 *%base) {
104 ; CHECK: cy %r2, -524288(%r3)
106 ; CHECK: ldr %f0, %f2
108 %ptr = getelementptr i32 *%base, i64 -131072
110 %cond = icmp slt 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: c %r2, 0(%r3)
122 ; CHECK: ldr %f0, %f2
124 %ptr = getelementptr i32 *%base, i64 -131073
126 %cond = icmp slt i32 %i1, %i2
127 %res = select i1 %cond, double %a, double %b
131 ; Check that C allows an index.
132 define double @f10(double %a, double %b, i32 %i1, i64 %base, i64 %index) {
134 ; CHECK: c %r2, 4092({{%r4,%r3|%r3,%r4}})
136 ; CHECK: ldr %f0, %f2
138 %add1 = add i64 %base, %index
139 %add2 = add i64 %add1, 4092
140 %ptr = inttoptr i64 %add2 to i32 *
142 %cond = icmp slt i32 %i1, %i2
143 %res = select i1 %cond, double %a, double %b
147 ; Check that CY allows an index.
148 define double @f11(double %a, double %b, i32 %i1, i64 %base, i64 %index) {
150 ; CHECK: cy %r2, 4096({{%r4,%r3|%r3,%r4}})
152 ; CHECK: ldr %f0, %f2
154 %add1 = add i64 %base, %index
155 %add2 = add i64 %add1, 4096
156 %ptr = inttoptr i64 %add2 to i32 *
158 %cond = icmp slt i32 %i1, %i2
159 %res = select i1 %cond, double %a, double %b