1 ; RUN: llc < %s | FileCheck %s
3 target triple = "amdgcn-amd-amdhsa"
5 ; The call to intrinsic implicitarg_ptr reaches a load through a phi. The
6 ; offsets of the phi cannot be determined, and hence the attirbutor assumes that
9 ; CHECK-LABEL: amdhsa.kernels:
10 ; CHECK: .value_kind: hidden_hostcall_buffer
11 ; CHECK: .value_kind: hidden_multigrid_sync_arg
12 ; CHECK-LABEL: .name: kernel_1
14 define amdgpu_kernel void @kernel_1(ptr addrspace(1) %a, i64 %index1, i64 %index2, i1 %cond) {
16 %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
17 br i1 %cond, label %old, label %new
20 %tmp4 = getelementptr i8, ptr addrspace(4) %tmp7, i64 %index1
24 %tmp12 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 %index2
27 join: ; preds = %new, %old
28 %.in.in.in = phi ptr addrspace(4) [ %tmp12, %new ], [ %tmp4, %old ]
30 ;;; THIS USE is where the offset into implicitarg_ptr is unknown
31 %.in = load i16, ptr addrspace(4) %.in.in.in, align 2
33 %idx.ext = sext i16 %.in to i64
34 %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext
35 %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 4
39 ; The call to intrinsic implicitarg_ptr is combined with an offset produced by
40 ; select'ing between two constants, before it is eventually used in a GEP to
41 ; form the address of a load. This test ensures that AAPointerInfo can look
42 ; through the select to maintain a set of indices, so that it can precisely
43 ; determine that hostcall and other expensive implicit args are not in use.
45 ; CHECK-NOT: hidden_hostcall_buffer
46 ; CHECK-NOT: hidden_multigrid_sync_arg
47 ; CHECK-LABEL: .name: kernel_2
49 define amdgpu_kernel void @kernel_2(ptr addrspace(1) %a, i1 %cond) {
51 %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
52 %tmp5 = select i1 %cond, i64 12, i64 18
53 %tmp6 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 %tmp5
55 ;;; THIS USE is where multiple offsets are possible, relative to implicitarg_ptr
56 %tmp9 = load i16, ptr addrspace(4) %tmp6, align 2
58 %idx.ext = sext i16 %tmp9 to i64
59 %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext
60 %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 4
64 ; CHECK-NOT: hidden_hostcall_buffer
65 ; CHECK-NOT: hidden_multigrid_sync_arg
66 ; CHECK-LABEL: .name: kernel_3
68 define amdgpu_kernel void @kernel_3(ptr addrspace(1) %a, i1 %cond) {
70 %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
71 br i1 %cond, label %old, label %new
74 %tmp4 = getelementptr i8, ptr addrspace(4) %tmp7, i64 12
78 %tmp12 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 18
81 join: ; preds = %new, %old
82 %.in.in.in = phi ptr addrspace(4) [ %tmp12, %new ], [ %tmp4, %old ]
84 ;;; THIS USE of implicitarg_ptr should not produce hostcall metadata
85 %.in = load i16, ptr addrspace(4) %.in.in.in, align 2
87 %idx.ext = sext i16 %.in to i64
88 %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext
89 %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 4
93 declare i32 @llvm.amdgcn.workitem.id.x()
95 declare align 4 ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
97 declare i32 @llvm.amdgcn.workgroup.id.x()