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