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 ; CHECK-O0-LABEL: test_alloca_store_reload:
29 ; CHECK-O0-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
30 ; CHECK-O0-NEXT: addvl sp, sp, #-1
31 ; CHECK-O0-NEXT: str p0, [sp, #7, mul vl]
32 ; CHECK-O0-NEXT: ldr p0, [sp, #7, mul vl]
33 ; CHECK-O0-NEXT: addvl sp, sp, #1
34 ; CHECK-O0-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
37 ; CHECK-O3-LABEL: test_alloca_store_reload:
39 ; CHECK-O3-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
40 ; CHECK-O3-NEXT: addvl sp, sp, #-1
41 ; CHECK-O3-NEXT: str p0, [sp, #7, mul vl]
42 ; CHECK-O3-NEXT: addvl sp, sp, #1
43 ; CHECK-O3-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
45 %ptr = alloca target("aarch64.svcount"), align 1
46 store target("aarch64.svcount") %val, ptr %ptr
47 %res = load target("aarch64.svcount"), ptr %ptr
48 ret target("aarch64.svcount") %res
52 ; Test passing as arguments (from perspective of callee)
55 define target("aarch64.svcount") @test_return_arg1(target("aarch64.svcount") %arg0, target("aarch64.svcount") %arg1) nounwind {
56 ; CHECK-LABEL: test_return_arg1:
58 ; CHECK-NEXT: mov p0.b, p1.b
60 ret target("aarch64.svcount") %arg1
63 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 {
64 ; CHECK-LABEL: test_return_arg4:
66 ; CHECK-NEXT: ldr p0, [x0]
68 ret target("aarch64.svcount") %arg4
72 ; Test passing as arguments (from perspective of caller)
75 declare void @take_svcount_1(target("aarch64.svcount") %arg)
76 define void @test_pass_1arg(target("aarch64.svcount") %arg) nounwind {
77 ; CHECK-LABEL: test_pass_1arg:
79 ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
80 ; CHECK-NEXT: bl take_svcount_1
81 ; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
83 call void @take_svcount_1(target("aarch64.svcount") %arg)
87 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)
88 define void @test_pass_5args(target("aarch64.svcount") %arg) nounwind {
89 ; CHECK-O0-LABEL: test_pass_5args:
91 ; CHECK-O0-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
92 ; CHECK-O0-NEXT: addvl sp, sp, #-1
93 ; CHECK-O0-NEXT: mov p3.b, p0.b
94 ; CHECK-O0-NEXT: str p3, [sp, #7, mul vl]
95 ; CHECK-O0-NEXT: addpl x0, sp, #7
96 ; CHECK-O0-NEXT: mov p0.b, p3.b
97 ; CHECK-O0-NEXT: mov p1.b, p3.b
98 ; CHECK-O0-NEXT: mov p2.b, p3.b
99 ; CHECK-O0-NEXT: bl take_svcount_5
100 ; CHECK-O0-NEXT: addvl sp, sp, #1
101 ; CHECK-O0-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
104 ; CHECK-O3-LABEL: test_pass_5args:
105 ; CHECK-O3: // %bb.0:
106 ; CHECK-O3-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
107 ; CHECK-O3-NEXT: addvl sp, sp, #-1
108 ; CHECK-O3-NEXT: mov p1.b, p0.b
109 ; CHECK-O3-NEXT: addpl x0, sp, #7
110 ; CHECK-O3-NEXT: str p0, [sp, #7, mul vl]
111 ; CHECK-O3-NEXT: mov p2.b, p0.b
112 ; CHECK-O3-NEXT: mov p3.b, p0.b
113 ; CHECK-O3-NEXT: bl take_svcount_5
114 ; CHECK-O3-NEXT: addvl sp, sp, #1
115 ; CHECK-O3-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload
117 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)
121 define target("aarch64.svcount") @test_sel(target("aarch64.svcount") %x, target("aarch64.svcount") %y, i1 %cmp) {
122 ; CHECK-O0-LABEL: test_sel:
123 ; CHECK-O0: // %bb.0:
124 ; CHECK-O0-NEXT: mov p2.b, p1.b
125 ; CHECK-O0-NEXT: mov p1.b, p0.b
126 ; CHECK-O0-NEXT: // implicit-def: $x8
127 ; CHECK-O0-NEXT: mov w8, w0
128 ; CHECK-O0-NEXT: sbfx x9, x8, #0, #1
129 ; CHECK-O0-NEXT: mov x8, xzr
130 ; CHECK-O0-NEXT: whilelo p0.b, x8, x9
131 ; CHECK-O0-NEXT: sel p0.b, p0, p1.b, p2.b
134 ; CHECK-O3-LABEL: test_sel:
135 ; CHECK-O3: // %bb.0:
136 ; CHECK-O3-NEXT: // kill: def $w0 killed $w0 def $x0
137 ; CHECK-O3-NEXT: sbfx x8, x0, #0, #1
138 ; CHECK-O3-NEXT: whilelo p2.b, xzr, x8
139 ; CHECK-O3-NEXT: sel p0.b, p2, p0.b, p1.b
141 %x.y = select i1 %cmp, target("aarch64.svcount") %x, target("aarch64.svcount") %y
142 ret target("aarch64.svcount") %x.y
145 define target("aarch64.svcount") @test_sel_cc(target("aarch64.svcount") %x, target("aarch64.svcount") %y, i32 %k) {
146 ; CHECK-O0-LABEL: test_sel_cc:
147 ; CHECK-O0: // %bb.0:
148 ; CHECK-O0-NEXT: mov p2.b, p1.b
149 ; CHECK-O0-NEXT: mov p1.b, p0.b
150 ; CHECK-O0-NEXT: subs w8, w0, #42
151 ; CHECK-O0-NEXT: cset w9, gt
152 ; CHECK-O0-NEXT: // implicit-def: $x8
153 ; CHECK-O0-NEXT: mov w8, w9
154 ; CHECK-O0-NEXT: sbfx x9, x8, #0, #1
155 ; CHECK-O0-NEXT: mov x8, xzr
156 ; CHECK-O0-NEXT: whilelo p0.b, x8, x9
157 ; CHECK-O0-NEXT: sel p0.b, p0, p1.b, p2.b
160 ; CHECK-O3-LABEL: test_sel_cc:
161 ; CHECK-O3: // %bb.0:
162 ; CHECK-O3-NEXT: cmp w0, #42
163 ; CHECK-O3-NEXT: cset w8, gt
164 ; CHECK-O3-NEXT: sbfx x8, x8, #0, #1
165 ; CHECK-O3-NEXT: whilelo p2.b, xzr, x8
166 ; CHECK-O3-NEXT: sel p0.b, p2, p0.b, p1.b
168 %cmp = icmp sgt i32 %k, 42
169 %x.y = select i1 %cmp, target("aarch64.svcount") %x, target("aarch64.svcount") %y
170 ret target("aarch64.svcount") %x.y