1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=aarch64 -mattr=+sve2p1 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-O0
3 ; RUN: llc -O3 -mtriple=aarch64 -mattr=+sve2p1 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-O3
6 ; Test simple loads, stores and return.
8 define target("aarch64.svcount") @test_load(ptr %ptr) nounwind {
9 ; CHECK-LABEL: test_load:
11 ; CHECK-NEXT: ldr p0, [x0]
13 %res = load target("aarch64.svcount"), ptr %ptr
14 ret target("aarch64.svcount") %res
17 define void @test_store(ptr %ptr, target("aarch64.svcount") %val) nounwind {
18 ; CHECK-LABEL: test_store:
20 ; CHECK-NEXT: str p0, [x0]
22 store target("aarch64.svcount") %val, ptr %ptr
26 define target("aarch64.svcount") @test_alloca_store_reload(target("aarch64.svcount") %val) nounwind {
27 ; CHECKO0-LABEL: test_alloca_store_reload:
29 ; CHECKO0-NEXT: sub sp, sp, #16
30 ; CHECKO0-NEXT: add x8, sp, #14
31 ; CHECKO0-NEXT: str p0, [x8]
32 ; CHECKO0-NEXT: ldr p0, [x8]
33 ; CHECKO0-NEXT: add sp, sp, #16
36 ; CHECKO3-LABEL: test_alloca_store_reload:
38 ; CHECKO3-NEXT: sub sp, sp, #16
39 ; CHECKO3-NEXT: add x8, sp, #14
40 ; CHECKO3-NEXT: str p0, [x8]
41 ; CHECKO3-NEXT: add sp, sp, #16
43 ; CHECK-O0-LABEL: test_alloca_store_reload:
45 ; CHECK-O0-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
46 ; CHECK-O0-NEXT: addvl sp, sp, #-1
47 ; CHECK-O0-NEXT: str p0, [sp, #7, mul vl]
48 ; CHECK-O0-NEXT: ldr p0, [sp, #7, mul vl]
49 ; CHECK-O0-NEXT: addvl sp, sp, #1
50 ; CHECK-O0-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
53 ; CHECK-O3-LABEL: test_alloca_store_reload:
55 ; CHECK-O3-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
56 ; CHECK-O3-NEXT: addvl sp, sp, #-1
57 ; CHECK-O3-NEXT: str p0, [sp, #7, mul vl]
58 ; CHECK-O3-NEXT: addvl sp, sp, #1
59 ; CHECK-O3-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
61 %ptr = alloca target("aarch64.svcount"), align 1
62 store target("aarch64.svcount") %val, ptr %ptr
63 %res = load target("aarch64.svcount"), ptr %ptr
64 ret target("aarch64.svcount") %res
68 ; Test passing as arguments (from perspective of callee)
71 define target("aarch64.svcount") @test_return_arg1(target("aarch64.svcount") %arg0, target("aarch64.svcount") %arg1) nounwind {
72 ; CHECK-LABEL: test_return_arg1:
74 ; CHECK-NEXT: mov p0.b, p1.b
76 ret target("aarch64.svcount") %arg1
79 define target("aarch64.svcount") @test_return_arg4(target("aarch64.svcount") %arg0, target("aarch64.svcount") %arg1, target("aarch64.svcount") %arg2, target("aarch64.svcount") %arg3, target("aarch64.svcount") %arg4) nounwind {
80 ; CHECK-LABEL: test_return_arg4:
82 ; CHECK-NEXT: ldr p0, [x0]
84 ret target("aarch64.svcount") %arg4
88 ; Test passing as arguments (from perspective of caller)
91 declare void @take_svcount_1(target("aarch64.svcount") %arg)
92 define void @test_pass_1arg(target("aarch64.svcount") %arg) nounwind {
93 ; CHECK-LABEL: test_pass_1arg:
95 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
96 ; CHECK-NEXT: bl take_svcount_1
97 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
99 call void @take_svcount_1(target("aarch64.svcount") %arg)
103 declare void @take_svcount_5(target("aarch64.svcount") %arg0, target("aarch64.svcount") %arg1, target("aarch64.svcount") %arg2, target("aarch64.svcount") %arg3, target("aarch64.svcount") %arg4)
104 define void @test_pass_5args(target("aarch64.svcount") %arg) nounwind {
105 ; CHECKO0-LABEL: test_pass_5args:
107 ; CHECKO0-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
108 ; CHECKO0-NEXT: addvl sp, sp, #-1
109 ; CHECKO0-NEXT: mov p3.b, p0.b
110 ; CHECKO0-NEXT: str p3, [sp, #7, mul vl]
111 ; CHECKO0-NEXT: addpl x0, sp, #7
112 ; CHECKO0-NEXT: mov p0.b, p3.b
113 ; CHECKO0-NEXT: mov p1.b, p3.b
114 ; CHECKO0-NEXT: mov p2.b, p3.b
115 ; CHECKO0-NEXT: bl take_svcount_5
116 ; CHECKO0-NEXT: addvl sp, sp, #1
117 ; CHECKO0-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
120 ; CHECKO3-LABEL: test_pass_5args:
122 ; CHECKO3-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
123 ; CHECKO3-NEXT: addvl sp, sp, #-1
124 ; CHECKO3-NEXT: addpl x0, sp, #7
125 ; CHECKO3-NEXT: mov p1.b, p0.b
126 ; CHECKO3-NEXT: mov p2.b, p0.b
127 ; CHECKO3-NEXT: mov p3.b, p0.b
128 ; CHECKO3-NEXT: str p0, [sp, #7, mul vl]
129 ; CHECKO3-NEXT: bl take_svcount_5
130 ; CHECKO3-NEXT: addvl sp, sp, #1
131 ; CHECKO3-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
133 ; CHECK-O0-LABEL: test_pass_5args:
134 ; CHECK-O0: // %bb.0:
135 ; CHECK-O0-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
136 ; CHECK-O0-NEXT: addvl sp, sp, #-1
137 ; CHECK-O0-NEXT: mov p3.b, p0.b
138 ; CHECK-O0-NEXT: str p3, [sp, #7, mul vl]
139 ; CHECK-O0-NEXT: addpl x0, sp, #7
140 ; CHECK-O0-NEXT: mov p0.b, p3.b
141 ; CHECK-O0-NEXT: mov p1.b, p3.b
142 ; CHECK-O0-NEXT: mov p2.b, p3.b
143 ; CHECK-O0-NEXT: bl take_svcount_5
144 ; CHECK-O0-NEXT: addvl sp, sp, #1
145 ; CHECK-O0-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
148 ; CHECK-O3-LABEL: test_pass_5args:
149 ; CHECK-O3: // %bb.0:
150 ; CHECK-O3-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
151 ; CHECK-O3-NEXT: addvl sp, sp, #-1
152 ; CHECK-O3-NEXT: mov p1.b, p0.b
153 ; CHECK-O3-NEXT: addpl x0, sp, #7
154 ; CHECK-O3-NEXT: str p0, [sp, #7, mul vl]
155 ; CHECK-O3-NEXT: mov p2.b, p0.b
156 ; CHECK-O3-NEXT: mov p3.b, p0.b
157 ; CHECK-O3-NEXT: bl take_svcount_5
158 ; CHECK-O3-NEXT: addvl sp, sp, #1
159 ; CHECK-O3-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
161 call void @take_svcount_5(target("aarch64.svcount") %arg, target("aarch64.svcount") %arg, target("aarch64.svcount") %arg, target("aarch64.svcount") %arg, target("aarch64.svcount") %arg)
165 define target("aarch64.svcount") @test_sel(target("aarch64.svcount") %x, target("aarch64.svcount") %y, i1 %cmp) {
166 ; CHECK-O0-LABEL: test_sel:
167 ; CHECK-O0: // %bb.0:
168 ; CHECK-O0-NEXT: mov p2.b, p1.b
169 ; CHECK-O0-NEXT: mov p1.b, p0.b
170 ; CHECK-O0-NEXT: // implicit-def: $x8
171 ; CHECK-O0-NEXT: mov w8, w0
172 ; CHECK-O0-NEXT: sbfx x9, x8, #0, #1
173 ; CHECK-O0-NEXT: mov x8, xzr
174 ; CHECK-O0-NEXT: whilelo p0.b, x8, x9
175 ; CHECK-O0-NEXT: sel p0.b, p0, p1.b, p2.b
178 ; CHECK-O3-LABEL: test_sel:
179 ; CHECK-O3: // %bb.0:
180 ; CHECK-O3-NEXT: // kill: def $w0 killed $w0 def $x0
181 ; CHECK-O3-NEXT: sbfx x8, x0, #0, #1
182 ; CHECK-O3-NEXT: whilelo p2.b, xzr, x8
183 ; CHECK-O3-NEXT: sel p0.b, p2, p0.b, p1.b
185 %x.y = select i1 %cmp, target("aarch64.svcount") %x, target("aarch64.svcount") %y
186 ret target("aarch64.svcount") %x.y
189 define target("aarch64.svcount") @test_sel_cc(target("aarch64.svcount") %x, target("aarch64.svcount") %y, i32 %k) {
190 ; CHECK-O0-LABEL: test_sel_cc:
191 ; CHECK-O0: // %bb.0:
192 ; CHECK-O0-NEXT: mov p2.b, p1.b
193 ; CHECK-O0-NEXT: mov p1.b, p0.b
194 ; CHECK-O0-NEXT: subs w8, w0, #42
195 ; CHECK-O0-NEXT: cset w9, gt
196 ; CHECK-O0-NEXT: // implicit-def: $x8
197 ; CHECK-O0-NEXT: mov w8, w9
198 ; CHECK-O0-NEXT: sbfx x9, x8, #0, #1
199 ; CHECK-O0-NEXT: mov x8, xzr
200 ; CHECK-O0-NEXT: whilelo p0.b, x8, x9
201 ; CHECK-O0-NEXT: sel p0.b, p0, p1.b, p2.b
204 ; CHECK-O3-LABEL: test_sel_cc:
205 ; CHECK-O3: // %bb.0:
206 ; CHECK-O3-NEXT: cmp w0, #42
207 ; CHECK-O3-NEXT: cset w8, gt
208 ; CHECK-O3-NEXT: sbfx x8, x8, #0, #1
209 ; CHECK-O3-NEXT: whilelo p2.b, xzr, x8
210 ; CHECK-O3-NEXT: sel p0.b, p2, p0.b, p1.b
212 %cmp = icmp sgt i32 %k, 42
213 %x.y = select i1 %cmp, target("aarch64.svcount") %x, target("aarch64.svcount") %y
214 ret target("aarch64.svcount") %x.y