1; Test 64-bit floating-point subtraction. 2; 3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 4 5declare double @foo() 6 7; Check register subtraction. 8define double @f1(double %f1, double %f2) { 9; CHECK-LABEL: f1: 10; CHECK: sdbr %f0, %f2 11; CHECK: br %r14 12 %res = fsub double %f1, %f2 13 ret double %res 14} 15 16; Check the low end of the SDB range. 17define double @f2(double %f1, double *%ptr) { 18; CHECK-LABEL: f2: 19; CHECK: sdb %f0, 0(%r2) 20; CHECK: br %r14 21 %f2 = load double , double *%ptr 22 %res = fsub double %f1, %f2 23 ret double %res 24} 25 26; Check the high end of the aligned SDB range. 27define double @f3(double %f1, double *%base) { 28; CHECK-LABEL: f3: 29; CHECK: sdb %f0, 4088(%r2) 30; CHECK: br %r14 31 %ptr = getelementptr double, double *%base, i64 511 32 %f2 = load double , double *%ptr 33 %res = fsub double %f1, %f2 34 ret double %res 35} 36 37; Check the next doubleword up, which needs separate address logic. 38; Other sequences besides this one would be OK. 39define double @f4(double %f1, double *%base) { 40; CHECK-LABEL: f4: 41; CHECK: aghi %r2, 4096 42; CHECK: sdb %f0, 0(%r2) 43; CHECK: br %r14 44 %ptr = getelementptr double, double *%base, i64 512 45 %f2 = load double , double *%ptr 46 %res = fsub double %f1, %f2 47 ret double %res 48} 49 50; Check negative displacements, which also need separate address logic. 51define double @f5(double %f1, double *%base) { 52; CHECK-LABEL: f5: 53; CHECK: aghi %r2, -8 54; CHECK: sdb %f0, 0(%r2) 55; CHECK: br %r14 56 %ptr = getelementptr double, double *%base, i64 -1 57 %f2 = load double , double *%ptr 58 %res = fsub double %f1, %f2 59 ret double %res 60} 61 62; Check that SDB allows indices. 63define double @f6(double %f1, double *%base, i64 %index) { 64; CHECK-LABEL: f6: 65; CHECK: sllg %r1, %r3, 3 66; CHECK: sdb %f0, 800(%r1,%r2) 67; CHECK: br %r14 68 %ptr1 = getelementptr double, double *%base, i64 %index 69 %ptr2 = getelementptr double, double *%ptr1, i64 100 70 %f2 = load double , double *%ptr2 71 %res = fsub double %f1, %f2 72 ret double %res 73} 74 75; Check that subtractions of spilled values can use SDB rather than SDBR. 76define double @f7(double *%ptr0) { 77; CHECK-LABEL: f7: 78; CHECK: brasl %r14, foo@PLT 79; CHECK: sdb %f0, 16{{[04]}}(%r15) 80; CHECK: br %r14 81 %ptr1 = getelementptr double, double *%ptr0, i64 2 82 %ptr2 = getelementptr double, double *%ptr0, i64 4 83 %ptr3 = getelementptr double, double *%ptr0, i64 6 84 %ptr4 = getelementptr double, double *%ptr0, i64 8 85 %ptr5 = getelementptr double, double *%ptr0, i64 10 86 %ptr6 = getelementptr double, double *%ptr0, i64 12 87 %ptr7 = getelementptr double, double *%ptr0, i64 14 88 %ptr8 = getelementptr double, double *%ptr0, i64 16 89 %ptr9 = getelementptr double, double *%ptr0, i64 18 90 %ptr10 = getelementptr double, double *%ptr0, i64 20 91 92 %val0 = load double , double *%ptr0 93 %val1 = load double , double *%ptr1 94 %val2 = load double , double *%ptr2 95 %val3 = load double , double *%ptr3 96 %val4 = load double , double *%ptr4 97 %val5 = load double , double *%ptr5 98 %val6 = load double , double *%ptr6 99 %val7 = load double , double *%ptr7 100 %val8 = load double , double *%ptr8 101 %val9 = load double , double *%ptr9 102 %val10 = load double , double *%ptr10 103 104 %ret = call double @foo() 105 106 %sub0 = fsub double %ret, %val0 107 %sub1 = fsub double %sub0, %val1 108 %sub2 = fsub double %sub1, %val2 109 %sub3 = fsub double %sub2, %val3 110 %sub4 = fsub double %sub3, %val4 111 %sub5 = fsub double %sub4, %val5 112 %sub6 = fsub double %sub5, %val6 113 %sub7 = fsub double %sub6, %val7 114 %sub8 = fsub double %sub7, %val8 115 %sub9 = fsub double %sub8, %val9 116 %sub10 = fsub double %sub9, %val10 117 118 ret double %sub10 119} 120