1 ; Test 64-bit floating-point division.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
7 ; Check register division.
8 define double @f1(double %f1, double %f2) {
10 ; CHECK: ddbr %f0, %f2
12 %res = fdiv double %f1, %f2
16 ; Check the low end of the DDB range.
17 define double @f2(double %f1, double *%ptr) {
19 ; CHECK: ddb %f0, 0(%r2)
21 %f2 = load double *%ptr
22 %res = fdiv double %f1, %f2
26 ; Check the high end of the aligned DDB range.
27 define double @f3(double %f1, double *%base) {
29 ; CHECK: ddb %f0, 4088(%r2)
31 %ptr = getelementptr double *%base, i64 511
32 %f2 = load double *%ptr
33 %res = fdiv double %f1, %f2
37 ; Check the next doubleword up, which needs separate address logic.
38 ; Other sequences besides this one would be OK.
39 define double @f4(double %f1, double *%base) {
41 ; CHECK: aghi %r2, 4096
42 ; CHECK: ddb %f0, 0(%r2)
44 %ptr = getelementptr double *%base, i64 512
45 %f2 = load double *%ptr
46 %res = fdiv double %f1, %f2
50 ; Check negative displacements, which also need separate address logic.
51 define double @f5(double %f1, double *%base) {
54 ; CHECK: ddb %f0, 0(%r2)
56 %ptr = getelementptr double *%base, i64 -1
57 %f2 = load double *%ptr
58 %res = fdiv double %f1, %f2
62 ; Check that DDB allows indices.
63 define double @f6(double %f1, double *%base, i64 %index) {
65 ; CHECK: sllg %r1, %r3, 3
66 ; CHECK: ddb %f0, 800(%r1,%r2)
68 %ptr1 = getelementptr double *%base, i64 %index
69 %ptr2 = getelementptr double *%ptr1, i64 100
70 %f2 = load double *%ptr2
71 %res = fdiv double %f1, %f2
75 ; Check that divisions of spilled values can use DDB rather than DDBR.
76 define double @f7(double *%ptr0) {
78 ; CHECK: brasl %r14, foo@PLT
79 ; CHECK: ddb %f0, 160(%r15)
81 %ptr1 = getelementptr double *%ptr0, i64 2
82 %ptr2 = getelementptr double *%ptr0, i64 4
83 %ptr3 = getelementptr double *%ptr0, i64 6
84 %ptr4 = getelementptr double *%ptr0, i64 8
85 %ptr5 = getelementptr double *%ptr0, i64 10
86 %ptr6 = getelementptr double *%ptr0, i64 12
87 %ptr7 = getelementptr double *%ptr0, i64 14
88 %ptr8 = getelementptr double *%ptr0, i64 16
89 %ptr9 = getelementptr double *%ptr0, i64 18
90 %ptr10 = getelementptr double *%ptr0, i64 20
92 %val0 = load double *%ptr0
93 %val1 = load double *%ptr1
94 %val2 = load double *%ptr2
95 %val3 = load double *%ptr3
96 %val4 = load double *%ptr4
97 %val5 = load double *%ptr5
98 %val6 = load double *%ptr6
99 %val7 = load double *%ptr7
100 %val8 = load double *%ptr8
101 %val9 = load double *%ptr9
102 %val10 = load double *%ptr10
104 %ret = call double @foo()
106 %div0 = fdiv double %ret, %val0
107 %div1 = fdiv double %div0, %val1
108 %div2 = fdiv double %div1, %val2
109 %div3 = fdiv double %div2, %val3
110 %div4 = fdiv double %div3, %val4
111 %div5 = fdiv double %div4, %val5
112 %div6 = fdiv double %div5, %val6
113 %div7 = fdiv double %div6, %val7
114 %div8 = fdiv double %div7, %val8
115 %div9 = fdiv double %div8, %val9
116 %div10 = fdiv double %div9, %val10