1 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s 2 3 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" 4 target triple = "nvptx64-nvidia-cuda" 5 6 ; Verify that both %input and %output are converted to global pointers and then 7 ; addrspacecast'ed back to the original type. 8 define void @kernel(float* %input, float* %output) { 9 ; CHECK-LABEL: .visible .entry kernel( 10 ; CHECK: cvta.to.global.u64 11 ; CHECK: cvta.to.global.u64 12 %1 = load float, float* %input, align 4 13 ; CHECK: ld.global.f32 14 store float %1, float* %output, align 4 15 ; CHECK: st.global.f32 16 ret void 17 } 18 19 define void @kernel2(float addrspace(1)* %input, float addrspace(1)* %output) { 20 ; CHECK-LABEL: .visible .entry kernel2( 21 ; CHECK-NOT: cvta.to.global.u64 22 %1 = load float, float addrspace(1)* %input, align 4 23 ; CHECK: ld.global.f32 24 store float %1, float addrspace(1)* %output, align 4 25 ; CHECK: st.global.f32 26 ret void 27 } 28 29 %struct.S = type { i32*, i32* } 30 31 define void @ptr_in_byval_kernel(%struct.S* byval %input, i32* %output) { 32 ; CHECK-LABEL: .visible .entry ptr_in_byval_kernel( 33 ; CHECK: ld.param.u64 %[[optr:rd.*]], [ptr_in_byval_kernel_param_1] 34 ; CHECK: cvta.to.global.u64 %[[optr_g:.*]], %[[optr]]; 35 ; CHECK: ld.param.u64 %[[iptr:rd.*]], [ptr_in_byval_kernel_param_0+8] 36 ; CHECK: cvta.to.global.u64 %[[iptr_g:.*]], %[[iptr]]; 37 %b_ptr = getelementptr inbounds %struct.S, %struct.S* %input, i64 0, i32 1 38 %b = load i32*, i32** %b_ptr, align 4 39 %v = load i32, i32* %b, align 4 40 ; CHECK: ld.global.u32 %[[val:.*]], [%[[iptr_g]]] 41 store i32 %v, i32* %output, align 4 42 ; CHECK: st.global.u32 [%[[optr_g]]], %[[val]] 43 ret void 44 } 45 46 ; Regular functions lower byval arguments differently. We need to make 47 ; sure that we're loading byval argument data using [symbol+offset]. 48 ; There's also no assumption that all pointers within are in global space. 49 define void @ptr_in_byval_func(%struct.S* byval %input, i32* %output) { 50 ; CHECK-LABEL: .visible .func ptr_in_byval_func( 51 ; CHECK: ld.param.u64 %[[optr:rd.*]], [ptr_in_byval_func_param_1] 52 ; CHECK: ld.param.u64 %[[iptr:rd.*]], [ptr_in_byval_func_param_0+8] 53 %b_ptr = getelementptr inbounds %struct.S, %struct.S* %input, i64 0, i32 1 54 %b = load i32*, i32** %b_ptr, align 4 55 %v = load i32, i32* %b, align 4 56 ; CHECK: ld.u32 %[[val:.*]], [%[[iptr]]] 57 store i32 %v, i32* %output, align 4 58 ; CHECK: st.u32 [%[[optr]]], %[[val]] 59 ret void 60 } 61 62 !nvvm.annotations = !{!0, !1, !2} 63 !0 = !{void (float*, float*)* @kernel, !"kernel", i32 1} 64 !1 = !{void (float addrspace(1)*, float addrspace(1)*)* @kernel2, !"kernel", i32 1} 65 !2 = !{void (%struct.S*, i32*)* @ptr_in_byval_kernel, !"kernel", i32 1} 66