1 ; RUN: opt < %s -S -nvptx-lower-alloca -infer-address-spaces | FileCheck %s
2 ; RUN: opt < %s -S -nvptx-lower-alloca | FileCheck %s --check-prefix LOWERALLOCAONLY
3 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_35 | FileCheck %s --check-prefix PTX
4 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_35 | %ptxas-verify %}
6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
7 target triple = "nvptx64-unknown-unknown"
9 define void @kernel() {
10 ; LABEL: @lower_alloca
11 ; PTX-LABEL: .visible .entry kernel(
13 ; CHECK: addrspacecast ptr %A to ptr addrspace(5)
14 ; CHECK: store i32 0, ptr addrspace(5) {{%.+}}
15 ; LOWERALLOCAONLY: [[V1:%.*]] = addrspacecast ptr %A to ptr addrspace(5)
16 ; LOWERALLOCAONLY: [[V2:%.*]] = addrspacecast ptr addrspace(5) [[V1]] to ptr
17 ; LOWERALLOCAONLY: store i32 0, ptr [[V2]], align 4
18 ; PTX: st.local.u32 [{{%rd[0-9]+}}], {{%r[0-9]+}}
20 call void @callee(ptr %A)
24 define void @alloca_in_explicit_local_as() {
25 ; LABEL: @lower_alloca_addrspace5
26 ; PTX-LABEL: .visible .func alloca_in_explicit_local_as(
27 %A = alloca i32, addrspace(5)
28 ; CHECK: store i32 0, ptr addrspace(5) {{%.+}}
29 ; PTX: st.local.u32 [%SP], {{%r[0-9]+}}
30 ; LOWERALLOCAONLY: [[V1:%.*]] = addrspacecast ptr addrspace(5) %A to ptr
31 ; LOWERALLOCAONLY: store i32 0, ptr [[V1]], align 4
32 store i32 0, ptr addrspace(5) %A
33 call void @callee(ptr addrspace(5) %A)
37 declare void @callee(ptr)
38 declare void @callee_addrspace5(ptr addrspace(5))
40 !nvvm.annotations = !{!0}
41 !nvvm.annotations = !{!1}
42 !0 = !{ptr @kernel, !"kernel", i32 1}
43 !1 = !{ptr @alloca_in_explicit_local_as, !"alloca_in_explicit_local_as", i32 1}