1; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
2
3declare float @llvm.fma.f32(float %f1, float %f2, float %f3)
4
5define float @f1(float %f1, float %f2, float %acc) {
6; CHECK-LABEL: f1:
7; CHECK: maebr %f4, %f0, %f2
8; CHECK: ler %f0, %f4
9; CHECK: br %r14
10  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
11  ret float %res
12}
13
14define float @f2(float %f1, float *%ptr, float %acc) {
15; CHECK-LABEL: f2:
16; CHECK: maeb %f2, %f0, 0(%r2)
17; CHECK: ler %f0, %f2
18; CHECK: br %r14
19  %f2 = load float , float *%ptr
20  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
21  ret float %res
22}
23
24define float @f3(float %f1, float *%base, float %acc) {
25; CHECK-LABEL: f3:
26; CHECK: maeb %f2, %f0, 4092(%r2)
27; CHECK: ler %f0, %f2
28; CHECK: br %r14
29  %ptr = getelementptr float, float *%base, i64 1023
30  %f2 = load float , float *%ptr
31  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
32  ret float %res
33}
34
35define float @f4(float %f1, float *%base, float %acc) {
36; The important thing here is that we don't generate an out-of-range
37; displacement.  Other sequences besides this one would be OK.
38;
39; CHECK-LABEL: f4:
40; CHECK: aghi %r2, 4096
41; CHECK: maeb %f2, %f0, 0(%r2)
42; CHECK: ler %f0, %f2
43; CHECK: br %r14
44  %ptr = getelementptr float, float *%base, i64 1024
45  %f2 = load float , float *%ptr
46  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
47  ret float %res
48}
49
50define float @f5(float %f1, float *%base, float %acc) {
51; Here too the important thing is that we don't generate an out-of-range
52; displacement.  Other sequences besides this one would be OK.
53;
54; CHECK-LABEL: f5:
55; CHECK: aghi %r2, -4
56; CHECK: maeb %f2, %f0, 0(%r2)
57; CHECK: ler %f0, %f2
58; CHECK: br %r14
59  %ptr = getelementptr float, float *%base, i64 -1
60  %f2 = load float , float *%ptr
61  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
62  ret float %res
63}
64
65define float @f6(float %f1, float *%base, i64 %index, float %acc) {
66; CHECK-LABEL: f6:
67; CHECK: sllg %r1, %r3, 2
68; CHECK: maeb %f2, %f0, 0(%r1,%r2)
69; CHECK: ler %f0, %f2
70; CHECK: br %r14
71  %ptr = getelementptr float, float *%base, i64 %index
72  %f2 = load float , float *%ptr
73  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
74  ret float %res
75}
76
77define float @f7(float %f1, float *%base, i64 %index, float %acc) {
78; CHECK-LABEL: f7:
79; CHECK: sllg %r1, %r3, 2
80; CHECK: maeb %f2, %f0, 4092({{%r1,%r2|%r2,%r1}})
81; CHECK: ler %f0, %f2
82; CHECK: br %r14
83  %index2 = add i64 %index, 1023
84  %ptr = getelementptr float, float *%base, i64 %index2
85  %f2 = load float , float *%ptr
86  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
87  ret float %res
88}
89
90define float @f8(float %f1, float *%base, i64 %index, float %acc) {
91; CHECK-LABEL: f8:
92; CHECK: sllg %r1, %r3, 2
93; CHECK: lay %r1, 4096({{%r1,%r2|%r2,%r1}})
94; CHECK: maeb %f2, %f0, 0(%r1)
95; CHECK: ler %f0, %f2
96; CHECK: br %r14
97  %index2 = add i64 %index, 1024
98  %ptr = getelementptr float, float *%base, i64 %index2
99  %f2 = load float , float *%ptr
100  %res = call float @llvm.fma.f32 (float %f1, float %f2, float %acc)
101  ret float %res
102}
103