1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s --check-prefixes=ALL,CHECK
3 ; RUN: llc -O0 < %s | FileCheck %s --check-prefixes=ALL,CHECK-O0
5 ; Source to regenerate:
9 ; __attribute__((address_space(9))) int *p_other;
11 ; void use_foo(Foo *f);
12 ; void test_sign_ext(Foo *f, int * __ptr32 __sptr i) {
16 ; void test_zero_ext(Foo *f, int * __ptr32 __uptr i) {
20 ; void test_trunc(Foo *f, int * __ptr64 i) {
24 ; void test_noop1(Foo *f, int * __ptr32 i) {
28 ; void test_noop2(Foo *f, int * __ptr64 i) {
32 ; void test_null_arg(Foo *f) {
35 ; void test_unrecognized(Foo *f, __attribute__((address_space(14))) int *i) {
36 ; f->p64 = (int * __ptr64)i;
39 ; void test_unrecognized2(Foo *f, int * __ptr64 i) {
44 ; $ clang -cc1 -triple x86_64-windows-msvc -fms-extensions -O2 -S t.cpp
46 target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
47 target triple = "i686-unknown-windows-msvc"
49 %struct.Foo = type { i32*, i32 addrspace(272)*, i32 addrspace(9)* }
50 declare dso_local void @use_foo(%struct.Foo*)
52 define dso_local void @test_sign_ext(%struct.Foo* %f, i32* %i) {
53 ; CHECK-LABEL: test_sign_ext:
54 ; CHECK: # %bb.0: # %entry
55 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
56 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
57 ; CHECK-NEXT: movl %ecx, 8(%eax)
58 ; CHECK-NEXT: sarl $31, %ecx
59 ; CHECK-NEXT: movl %ecx, 12(%eax)
60 ; CHECK-NEXT: jmp _use_foo # TAILCALL
62 ; CHECK-O0-LABEL: test_sign_ext:
63 ; CHECK-O0: # %bb.0: # %entry
64 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
65 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; CHECK-O0-NEXT: movl %edx, %ecx
67 ; CHECK-O0-NEXT: sarl $31, %ecx
68 ; CHECK-O0-NEXT: movl %edx, 8(%eax)
69 ; CHECK-O0-NEXT: movl %ecx, 12(%eax)
70 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
72 %0 = addrspacecast i32* %i to i32 addrspace(272)*
73 %p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
74 store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
75 tail call void @use_foo(%struct.Foo* %f)
79 define dso_local void @test_zero_ext(%struct.Foo* %f, i32 addrspace(271)* %i) {
80 ; CHECK-LABEL: test_zero_ext:
81 ; CHECK: # %bb.0: # %entry
82 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
83 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
84 ; CHECK-NEXT: movl %eax, 8(%ecx)
85 ; CHECK-NEXT: movl $0, 12(%ecx)
86 ; CHECK-NEXT: jmp _use_foo # TAILCALL
88 ; CHECK-O0-LABEL: test_zero_ext:
89 ; CHECK-O0: # %bb.0: # %entry
90 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
91 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
92 ; CHECK-O0-NEXT: movl %ecx, 8(%eax)
93 ; CHECK-O0-NEXT: movl $0, 12(%eax)
94 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
96 %0 = addrspacecast i32 addrspace(271)* %i to i32 addrspace(272)*
97 %p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
98 store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
99 tail call void @use_foo(%struct.Foo* %f)
103 define dso_local void @test_trunc(%struct.Foo* %f, i32 addrspace(272)* %i) {
104 ; CHECK-LABEL: test_trunc:
105 ; CHECK: # %bb.0: # %entry
106 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
107 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
108 ; CHECK-NEXT: movl %eax, (%ecx)
109 ; CHECK-NEXT: jmp _use_foo # TAILCALL
111 ; CHECK-O0-LABEL: test_trunc:
112 ; CHECK-O0: # %bb.0: # %entry
113 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
114 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
115 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
116 ; CHECK-O0-NEXT: movl %ecx, (%eax)
117 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
119 %0 = addrspacecast i32 addrspace(272)* %i to i32*
120 %p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 0
121 store i32* %0, i32** %p32, align 8
122 tail call void @use_foo(%struct.Foo* %f)
126 define dso_local void @test_noop1(%struct.Foo* %f, i32* %i) {
127 ; CHECK-LABEL: test_noop1:
128 ; CHECK: # %bb.0: # %entry
129 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
130 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
131 ; CHECK-NEXT: movl %eax, (%ecx)
132 ; CHECK-NEXT: jmp _use_foo # TAILCALL
134 ; CHECK-O0-LABEL: test_noop1:
135 ; CHECK-O0: # %bb.0: # %entry
136 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
137 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
138 ; CHECK-O0-NEXT: movl %ecx, (%eax)
139 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
141 %p32 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 0
142 store i32* %i, i32** %p32, align 8
143 tail call void @use_foo(%struct.Foo* %f)
147 define dso_local void @test_noop2(%struct.Foo* %f, i32 addrspace(272)* %i) {
148 ; CHECK-LABEL: test_noop2:
149 ; CHECK: # %bb.0: # %entry
150 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
151 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
152 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
153 ; CHECK-NEXT: movl %ecx, 12(%edx)
154 ; CHECK-NEXT: movl %eax, 8(%edx)
155 ; CHECK-NEXT: jmp _use_foo # TAILCALL
157 ; CHECK-O0-LABEL: test_noop2:
158 ; CHECK-O0: # %bb.0: # %entry
159 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
160 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
161 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
162 ; CHECK-O0-NEXT: movl %edx, 8(%eax)
163 ; CHECK-O0-NEXT: movl %ecx, 12(%eax)
164 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
166 %p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
167 store i32 addrspace(272)* %i, i32 addrspace(272)** %p64, align 8
168 tail call void @use_foo(%struct.Foo* %f)
172 ; Test that null can be passed as a 64-bit pointer.
173 define dso_local void @test_null_arg(%struct.Foo* %f) {
174 ; CHECK-LABEL: test_null_arg:
175 ; CHECK: # %bb.0: # %entry
176 ; CHECK-NEXT: pushl $0
177 ; CHECK-NEXT: pushl $0
178 ; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
179 ; CHECK-NEXT: calll _test_noop2
180 ; CHECK-NEXT: addl $12, %esp
183 ; CHECK-O0-LABEL: test_null_arg:
184 ; CHECK-O0: # %bb.0: # %entry
185 ; CHECK-O0-NEXT: subl $12, %esp
186 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
187 ; CHECK-O0-NEXT: movl %esp, %eax
188 ; CHECK-O0-NEXT: movl %ecx, (%eax)
189 ; CHECK-O0-NEXT: movl $0, 8(%eax)
190 ; CHECK-O0-NEXT: movl $0, 4(%eax)
191 ; CHECK-O0-NEXT: calll _test_noop2
192 ; CHECK-O0-NEXT: addl $12, %esp
193 ; CHECK-O0-NEXT: retl
195 call void @test_noop2(%struct.Foo* %f, i32 addrspace(272)* null)
199 define dso_local void @test_unrecognized(%struct.Foo* %f, i32 addrspace(14)* %i) {
200 ; CHECK-LABEL: test_unrecognized:
201 ; CHECK: # %bb.0: # %entry
202 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
203 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
204 ; CHECK-NEXT: movl %ecx, 8(%eax)
205 ; CHECK-NEXT: sarl $31, %ecx
206 ; CHECK-NEXT: movl %ecx, 12(%eax)
207 ; CHECK-NEXT: jmp _use_foo # TAILCALL
209 ; CHECK-O0-LABEL: test_unrecognized:
210 ; CHECK-O0: # %bb.0: # %entry
211 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %edx
212 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
213 ; CHECK-O0-NEXT: movl %edx, %ecx
214 ; CHECK-O0-NEXT: sarl $31, %ecx
215 ; CHECK-O0-NEXT: movl %edx, 8(%eax)
216 ; CHECK-O0-NEXT: movl %ecx, 12(%eax)
217 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
219 %0 = addrspacecast i32 addrspace(14)* %i to i32 addrspace(272)*
220 %p64 = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 1
221 store i32 addrspace(272)* %0, i32 addrspace(272)** %p64, align 8
222 tail call void @use_foo(%struct.Foo* %f)
226 define dso_local void @test_unrecognized2(%struct.Foo* %f, i32 addrspace(272)* %i) {
227 ; CHECK-LABEL: test_unrecognized2:
228 ; CHECK: # %bb.0: # %entry
229 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
230 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
231 ; CHECK-NEXT: movl %eax, 16(%ecx)
232 ; CHECK-NEXT: jmp _use_foo # TAILCALL
234 ; CHECK-O0-LABEL: test_unrecognized2:
235 ; CHECK-O0: # %bb.0: # %entry
236 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
237 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
238 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
239 ; CHECK-O0-NEXT: movl %ecx, 16(%eax)
240 ; CHECK-O0-NEXT: jmp _use_foo # TAILCALL
242 %0 = addrspacecast i32 addrspace(272)* %i to i32 addrspace(9)*
243 %p_other = getelementptr inbounds %struct.Foo, %struct.Foo* %f, i32 0, i32 2
244 store i32 addrspace(9)* %0, i32 addrspace(9)** %p_other, align 8
245 tail call void @use_foo(%struct.Foo* %f)
249 define i32 @test_load_sptr32(i32 addrspace(270)* %i) {
250 ; ALL-LABEL: test_load_sptr32:
251 ; ALL: # %bb.0: # %entry
252 ; ALL-NEXT: movl {{[0-9]+}}(%esp), %eax
253 ; ALL-NEXT: movl (%eax), %eax
256 %0 = load i32, i32 addrspace(270)* %i, align 4
260 define i32 @test_load_uptr32(i32 addrspace(271)* %i) {
261 ; ALL-LABEL: test_load_uptr32:
262 ; ALL: # %bb.0: # %entry
263 ; ALL-NEXT: movl {{[0-9]+}}(%esp), %eax
264 ; ALL-NEXT: movl (%eax), %eax
267 %0 = load i32, i32 addrspace(271)* %i, align 4
271 define i32 @test_load_ptr64(i32 addrspace(272)* %i) {
272 ; CHECK-LABEL: test_load_ptr64:
273 ; CHECK: # %bb.0: # %entry
274 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
275 ; CHECK-NEXT: movl (%eax), %eax
278 ; CHECK-O0-LABEL: test_load_ptr64:
279 ; CHECK-O0: # %bb.0: # %entry
280 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
281 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
282 ; CHECK-O0-NEXT: movl (%eax), %eax
283 ; CHECK-O0-NEXT: retl
285 %0 = load i32, i32 addrspace(272)* %i, align 8
289 define void @test_store_sptr32(i32 addrspace(270)* %s, i32 %i) {
290 ; CHECK-LABEL: test_store_sptr32:
291 ; CHECK: # %bb.0: # %entry
292 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
293 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
294 ; CHECK-NEXT: movl %eax, (%ecx)
297 ; CHECK-O0-LABEL: test_store_sptr32:
298 ; CHECK-O0: # %bb.0: # %entry
299 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
300 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
301 ; CHECK-O0-NEXT: movl %ecx, (%eax)
302 ; CHECK-O0-NEXT: retl
304 store i32 %i, i32 addrspace(270)* %s, align 4
308 define void @test_store_uptr32(i32 addrspace(271)* %s, i32 %i) {
309 ; CHECK-LABEL: test_store_uptr32:
310 ; CHECK: # %bb.0: # %entry
311 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
312 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
313 ; CHECK-NEXT: movl %eax, (%ecx)
316 ; CHECK-O0-LABEL: test_store_uptr32:
317 ; CHECK-O0: # %bb.0: # %entry
318 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
319 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
320 ; CHECK-O0-NEXT: movl %ecx, (%eax)
321 ; CHECK-O0-NEXT: retl
323 store i32 %i, i32 addrspace(271)* %s, align 4
327 define void @test_store_ptr64(i32 addrspace(272)* %s, i32 %i) {
328 ; CHECK-LABEL: test_store_ptr64:
329 ; CHECK: # %bb.0: # %entry
330 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
331 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
332 ; CHECK-NEXT: movl %eax, (%ecx)
335 ; CHECK-O0-LABEL: test_store_ptr64:
336 ; CHECK-O0: # %bb.0: # %entry
337 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
338 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %eax
339 ; CHECK-O0-NEXT: movl {{[0-9]+}}(%esp), %ecx
340 ; CHECK-O0-NEXT: movl %ecx, (%eax)
341 ; CHECK-O0-NEXT: retl
343 store i32 %i, i32 addrspace(272)* %s, align 8