1 ; Test f32 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, float %alt, i32 %limit) {
13 ; CHECK: ste %f0, 0(%r2)
15 %cond = icmp ult i32 %limit, 420
16 %orig = load float, ptr %ptr
17 %res = select i1 %cond, float %orig, float %alt
18 store float %res, ptr %ptr
22 ; ...and with the loaded value second
23 define void @f2(ptr %ptr, float %alt, i32 %limit) {
28 ; CHECK: ste %f0, 0(%r2)
30 %cond = icmp ult i32 %limit, 420
31 %orig = load float, ptr %ptr
32 %res = select i1 %cond, float %alt, float %orig
33 store float %res, ptr %ptr
37 ; Check the high end of the aligned STE range.
38 define void @f3(ptr %base, float %alt, i32 %limit) {
43 ; CHECK: ste %f0, 4092(%r2)
45 %ptr = getelementptr float, ptr %base, i64 1023
46 %cond = icmp ult i32 %limit, 420
47 %orig = load float, ptr %ptr
48 %res = select i1 %cond, float %orig, float %alt
49 store float %res, ptr %ptr
53 ; Check the next word up, which should use STEY instead of STE.
54 define void @f4(ptr %base, float %alt, i32 %limit) {
59 ; CHECK: stey %f0, 4096(%r2)
61 %ptr = getelementptr float, ptr %base, i64 1024
62 %cond = icmp ult i32 %limit, 420
63 %orig = load float, ptr %ptr
64 %res = select i1 %cond, float %orig, float %alt
65 store float %res, ptr %ptr
69 ; Check the high end of the aligned STEY range.
70 define void @f5(ptr %base, float %alt, i32 %limit) {
75 ; CHECK: stey %f0, 524284(%r2)
77 %ptr = getelementptr float, ptr %base, i64 131071
78 %cond = icmp ult i32 %limit, 420
79 %orig = load float, ptr %ptr
80 %res = select i1 %cond, float %orig, float %alt
81 store float %res, ptr %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(ptr %base, float %alt, i32 %limit) {
92 ; CHECK: agfi %r2, 524288
93 ; CHECK: ste %f0, 0(%r2)
95 %ptr = getelementptr float, ptr %base, i64 131072
96 %cond = icmp ult i32 %limit, 420
97 %orig = load float, ptr %ptr
98 %res = select i1 %cond, float %orig, float %alt
99 store float %res, ptr %ptr
103 ; Check the low end of the STEY range.
104 define void @f7(ptr %base, float %alt, i32 %limit) {
109 ; CHECK: stey %f0, -524288(%r2)
111 %ptr = getelementptr float, ptr %base, i64 -131072
112 %cond = icmp ult i32 %limit, 420
113 %orig = load float, ptr %ptr
114 %res = select i1 %cond, float %orig, float %alt
115 store float %res, ptr %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(ptr %base, float %alt, i32 %limit) {
126 ; CHECK: agfi %r2, -524292
127 ; CHECK: ste %f0, 0(%r2)
129 %ptr = getelementptr float, ptr %base, i64 -131073
130 %cond = icmp ult i32 %limit, 420
131 %orig = load float, ptr %ptr
132 %res = select i1 %cond, float %orig, float %alt
133 store float %res, ptr %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 ptr
148 %cond = icmp ult i32 %limit, 420
149 %orig = load float, ptr %ptr
150 %res = select i1 %cond, float %orig, float %alt
151 store float %res, ptr %ptr
155 ; Check that volatile loads are not matched.
156 define void @f10(ptr %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, ptr %ptr
165 %res = select i1 %cond, float %orig, float %alt
166 store float %res, ptr %ptr
170 ; ...likewise stores. In this case we should have a conditional load into %f0.
171 define void @f11(ptr %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, ptr %ptr
180 %res = select i1 %cond, float %orig, float %alt
181 store volatile float %res, ptr %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(ptr %ptr)
198 %cond = icmp ult i32 %limit, 420
199 %orig = load float, ptr %ptr
200 %res = select i1 %cond, float %orig, float %alt
201 store float %res, ptr %ptr
202 call void @foo(ptr %ptr)