1; Test 64-bit floating-point stores.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5
6; Test the low end of the STD range.
7define void @f1(double *%src, double %val) {
8; CHECK-LABEL: f1:
9; CHECK: std %f0, 0(%r2)
10; CHECK: br %r14
11  store double %val, double *%src
12  ret void
13}
14
15; Test the high end of the STD range.
16define void @f2(double *%src, double %val) {
17; CHECK-LABEL: f2:
18; CHECK: std %f0, 4088(%r2)
19; CHECK: br %r14
20  %ptr = getelementptr double, double *%src, i64 511
21  store double %val, double *%ptr
22  ret void
23}
24
25; Check the next doubleword up, which should use STDY instead of STD.
26define void @f3(double *%src, double %val) {
27; CHECK-LABEL: f3:
28; CHECK: stdy %f0, 4096(%r2)
29; CHECK: br %r14
30  %ptr = getelementptr double, double *%src, i64 512
31  store double %val, double *%ptr
32  ret void
33}
34
35; Check the high end of the aligned STDY range.
36define void @f4(double *%src, double %val) {
37; CHECK-LABEL: f4:
38; CHECK: stdy %f0, 524280(%r2)
39; CHECK: br %r14
40  %ptr = getelementptr double, double *%src, i64 65535
41  store double %val, double *%ptr
42  ret void
43}
44
45; Check the next doubleword up, which needs separate address logic.
46; Other sequences besides this one would be OK.
47define void @f5(double *%src, double %val) {
48; CHECK-LABEL: f5:
49; CHECK: agfi %r2, 524288
50; CHECK: std %f0, 0(%r2)
51; CHECK: br %r14
52  %ptr = getelementptr double, double *%src, i64 65536
53  store double %val, double *%ptr
54  ret void
55}
56
57; Check the high end of the negative aligned STDY range.
58define void @f6(double *%src, double %val) {
59; CHECK-LABEL: f6:
60; CHECK: stdy %f0, -8(%r2)
61; CHECK: br %r14
62  %ptr = getelementptr double, double *%src, i64 -1
63  store double %val, double *%ptr
64  ret void
65}
66
67; Check the low end of the STDY range.
68define void @f7(double *%src, double %val) {
69; CHECK-LABEL: f7:
70; CHECK: stdy %f0, -524288(%r2)
71; CHECK: br %r14
72  %ptr = getelementptr double, double *%src, i64 -65536
73  store double %val, double *%ptr
74  ret void
75}
76
77; Check the next doubleword down, which needs separate address logic.
78; Other sequences besides this one would be OK.
79define void @f8(double *%src, double %val) {
80; CHECK-LABEL: f8:
81; CHECK: agfi %r2, -524296
82; CHECK: std %f0, 0(%r2)
83; CHECK: br %r14
84  %ptr = getelementptr double, double *%src, i64 -65537
85  store double %val, double *%ptr
86  ret void
87}
88
89; Check that STD allows an index.
90define void @f9(i64 %src, i64 %index, double %val) {
91; CHECK-LABEL: f9:
92; CHECK: std %f0, 4095({{%r3,%r2|%r2,%r3}})
93; CHECK: br %r14
94  %add1 = add i64 %src, %index
95  %add2 = add i64 %add1, 4095
96  %ptr = inttoptr i64 %add2 to double *
97  store double %val, double *%ptr
98  ret void
99}
100
101; Check that STDY allows an index.
102define void @f10(i64 %src, i64 %index, double %val) {
103; CHECK-LABEL: f10:
104; CHECK: stdy %f0, 4096({{%r3,%r2|%r2,%r3}})
105; CHECK: br %r14
106  %add1 = add i64 %src, %index
107  %add2 = add i64 %add1, 4096
108  %ptr = inttoptr i64 %add2 to double *
109  store double %val, double *%ptr
110  ret void
111}
112