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