1 ; Test 64-bit floating-point subtraction.
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 | FileCheck %s
9 ; Check register subtraction.
10 define double @f1(double %f1, double %f2) {
12 ; CHECK: sdbr %f0, %f2
14 %res = fsub double %f1, %f2
18 ; Check the low end of the SDB range.
19 define double @f2(double %f1, ptr %ptr) {
21 ; CHECK: sdb %f0, 0(%r2)
23 %f2 = load double, ptr %ptr
24 %res = fsub double %f1, %f2
28 ; Check the high end of the aligned SDB range.
29 define double @f3(double %f1, ptr %base) {
31 ; CHECK: sdb %f0, 4088(%r2)
33 %ptr = getelementptr double, ptr %base, i64 511
34 %f2 = load double, ptr %ptr
35 %res = fsub double %f1, %f2
39 ; Check the next doubleword up, which needs separate address logic.
40 ; Other sequences besides this one would be OK.
41 define double @f4(double %f1, ptr %base) {
43 ; CHECK: aghi %r2, 4096
44 ; CHECK: sdb %f0, 0(%r2)
46 %ptr = getelementptr double, ptr %base, i64 512
47 %f2 = load double, ptr %ptr
48 %res = fsub double %f1, %f2
52 ; Check negative displacements, which also need separate address logic.
53 define double @f5(double %f1, ptr %base) {
56 ; CHECK: sdb %f0, 0(%r2)
58 %ptr = getelementptr double, ptr %base, i64 -1
59 %f2 = load double, ptr %ptr
60 %res = fsub double %f1, %f2
64 ; Check that SDB allows indices.
65 define double @f6(double %f1, ptr %base, i64 %index) {
67 ; CHECK: sllg %r1, %r3, 3
68 ; CHECK: sdb %f0, 800(%r1,%r2)
70 %ptr1 = getelementptr double, ptr %base, i64 %index
71 %ptr2 = getelementptr double, ptr %ptr1, i64 100
72 %f2 = load double, ptr %ptr2
73 %res = fsub double %f1, %f2
77 ; Check that subtractions of spilled values can use SDB rather than SDBR.
78 define double @f7(ptr %ptr0) {
80 ; CHECK: brasl %r14, foo@PLT
81 ; CHECK-SCALAR: sdb %f0, 16{{[04]}}(%r15)
83 %ptr1 = getelementptr double, ptr %ptr0, i64 2
84 %ptr2 = getelementptr double, ptr %ptr0, i64 4
85 %ptr3 = getelementptr double, ptr %ptr0, i64 6
86 %ptr4 = getelementptr double, ptr %ptr0, i64 8
87 %ptr5 = getelementptr double, ptr %ptr0, i64 10
88 %ptr6 = getelementptr double, ptr %ptr0, i64 12
89 %ptr7 = getelementptr double, ptr %ptr0, i64 14
90 %ptr8 = getelementptr double, ptr %ptr0, i64 16
91 %ptr9 = getelementptr double, ptr %ptr0, i64 18
92 %ptr10 = getelementptr double, ptr %ptr0, i64 20
94 %val0 = load double, ptr %ptr0
95 %val1 = load double, ptr %ptr1
96 %val2 = load double, ptr %ptr2
97 %val3 = load double, ptr %ptr3
98 %val4 = load double, ptr %ptr4
99 %val5 = load double, ptr %ptr5
100 %val6 = load double, ptr %ptr6
101 %val7 = load double, ptr %ptr7
102 %val8 = load double, ptr %ptr8
103 %val9 = load double, ptr %ptr9
104 %val10 = load double, ptr %ptr10
106 %ret = call double @foo()
108 %sub0 = fsub double %ret, %val0
109 %sub1 = fsub double %sub0, %val1
110 %sub2 = fsub double %sub1, %val2
111 %sub3 = fsub double %sub2, %val3
112 %sub4 = fsub double %sub3, %val4
113 %sub5 = fsub double %sub4, %val5
114 %sub6 = fsub double %sub5, %val6
115 %sub7 = fsub double %sub6, %val7
116 %sub8 = fsub double %sub7, %val8
117 %sub9 = fsub double %sub8, %val9
118 %sub10 = fsub double %sub9, %val10
123 ; Check that reassociation flags do not get in the way of SDB.
124 define double @f8(ptr %x) {
130 %0 = load double, ptr %x, align 8
131 %arrayidx1 = getelementptr inbounds double, ptr %x, i64 1
132 %1 = load double, ptr %arrayidx1, align 8
133 %add = fsub reassoc nsz arcp contract afn double %1, %0