1 ; Test 32-bit unsigned comparison in which the second operand is a variable. 2 ; 3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5 ; Check register comparison. 6 define double @f1(double %a, double %b, i32 %i1, i32 %i2) { 7 ; CHECK-LABEL: f1: 8 ; CHECK: clrjl %r2, %r3 9 ; CHECK: ldr %f0, %f2 10 ; CHECK: br %r14 11 %cond = icmp ult i32 %i1, %i2 12 %res = select i1 %cond, double %a, double %b 13 ret double %res 14 } 15 16 ; Check the low end of the CL range. 17 define double @f2(double %a, double %b, i32 %i1, i32 *%ptr) { 18 ; CHECK-LABEL: f2: 19 ; CHECK: cl %r2, 0(%r3) 20 ; CHECK-NEXT: jl 21 ; CHECK: ldr %f0, %f2 22 ; CHECK: br %r14 23 %i2 = load i32 *%ptr 24 %cond = icmp ult i32 %i1, %i2 25 %res = select i1 %cond, double %a, double %b 26 ret double %res 27 } 28 29 ; Check the high end of the aligned CL range. 30 define double @f3(double %a, double %b, i32 %i1, i32 *%base) { 31 ; CHECK-LABEL: f3: 32 ; CHECK: cl %r2, 4092(%r3) 33 ; CHECK-NEXT: jl 34 ; CHECK: ldr %f0, %f2 35 ; CHECK: br %r14 36 %ptr = getelementptr i32 *%base, i64 1023 37 %i2 = load i32 *%ptr 38 %cond = icmp ult i32 %i1, %i2 39 %res = select i1 %cond, double %a, double %b 40 ret double %res 41 } 42 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) { 45 ; CHECK-LABEL: f4: 46 ; CHECK: cly %r2, 4096(%r3) 47 ; CHECK-NEXT: jl 48 ; CHECK: ldr %f0, %f2 49 ; CHECK: br %r14 50 %ptr = getelementptr i32 *%base, i64 1024 51 %i2 = load i32 *%ptr 52 %cond = icmp ult i32 %i1, %i2 53 %res = select i1 %cond, double %a, double %b 54 ret double %res 55 } 56 57 ; Check the high end of the aligned CLY range. 58 define double @f5(double %a, double %b, i32 %i1, i32 *%base) { 59 ; CHECK-LABEL: f5: 60 ; CHECK: cly %r2, 524284(%r3) 61 ; CHECK-NEXT: jl 62 ; CHECK: ldr %f0, %f2 63 ; CHECK: br %r14 64 %ptr = getelementptr i32 *%base, i64 131071 65 %i2 = load i32 *%ptr 66 %cond = icmp ult i32 %i1, %i2 67 %res = select i1 %cond, double %a, double %b 68 ret double %res 69 } 70 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) { 74 ; CHECK-LABEL: f6: 75 ; CHECK: agfi %r3, 524288 76 ; CHECK: cl %r2, 0(%r3) 77 ; CHECK-NEXT: jl 78 ; CHECK: ldr %f0, %f2 79 ; CHECK: br %r14 80 %ptr = getelementptr i32 *%base, i64 131072 81 %i2 = load i32 *%ptr 82 %cond = icmp ult i32 %i1, %i2 83 %res = select i1 %cond, double %a, double %b 84 ret double %res 85 } 86 87 ; Check the high end of the negative aligned CLY range. 88 define double @f7(double %a, double %b, i32 %i1, i32 *%base) { 89 ; CHECK-LABEL: f7: 90 ; CHECK: cly %r2, -4(%r3) 91 ; CHECK-NEXT: jl 92 ; CHECK: ldr %f0, %f2 93 ; CHECK: br %r14 94 %ptr = getelementptr i32 *%base, i64 -1 95 %i2 = load i32 *%ptr 96 %cond = icmp ult i32 %i1, %i2 97 %res = select i1 %cond, double %a, double %b 98 ret double %res 99 } 100 101 ; Check the low end of the CLY range. 102 define double @f8(double %a, double %b, i32 %i1, i32 *%base) { 103 ; CHECK-LABEL: f8: 104 ; CHECK: cly %r2, -524288(%r3) 105 ; CHECK-NEXT: jl 106 ; CHECK: ldr %f0, %f2 107 ; CHECK: br %r14 108 %ptr = getelementptr i32 *%base, i64 -131072 109 %i2 = load i32 *%ptr 110 %cond = icmp ult i32 %i1, %i2 111 %res = select i1 %cond, double %a, double %b 112 ret double %res 113 } 114 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) { 118 ; CHECK-LABEL: f9: 119 ; CHECK: agfi %r3, -524292 120 ; CHECK: cl %r2, 0(%r3) 121 ; CHECK-NEXT: jl 122 ; CHECK: ldr %f0, %f2 123 ; CHECK: br %r14 124 %ptr = getelementptr i32 *%base, i64 -131073 125 %i2 = load i32 *%ptr 126 %cond = icmp ult i32 %i1, %i2 127 %res = select i1 %cond, double %a, double %b 128 ret double %res 129 } 130 131 ; Check that CL allows an index. 132 define double @f10(double %a, double %b, i32 %i1, i64 %base, i64 %index) { 133 ; CHECK-LABEL: f10: 134 ; CHECK: cl %r2, 4092({{%r4,%r3|%r3,%r4}}) 135 ; CHECK-NEXT: jl 136 ; CHECK: ldr %f0, %f2 137 ; CHECK: br %r14 138 %add1 = add i64 %base, %index 139 %add2 = add i64 %add1, 4092 140 %ptr = inttoptr i64 %add2 to i32 * 141 %i2 = load i32 *%ptr 142 %cond = icmp ult i32 %i1, %i2 143 %res = select i1 %cond, double %a, double %b 144 ret double %res 145 } 146 147 ; Check that CLY allows an index. 148 define double @f11(double %a, double %b, i32 %i1, i64 %base, i64 %index) { 149 ; CHECK-LABEL: f11: 150 ; CHECK: cly %r2, 4096({{%r4,%r3|%r3,%r4}}) 151 ; CHECK-NEXT: jl 152 ; CHECK: ldr %f0, %f2 153 ; CHECK: br %r14 154 %add1 = add i64 %base, %index 155 %add2 = add i64 %add1, 4096 156 %ptr = inttoptr i64 %add2 to i32 * 157 %i2 = load i32 *%ptr 158 %cond = icmp ult i32 %i1, %i2 159 %res = select i1 %cond, double %a, double %b 160 ret double %res 161 } 162 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) { 165 ; CHECK-LABEL: f12: 166 ; CHECK: cl %r2, 0(%r3) 167 ; CHECK-NEXT: jh {{\.L.*}} 168 ; CHECK: ldr %f0, %f2 169 ; CHECK: br %r14 170 %i1 = load i32 *%ptr 171 %cond = icmp ult i32 %i1, %i2 172 %res = select i1 %cond, double %a, double %b 173 ret double %res 174 } 175