brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 7c8d89e Raw
98 lines · plain
1; RUN: opt -passes=amdgpu-attributor < %s | llc | FileCheck %s2 3target triple = "amdgcn-amd-amdhsa"4 5; The call to intrinsic implicitarg_ptr reaches a load through a phi. The6; offsets of the phi cannot be determined, and hence the attirbutor assumes that7; hostcall is in use.8 9; CHECK-LABEL: amdhsa.kernels:10; CHECK: .value_kind:     hidden_hostcall_buffer11; CHECK: .value_kind:     hidden_multigrid_sync_arg12; CHECK-LABEL: .name:           kernel_113 14define amdgpu_kernel void @kernel_1(ptr addrspace(1) %a, i64 %index1, i64 %index2, i1 %cond)  {15entry:16  %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()17  br i1 %cond, label %old, label %new18 19old:                                              ; preds = %entry20  %tmp4 = getelementptr i8, ptr addrspace(4) %tmp7, i64 %index121  br label %join22 23new:                                              ; preds = %entry24  %tmp12 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 %index225  br label %join26 27join:                                             ; preds = %new, %old28  %.in.in.in = phi ptr addrspace(4) [ %tmp12, %new ], [ %tmp4, %old ]29 30  ;;; THIS USE is where the offset into implicitarg_ptr is unknown31  %.in = load i16, ptr addrspace(4) %.in.in.in, align 232 33  %idx.ext = sext i16 %.in to i6434  %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext35  %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 436  ret void37}38 39; The call to intrinsic implicitarg_ptr is combined with an offset produced by40; select'ing between two constants, before it is eventually used in a GEP to41; form the address of a load. This test ensures that AAPointerInfo can look42; through the select to maintain a set of indices, so that it can precisely43; determine that hostcall and other expensive implicit args are not in use.44 45; CHECK-NOT: hidden_hostcall_buffer46; CHECK-NOT: hidden_multigrid_sync_arg47; CHECK-LABEL: .name:           kernel_248 49define amdgpu_kernel void @kernel_2(ptr addrspace(1) %a, i1 %cond)  {50entry:51  %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()52  %tmp5 = select i1 %cond, i64 12, i64 1853  %tmp6 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 %tmp554 55  ;;; THIS USE is where multiple offsets are possible, relative to implicitarg_ptr56  %tmp9 = load i16, ptr addrspace(4) %tmp6, align 257 58  %idx.ext = sext i16 %tmp9 to i6459  %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext60  %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 461  ret void62}63 64; CHECK-NOT: hidden_hostcall_buffer65; CHECK-NOT: hidden_multigrid_sync_arg66; CHECK-LABEL: .name:           kernel_367 68define amdgpu_kernel void @kernel_3(ptr addrspace(1) %a, i1 %cond)  {69entry:70  %tmp7 = tail call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()71  br i1 %cond, label %old, label %new72 73old:                                              ; preds = %entry74  %tmp4 = getelementptr i8, ptr addrspace(4) %tmp7, i64 1275  br label %join76 77new:                                              ; preds = %entry78  %tmp12 = getelementptr inbounds i8, ptr addrspace(4) %tmp7, i64 1879  br label %join80 81join:                                             ; preds = %new, %old82  %.in.in.in = phi ptr addrspace(4) [ %tmp12, %new ], [ %tmp4, %old ]83 84  ;;; THIS USE of implicitarg_ptr should not produce hostcall metadata85  %.in = load i16, ptr addrspace(4) %.in.in.in, align 286 87  %idx.ext = sext i16 %.in to i6488  %add.ptr3 = getelementptr inbounds i32, ptr addrspace(1) %a, i64 %idx.ext89  %tmp16 = atomicrmw add ptr addrspace(1) %add.ptr3, i32 15 syncscope("agent-one-as") monotonic, align 490  ret void91}92 93declare i32 @llvm.amdgcn.workitem.id.x()94 95declare align 4 ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()96 97declare i32 @llvm.amdgcn.workgroup.id.x()98