1 ; Test 64-bit signed comparison in which the second operand is a variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 define double @f1(double %a, double %b, i64 %i1, i64 %i2) {
12 %cond = icmp slt i64 %i1, %i2
13 %res = select i1 %cond, double %a, double %b
17 ; Check CG with no displacement.
18 define double @f2(double %a, double %b, i64 %i1, i64 *%ptr) {
20 ; CHECK: cg %r2, 0(%r3)
21 ; CHECK-NEXT: j{{g?}}l
25 %cond = icmp slt i64 %i1, %i2
26 %res = select i1 %cond, double %a, double %b
30 ; Check the high end of the aligned CG range.
31 define double @f3(double %a, double %b, i64 %i1, i64 *%base) {
33 ; CHECK: cg %r2, 524280(%r3)
34 ; CHECK-NEXT: j{{g?}}l
37 %ptr = getelementptr i64 *%base, i64 65535
39 %cond = icmp slt i64 %i1, %i2
40 %res = select i1 %cond, double %a, double %b
44 ; Check the next doubleword up, which needs separate address logic.
45 ; Other sequences besides this one would be OK.
46 define double @f4(double %a, double %b, i64 %i1, i64 *%base) {
48 ; CHECK: agfi %r3, 524288
49 ; CHECK: cg %r2, 0(%r3)
50 ; CHECK-NEXT: j{{g?}}l
53 %ptr = getelementptr i64 *%base, i64 65536
55 %cond = icmp slt i64 %i1, %i2
56 %res = select i1 %cond, double %a, double %b
60 ; Check the high end of the negative aligned CG range.
61 define double @f5(double %a, double %b, i64 %i1, i64 *%base) {
63 ; CHECK: cg %r2, -8(%r3)
64 ; CHECK-NEXT: j{{g?}}l
67 %ptr = getelementptr i64 *%base, i64 -1
69 %cond = icmp slt i64 %i1, %i2
70 %res = select i1 %cond, double %a, double %b
74 ; Check the low end of the CG range.
75 define double @f6(double %a, double %b, i64 %i1, i64 *%base) {
77 ; CHECK: cg %r2, -524288(%r3)
78 ; CHECK-NEXT: j{{g?}}l
81 %ptr = getelementptr i64 *%base, i64 -65536
83 %cond = icmp slt i64 %i1, %i2
84 %res = select i1 %cond, double %a, double %b
88 ; Check the next doubleword down, which needs separate address logic.
89 ; Other sequences besides this one would be OK.
90 define double @f7(double %a, double %b, i64 %i1, i64 *%base) {
92 ; CHECK: agfi %r3, -524296
93 ; CHECK: cg %r2, 0(%r3)
94 ; CHECK-NEXT: j{{g?}}l
97 %ptr = getelementptr i64 *%base, i64 -65537
99 %cond = icmp slt i64 %i1, %i2
100 %res = select i1 %cond, double %a, double %b
104 ; Check that CG allows an index.
105 define double @f8(double %a, double %b, i64 %i1, i64 %base, i64 %index) {
107 ; CHECK: cg %r2, 524280({{%r4,%r3|%r3,%r4}})
108 ; CHECK-NEXT: j{{g?}}l
109 ; CHECK: ldr %f0, %f2
111 %add1 = add i64 %base, %index
112 %add2 = add i64 %add1, 524280
113 %ptr = inttoptr i64 %add2 to i64 *
115 %cond = icmp slt i64 %i1, %i2
116 %res = select i1 %cond, double %a, double %b