1 ; Test f64 conditional stores that are presented as selects.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
7 ; Test with the loaded value first.
8 define void @f1(ptr %ptr, double %alt, i32 %limit) {
13 ; CHECK: std %f0, 0(%r2)
15 %cond = icmp ult i32 %limit, 420
16 %orig = load double, ptr %ptr
17 %res = select i1 %cond, double %orig, double %alt
18 store double %res, ptr %ptr
22 ; ...and with the loaded value second
23 define void @f2(ptr %ptr, double %alt, i32 %limit) {
28 ; CHECK: std %f0, 0(%r2)
30 %cond = icmp ult i32 %limit, 420
31 %orig = load double, ptr %ptr
32 %res = select i1 %cond, double %alt, double %orig
33 store double %res, ptr %ptr
37 ; Check the high end of the aligned STD range.
38 define void @f3(ptr %base, double %alt, i32 %limit) {
43 ; CHECK: std %f0, 4088(%r2)
45 %ptr = getelementptr double, ptr %base, i64 511
46 %cond = icmp ult i32 %limit, 420
47 %orig = load double, ptr %ptr
48 %res = select i1 %cond, double %orig, double %alt
49 store double %res, ptr %ptr
53 ; Check the next doubleword up, which should use STDY instead of STD.
54 define void @f4(ptr %base, double %alt, i32 %limit) {
59 ; CHECK: stdy %f0, 4096(%r2)
61 %ptr = getelementptr double, ptr %base, i64 512
62 %cond = icmp ult i32 %limit, 420
63 %orig = load double, ptr %ptr
64 %res = select i1 %cond, double %orig, double %alt
65 store double %res, ptr %ptr
69 ; Check the high end of the aligned STDY range.
70 define void @f5(ptr %base, double %alt, i32 %limit) {
75 ; CHECK: stdy %f0, 524280(%r2)
77 %ptr = getelementptr double, ptr %base, i64 65535
78 %cond = icmp ult i32 %limit, 420
79 %orig = load double, ptr %ptr
80 %res = select i1 %cond, double %orig, double %alt
81 store double %res, ptr %ptr
85 ; Check the next doubleword up, which needs separate address logic.
86 ; Other sequences besides this one would be OK.
87 define void @f6(ptr %base, double %alt, i32 %limit) {
92 ; CHECK: agfi %r2, 524288
93 ; CHECK: std %f0, 0(%r2)
95 %ptr = getelementptr double, ptr %base, i64 65536
96 %cond = icmp ult i32 %limit, 420
97 %orig = load double, ptr %ptr
98 %res = select i1 %cond, double %orig, double %alt
99 store double %res, ptr %ptr
103 ; Check the low end of the STDY range.
104 define void @f7(ptr %base, double %alt, i32 %limit) {
109 ; CHECK: stdy %f0, -524288(%r2)
111 %ptr = getelementptr double, ptr %base, i64 -65536
112 %cond = icmp ult i32 %limit, 420
113 %orig = load double, ptr %ptr
114 %res = select i1 %cond, double %orig, double %alt
115 store double %res, ptr %ptr
119 ; Check the next doubleword down, which needs separate address logic.
120 ; Other sequences besides this one would be OK.
121 define void @f8(ptr %base, double %alt, i32 %limit) {
126 ; CHECK: agfi %r2, -524296
127 ; CHECK: std %f0, 0(%r2)
129 %ptr = getelementptr double, ptr %base, i64 -65537
130 %cond = icmp ult i32 %limit, 420
131 %orig = load double, ptr %ptr
132 %res = select i1 %cond, double %orig, double %alt
133 store double %res, ptr %ptr
137 ; Check that STDY allows an index.
138 define void @f9(i64 %base, i64 %index, double %alt, i32 %limit) {
143 ; CHECK: stdy %f0, 524287(%r3,%r2)
145 %add1 = add i64 %base, %index
146 %add2 = add i64 %add1, 524287
147 %ptr = inttoptr i64 %add2 to ptr
148 %cond = icmp ult i32 %limit, 420
149 %orig = load double, ptr %ptr
150 %res = select i1 %cond, double %orig, double %alt
151 store double %res, ptr %ptr
155 ; Check that volatile loads are not matched.
156 define void @f10(ptr %ptr, double %alt, i32 %limit) {
158 ; CHECK: ld {{%f[0-5]}}, 0(%r2)
159 ; CHECK: {{jl|jnl}} [[LABEL:[^ ]*]]
161 ; CHECK: std {{%f[0-5]}}, 0(%r2)
163 %cond = icmp ult i32 %limit, 420
164 %orig = load volatile double, ptr %ptr
165 %res = select i1 %cond, double %orig, double %alt
166 store double %res, ptr %ptr
170 ; ...likewise stores. In this case we should have a conditional load into %f0.
171 define void @f11(ptr %ptr, double %alt, i32 %limit) {
173 ; CHECK: jhe [[LABEL:[^ ]*]]
174 ; CHECK: ld %f0, 0(%r2)
176 ; CHECK: std %f0, 0(%r2)
178 %cond = icmp ult i32 %limit, 420
179 %orig = load double, ptr %ptr
180 %res = select i1 %cond, double %orig, double %alt
181 store volatile double %res, ptr %ptr
185 ; Try a frame index base.
186 define void @f12(double %alt, i32 %limit) {
188 ; CHECK: brasl %r14, foo@PLT
190 ; CHECK: jl [[LABEL:[^ ]*]]
192 ; CHECK: std {{%f[0-9]+}}, {{[0-9]+}}(%r15)
194 ; CHECK: brasl %r14, foo@PLT
197 call void @foo(ptr %ptr)
198 %cond = icmp ult i32 %limit, 420
199 %orig = load double, ptr %ptr
200 %res = select i1 %cond, double %orig, double %alt
201 store double %res, ptr %ptr
202 call void @foo(ptr %ptr)