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