blob: 701304ef3ee57d0e0ac9bd24e0801d44a7e2bd2a [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test multiplication of two f64s, producing an f64 result.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
Richard Sandiforded1fab62013-07-03 10:10:02 +00005declare double @foo()
6
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00007; Check register multiplication.
8define double @f1(double %f1, double %f2) {
Stephen Lind24ab202013-07-14 06:24:09 +00009; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: mdbr %f0, %f2
11; CHECK: br %r14
12 %res = fmul double %f1, %f2
13 ret double %res
14}
15
16; Check the low end of the MDB range.
17define double @f2(double %f1, double *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000018; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000019; CHECK: mdb %f0, 0(%r2)
20; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000021 %f2 = load double , double *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022 %res = fmul double %f1, %f2
23 ret double %res
24}
25
26; Check the high end of the aligned MDB range.
27define double @f3(double %f1, double *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000028; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000029; CHECK: mdb %f0, 4088(%r2)
30; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000031 %ptr = getelementptr double, double *%base, i64 511
David Blaikiea79ac142015-02-27 21:17:42 +000032 %f2 = load double , double *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000033 %res = fmul 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000040; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000041; CHECK: aghi %r2, 4096
42; CHECK: mdb %f0, 0(%r2)
43; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000044 %ptr = getelementptr double, double *%base, i64 512
David Blaikiea79ac142015-02-27 21:17:42 +000045 %f2 = load double , double *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000046 %res = fmul 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) {
Stephen Lind24ab202013-07-14 06:24:09 +000052; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000053; CHECK: aghi %r2, -8
54; CHECK: mdb %f0, 0(%r2)
55; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000056 %ptr = getelementptr double, double *%base, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +000057 %f2 = load double , double *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058 %res = fmul double %f1, %f2
59 ret double %res
60}
61
62; Check that MDB allows indices.
63define double @f6(double %f1, double *%base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +000064; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000065; CHECK: sllg %r1, %r3, 3
66; CHECK: mdb %f0, 800(%r1,%r2)
67; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000068 %ptr1 = getelementptr double, double *%base, i64 %index
69 %ptr2 = getelementptr double, double *%ptr1, i64 100
David Blaikiea79ac142015-02-27 21:17:42 +000070 %f2 = load double , double *%ptr2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000071 %res = fmul double %f1, %f2
72 ret double %res
73}
Richard Sandiforded1fab62013-07-03 10:10:02 +000074
75; Check that multiplications of spilled values can use MDB rather than MDBR.
76define double @f7(double *%ptr0) {
Stephen Lind24ab202013-07-14 06:24:09 +000077; CHECK-LABEL: f7:
Richard Sandiforded1fab62013-07-03 10:10:02 +000078; CHECK: brasl %r14, foo@PLT
79; CHECK: mdb %f0, 160(%r15)
80; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000081 %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
Richard Sandiforded1fab62013-07-03 10:10:02 +000091
David Blaikiea79ac142015-02-27 21:17:42 +000092 %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
Richard Sandiforded1fab62013-07-03 10:10:02 +0000103
104 %ret = call double @foo()
105
106 %mul0 = fmul double %ret, %val0
107 %mul1 = fmul double %mul0, %val1
108 %mul2 = fmul double %mul1, %val2
109 %mul3 = fmul double %mul2, %val3
110 %mul4 = fmul double %mul3, %val4
111 %mul5 = fmul double %mul4, %val5
112 %mul6 = fmul double %mul5, %val6
113 %mul7 = fmul double %mul6, %val7
114 %mul8 = fmul double %mul7, %val8
115 %mul9 = fmul double %mul8, %val9
116 %mul10 = fmul double %mul9, %val10
117
118 ret double %mul10
119}