1 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck %s 2 3 ; Nothing should be done if the addrspacecast is captured. 4 5 declare void @consume_ptr2int(i32) #0 6 7 ; CHECK-LABEL: @addrspacecast_captured( 8 ; CHECK: %data = alloca i32, align 4 9 ; CHECK: %cast = addrspacecast i32* %data to i32 addrspace(4)* 10 ; CHECK: %ptr2int = ptrtoint i32 addrspace(4)* %cast to i32 11 ; CHECK: store i32 %ptr2int, i32 addrspace(1)* %out 12 define amdgpu_kernel void @addrspacecast_captured(i32 addrspace(1)* %out) #0 { 13 entry: 14 %data = alloca i32, align 4 15 %cast = addrspacecast i32* %data to i32 addrspace(4)* 16 %ptr2int = ptrtoint i32 addrspace(4)* %cast to i32 17 store i32 %ptr2int, i32 addrspace(1)* %out 18 ret void 19 } 20 21 ; CHECK-LABEL: @addrspacecast_captured_store( 22 ; CHECK: %data = alloca i32, align 4 23 ; CHECK: %cast = addrspacecast i32* %data to i32 addrspace(4)* 24 ; CHECK: store i32 addrspace(4)* %cast, i32 addrspace(4)* addrspace(1)* %out 25 define amdgpu_kernel void @addrspacecast_captured_store(i32 addrspace(4)* addrspace(1)* %out) #0 { 26 entry: 27 %data = alloca i32, align 4 28 %cast = addrspacecast i32* %data to i32 addrspace(4)* 29 store i32 addrspace(4)* %cast, i32 addrspace(4)* addrspace(1)* %out 30 ret void 31 } 32 33 ; CHECK-LABEL: @addrspacecast_captured_call( 34 ; CHECK: %data = alloca i32, align 4 35 ; CHECK: %cast = addrspacecast i32* %data to i32 addrspace(4)* 36 ; CHECK: %ptr2int = ptrtoint i32 addrspace(4)* %cast to i32 37 ; CHECK: call void @consume_ptr2int(i32 %ptr2int) 38 define amdgpu_kernel void @addrspacecast_captured_call() #0 { 39 entry: 40 %data = alloca i32, align 4 41 %cast = addrspacecast i32* %data to i32 addrspace(4)* 42 %ptr2int = ptrtoint i32 addrspace(4)* %cast to i32 43 call void @consume_ptr2int(i32 %ptr2int) 44 ret void 45 } 46 47 attributes #0 = { nounwind } 48