1; Test strict multiplication of two f32s, producing an f32 result.
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=z14 | FileCheck %s
6
7declare float @foo()
8declare float @llvm.experimental.constrained.fmul.f32(float, float, metadata, metadata)
9
10; Check register multiplication.
11define float @f1(float %f1, float %f2) #0 {
12; CHECK-LABEL: f1:
13; CHECK: meebr %f0, %f2
14; CHECK: br %r14
15  %res = call float @llvm.experimental.constrained.fmul.f32(
16                        float %f1, float %f2,
17                        metadata !"round.dynamic",
18                        metadata !"fpexcept.strict") #0
19  ret float %res
20}
21
22; Check the low end of the MEEB range.
23define float @f2(float %f1, float *%ptr) #0 {
24; CHECK-LABEL: f2:
25; CHECK: meeb %f0, 0(%r2)
26; CHECK: br %r14
27  %f2 = load float, float *%ptr
28  %res = call float @llvm.experimental.constrained.fmul.f32(
29                        float %f1, float %f2,
30                        metadata !"round.dynamic",
31                        metadata !"fpexcept.strict") #0
32  ret float %res
33}
34
35; Check the high end of the aligned MEEB range.
36define float @f3(float %f1, float *%base) #0 {
37; CHECK-LABEL: f3:
38; CHECK: meeb %f0, 4092(%r2)
39; CHECK: br %r14
40  %ptr = getelementptr float, float *%base, i64 1023
41  %f2 = load float, float *%ptr
42  %res = call float @llvm.experimental.constrained.fmul.f32(
43                        float %f1, float %f2,
44                        metadata !"round.dynamic",
45                        metadata !"fpexcept.strict") #0
46  ret float %res
47}
48
49; Check the next word up, which needs separate address logic.
50; Other sequences besides this one would be OK.
51define float @f4(float %f1, float *%base) #0 {
52; CHECK-LABEL: f4:
53; CHECK: aghi %r2, 4096
54; CHECK: meeb %f0, 0(%r2)
55; CHECK: br %r14
56  %ptr = getelementptr float, float *%base, i64 1024
57  %f2 = load float, float *%ptr
58  %res = call float @llvm.experimental.constrained.fmul.f32(
59                        float %f1, float %f2,
60                        metadata !"round.dynamic",
61                        metadata !"fpexcept.strict") #0
62  ret float %res
63}
64
65; Check negative displacements, which also need separate address logic.
66define float @f5(float %f1, float *%base) #0 {
67; CHECK-LABEL: f5:
68; CHECK: aghi %r2, -4
69; CHECK: meeb %f0, 0(%r2)
70; CHECK: br %r14
71  %ptr = getelementptr float, float *%base, i64 -1
72  %f2 = load float, float *%ptr
73  %res = call float @llvm.experimental.constrained.fmul.f32(
74                        float %f1, float %f2,
75                        metadata !"round.dynamic",
76                        metadata !"fpexcept.strict") #0
77  ret float %res
78}
79
80; Check that MEEB allows indices.
81define float @f6(float %f1, float *%base, i64 %index) #0 {
82; CHECK-LABEL: f6:
83; CHECK: sllg %r1, %r3, 2
84; CHECK: meeb %f0, 400(%r1,%r2)
85; CHECK: br %r14
86  %ptr1 = getelementptr float, float *%base, i64 %index
87  %ptr2 = getelementptr float, float *%ptr1, i64 100
88  %f2 = load float, float *%ptr2
89  %res = call float @llvm.experimental.constrained.fmul.f32(
90                        float %f1, float %f2,
91                        metadata !"round.dynamic",
92                        metadata !"fpexcept.strict") #0
93  ret float %res
94}
95
96; Check that multiplications of spilled values can use MEEB rather than MEEBR.
97define float @f7(float *%ptr0) #0 {
98; CHECK-LABEL: f7:
99; CHECK: brasl %r14, foo@PLT
100; CHECK-SCALAR: meeb %f0, 16{{[04]}}(%r15)
101; CHECK: br %r14
102  %ptr1 = getelementptr float, float *%ptr0, i64 2
103  %ptr2 = getelementptr float, float *%ptr0, i64 4
104  %ptr3 = getelementptr float, float *%ptr0, i64 6
105  %ptr4 = getelementptr float, float *%ptr0, i64 8
106  %ptr5 = getelementptr float, float *%ptr0, i64 10
107  %ptr6 = getelementptr float, float *%ptr0, i64 12
108  %ptr7 = getelementptr float, float *%ptr0, i64 14
109  %ptr8 = getelementptr float, float *%ptr0, i64 16
110  %ptr9 = getelementptr float, float *%ptr0, i64 18
111  %ptr10 = getelementptr float, float *%ptr0, i64 20
112
113  %val0 = load float, float *%ptr0
114  %val1 = load float, float *%ptr1
115  %val2 = load float, float *%ptr2
116  %val3 = load float, float *%ptr3
117  %val4 = load float, float *%ptr4
118  %val5 = load float, float *%ptr5
119  %val6 = load float, float *%ptr6
120  %val7 = load float, float *%ptr7
121  %val8 = load float, float *%ptr8
122  %val9 = load float, float *%ptr9
123  %val10 = load float, float *%ptr10
124
125  %ret = call float @foo() #0
126
127  %mul0 = call float @llvm.experimental.constrained.fmul.f32(
128                        float %ret, float %val0,
129                        metadata !"round.dynamic",
130                        metadata !"fpexcept.strict") #0
131  %mul1 = call float @llvm.experimental.constrained.fmul.f32(
132                        float %mul0, float %val1,
133                        metadata !"round.dynamic",
134                        metadata !"fpexcept.strict") #0
135  %mul2 = call float @llvm.experimental.constrained.fmul.f32(
136                        float %mul1, float %val2,
137                        metadata !"round.dynamic",
138                        metadata !"fpexcept.strict") #0
139  %mul3 = call float @llvm.experimental.constrained.fmul.f32(
140                        float %mul2, float %val3,
141                        metadata !"round.dynamic",
142                        metadata !"fpexcept.strict") #0
143  %mul4 = call float @llvm.experimental.constrained.fmul.f32(
144                        float %mul3, float %val4,
145                        metadata !"round.dynamic",
146                        metadata !"fpexcept.strict") #0
147  %mul5 = call float @llvm.experimental.constrained.fmul.f32(
148                        float %mul4, float %val5,
149                        metadata !"round.dynamic",
150                        metadata !"fpexcept.strict") #0
151  %mul6 = call float @llvm.experimental.constrained.fmul.f32(
152                        float %mul5, float %val6,
153                        metadata !"round.dynamic",
154                        metadata !"fpexcept.strict") #0
155  %mul7 = call float @llvm.experimental.constrained.fmul.f32(
156                        float %mul6, float %val7,
157                        metadata !"round.dynamic",
158                        metadata !"fpexcept.strict") #0
159  %mul8 = call float @llvm.experimental.constrained.fmul.f32(
160                        float %mul7, float %val8,
161                        metadata !"round.dynamic",
162                        metadata !"fpexcept.strict") #0
163  %mul9 = call float @llvm.experimental.constrained.fmul.f32(
164                        float %mul8, float %val9,
165                        metadata !"round.dynamic",
166                        metadata !"fpexcept.strict") #0
167  %mul10 = call float @llvm.experimental.constrained.fmul.f32(
168                        float %mul9, float %val10,
169                        metadata !"round.dynamic",
170                        metadata !"fpexcept.strict") #0
171
172  ret float %mul10
173}
174
175attributes #0 = { strictfp }
176