131 lines · plain
1; Test 64-bit signed comparison in which the second operand is a variable.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4 5; Check CGR.6define double @f1(double %a, double %b, i64 %i1, i64 %i2) {7; CHECK-LABEL: f1:8; CHECK: cgrbl %r2, %r3, 0(%r14)9; CHECK: ldr %f0, %f210; CHECK: br %r1411 %cond = icmp slt i64 %i1, %i212 %res = select i1 %cond, double %a, double %b13 ret double %res14}15 16; Check CG with no displacement.17define double @f2(double %a, double %b, i64 %i1, ptr %ptr) {18; CHECK-LABEL: f2:19; CHECK: cg %r2, 0(%r3)20; CHECK-NEXT: blr %r1421; CHECK: ldr %f0, %f222; CHECK: br %r1423 %i2 = load i64, ptr %ptr24 %cond = icmp slt i64 %i1, %i225 %res = select i1 %cond, double %a, double %b26 ret double %res27}28 29; Check the high end of the aligned CG range.30define double @f3(double %a, double %b, i64 %i1, ptr %base) {31; CHECK-LABEL: f3:32; CHECK: cg %r2, 524280(%r3)33; CHECK-NEXT: blr %r1434; CHECK: ldr %f0, %f235; CHECK: br %r1436 %ptr = getelementptr i64, ptr %base, i64 6553537 %i2 = load i64, ptr %ptr38 %cond = icmp slt i64 %i1, %i239 %res = select i1 %cond, double %a, double %b40 ret double %res41}42 43; Check the next doubleword up, which needs separate address logic.44; Other sequences besides this one would be OK.45define double @f4(double %a, double %b, i64 %i1, ptr %base) {46; CHECK-LABEL: f4:47; CHECK: agfi %r3, 52428848; CHECK: cg %r2, 0(%r3)49; CHECK-NEXT: blr %r1450; CHECK: ldr %f0, %f251; CHECK: br %r1452 %ptr = getelementptr i64, ptr %base, i64 6553653 %i2 = load i64, ptr %ptr54 %cond = icmp slt i64 %i1, %i255 %res = select i1 %cond, double %a, double %b56 ret double %res57}58 59; Check the high end of the negative aligned CG range.60define double @f5(double %a, double %b, i64 %i1, ptr %base) {61; CHECK-LABEL: f5:62; CHECK: cg %r2, -8(%r3)63; CHECK-NEXT: blr %r1464; CHECK: ldr %f0, %f265; CHECK: br %r1466 %ptr = getelementptr i64, ptr %base, i64 -167 %i2 = load i64, ptr %ptr68 %cond = icmp slt i64 %i1, %i269 %res = select i1 %cond, double %a, double %b70 ret double %res71}72 73; Check the low end of the CG range.74define double @f6(double %a, double %b, i64 %i1, ptr %base) {75; CHECK-LABEL: f6:76; CHECK: cg %r2, -524288(%r3)77; CHECK-NEXT: blr %r1478; CHECK: ldr %f0, %f279; CHECK: br %r1480 %ptr = getelementptr i64, ptr %base, i64 -6553681 %i2 = load i64, ptr %ptr82 %cond = icmp slt i64 %i1, %i283 %res = select i1 %cond, double %a, double %b84 ret double %res85}86 87; Check the next doubleword down, which needs separate address logic.88; Other sequences besides this one would be OK.89define double @f7(double %a, double %b, i64 %i1, ptr %base) {90; CHECK-LABEL: f7:91; CHECK: agfi %r3, -52429692; CHECK: cg %r2, 0(%r3)93; CHECK-NEXT: blr %r1494; CHECK: ldr %f0, %f295; CHECK: br %r1496 %ptr = getelementptr i64, ptr %base, i64 -6553797 %i2 = load i64, ptr %ptr98 %cond = icmp slt i64 %i1, %i299 %res = select i1 %cond, double %a, double %b100 ret double %res101}102 103; Check that CG allows an index.104define double @f8(double %a, double %b, i64 %i1, i64 %base, i64 %index) {105; CHECK-LABEL: f8:106; CHECK: cg %r2, 524280({{%r4,%r3|%r3,%r4}})107; CHECK-NEXT: blr %r14108; CHECK: ldr %f0, %f2109; CHECK: br %r14110 %add1 = add i64 %base, %index111 %add2 = add i64 %add1, 524280112 %ptr = inttoptr i64 %add2 to ptr113 %i2 = load i64, ptr %ptr114 %cond = icmp slt i64 %i1, %i2115 %res = select i1 %cond, double %a, double %b116 ret double %res117}118 119; Check the comparison can be reversed if that allows CG to be used.120define double @f9(double %a, double %b, i64 %i2, ptr %ptr) {121; CHECK-LABEL: f9:122; CHECK: cg %r2, 0(%r3)123; CHECK-NEXT: bhr %r14124; CHECK: ldr %f0, %f2125; CHECK: br %r14126 %i1 = load i64, ptr %ptr127 %cond = icmp slt i64 %i1, %i2128 %res = select i1 %cond, double %a, double %b129 ret double %res130}131