blob: ee514dc474e953afe0f7518aa7f1507a1a135628 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 32-bit floating-point division.
2;
Ulrich Weigand33435c42017-07-17 17:42:48 +00003; 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=z14 | FileCheck %s
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00006
Richard Sandiforded1fab62013-07-03 10:10:02 +00007declare float @foo()
8
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009; Check register division.
10define float @f1(float %f1, float %f2) {
Stephen Lind24ab202013-07-14 06:24:09 +000011; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000012; CHECK: debr %f0, %f2
13; CHECK: br %r14
14 %res = fdiv float %f1, %f2
15 ret float %res
16}
17
18; Check the low end of the DEB range.
19define float @f2(float %f1, float *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000020; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000021; CHECK: deb %f0, 0(%r2)
22; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000023 %f2 = load float , float *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000024 %res = fdiv float %f1, %f2
25 ret float %res
26}
27
28; Check the high end of the aligned DEB range.
29define float @f3(float %f1, float *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000030; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000031; CHECK: deb %f0, 4092(%r2)
32; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000033 %ptr = getelementptr float, float *%base, i64 1023
David Blaikiea79ac142015-02-27 21:17:42 +000034 %f2 = load float , float *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000035 %res = fdiv float %f1, %f2
36 ret float %res
37}
38
39; Check the next word up, which needs separate address logic.
40; Other sequences besides this one would be OK.
41define float @f4(float %f1, float *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000042; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000043; CHECK: aghi %r2, 4096
44; CHECK: deb %f0, 0(%r2)
45; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000046 %ptr = getelementptr float, float *%base, i64 1024
David Blaikiea79ac142015-02-27 21:17:42 +000047 %f2 = load float , float *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000048 %res = fdiv float %f1, %f2
49 ret float %res
50}
51
52; Check negative displacements, which also need separate address logic.
53define float @f5(float %f1, float *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000054; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000055; CHECK: aghi %r2, -4
56; CHECK: deb %f0, 0(%r2)
57; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000058 %ptr = getelementptr float, float *%base, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +000059 %f2 = load float , float *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000060 %res = fdiv float %f1, %f2
61 ret float %res
62}
63
64; Check that DEB allows indices.
65define float @f6(float %f1, float *%base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +000066; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000067; CHECK: sllg %r1, %r3, 2
68; CHECK: deb %f0, 400(%r1,%r2)
69; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000070 %ptr1 = getelementptr float, float *%base, i64 %index
71 %ptr2 = getelementptr float, float *%ptr1, i64 100
David Blaikiea79ac142015-02-27 21:17:42 +000072 %f2 = load float , float *%ptr2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000073 %res = fdiv float %f1, %f2
74 ret float %res
75}
Richard Sandiforded1fab62013-07-03 10:10:02 +000076
77; Check that divisions of spilled values can use DEB rather than DEBR.
78define float @f7(float *%ptr0) {
Stephen Lind24ab202013-07-14 06:24:09 +000079; CHECK-LABEL: f7:
Richard Sandiforded1fab62013-07-03 10:10:02 +000080; CHECK: brasl %r14, foo@PLT
Ulrich Weigand33435c42017-07-17 17:42:48 +000081; CHECK-SCALAR: deb %f0, 16{{[04]}}(%r15)
Richard Sandiforded1fab62013-07-03 10:10:02 +000082; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000083 %ptr1 = getelementptr float, float *%ptr0, i64 2
84 %ptr2 = getelementptr float, float *%ptr0, i64 4
85 %ptr3 = getelementptr float, float *%ptr0, i64 6
86 %ptr4 = getelementptr float, float *%ptr0, i64 8
87 %ptr5 = getelementptr float, float *%ptr0, i64 10
88 %ptr6 = getelementptr float, float *%ptr0, i64 12
89 %ptr7 = getelementptr float, float *%ptr0, i64 14
90 %ptr8 = getelementptr float, float *%ptr0, i64 16
91 %ptr9 = getelementptr float, float *%ptr0, i64 18
92 %ptr10 = getelementptr float, float *%ptr0, i64 20
Richard Sandiforded1fab62013-07-03 10:10:02 +000093
David Blaikiea79ac142015-02-27 21:17:42 +000094 %val0 = load float , float *%ptr0
95 %val1 = load float , float *%ptr1
96 %val2 = load float , float *%ptr2
97 %val3 = load float , float *%ptr3
98 %val4 = load float , float *%ptr4
99 %val5 = load float , float *%ptr5
100 %val6 = load float , float *%ptr6
101 %val7 = load float , float *%ptr7
102 %val8 = load float , float *%ptr8
103 %val9 = load float , float *%ptr9
104 %val10 = load float , float *%ptr10
Richard Sandiforded1fab62013-07-03 10:10:02 +0000105
106 %ret = call float @foo()
107
108 %div0 = fdiv float %ret, %val0
109 %div1 = fdiv float %div0, %val1
110 %div2 = fdiv float %div1, %val2
111 %div3 = fdiv float %div2, %val3
112 %div4 = fdiv float %div3, %val4
113 %div5 = fdiv float %div4, %val5
114 %div6 = fdiv float %div5, %val6
115 %div7 = fdiv float %div6, %val7
116 %div8 = fdiv float %div7, %val8
117 %div9 = fdiv float %div8, %val9
118 %div10 = fdiv float %div9, %val10
119
120 ret float %div10
121}