160 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 52; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -passes=amdgpu-attributor < %s | FileCheck -check-prefixes=GFX9 %s3; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -passes=amdgpu-attributor < %s | FileCheck -check-prefixes=GFX10 %s4 5;6; None of these functions should have the attribute amdgpu-no-flat-scratch-init. In these tests7; we manually set the attribute for the functions. The purpose is to test how the amdgpu-attributor pass8; handles this situation.9;10;; tests of addrspacecast11 12define void @with_private_to_flat_addrspacecast(ptr addrspace(5) %ptr) #0 {13; GFX9-LABEL: define void @with_private_to_flat_addrspacecast(14; GFX9-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {15; GFX9-NEXT: [[STOF:%.*]] = addrspacecast ptr addrspace(5) [[PTR]] to ptr16; GFX9-NEXT: store volatile i32 0, ptr [[STOF]], align 4, !noalias.addrspace [[META0:![0-9]+]]17; GFX9-NEXT: ret void18;19; GFX10-LABEL: define void @with_private_to_flat_addrspacecast(20; GFX10-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {21; GFX10-NEXT: [[STOF:%.*]] = addrspacecast ptr addrspace(5) [[PTR]] to ptr22; GFX10-NEXT: store volatile i32 0, ptr [[STOF]], align 4, !noalias.addrspace [[META0:![0-9]+]]23; GFX10-NEXT: ret void24;25 %stof = addrspacecast ptr addrspace(5) %ptr to ptr26 store volatile i32 0, ptr %stof27 ret void28}29 30define amdgpu_kernel void @with_private_to_flat_addrspacecast_cc_kernel(ptr addrspace(5) %ptr) #0 {31; GFX9-LABEL: define amdgpu_kernel void @with_private_to_flat_addrspacecast_cc_kernel(32; GFX9-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {33; GFX9-NEXT: [[STOF:%.*]] = addrspacecast ptr addrspace(5) [[PTR]] to ptr34; GFX9-NEXT: store volatile i32 0, ptr [[STOF]], align 4, !noalias.addrspace [[META0]]35; GFX9-NEXT: ret void36;37; GFX10-LABEL: define amdgpu_kernel void @with_private_to_flat_addrspacecast_cc_kernel(38; GFX10-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {39; GFX10-NEXT: [[STOF:%.*]] = addrspacecast ptr addrspace(5) [[PTR]] to ptr40; GFX10-NEXT: store volatile i32 0, ptr [[STOF]], align 4, !noalias.addrspace [[META0]]41; GFX10-NEXT: ret void42;43 %stof = addrspacecast ptr addrspace(5) %ptr to ptr44 store volatile i32 0, ptr %stof45 ret void46}47 48define void @call_with_private_to_flat_addrspacecast(ptr addrspace(5) %ptr) #0 {49; GFX9-LABEL: define void @call_with_private_to_flat_addrspacecast(50; GFX9-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {51; GFX9-NEXT: call void @with_private_to_flat_addrspacecast(ptr addrspace(5) [[PTR]])52; GFX9-NEXT: ret void53;54; GFX10-LABEL: define void @call_with_private_to_flat_addrspacecast(55; GFX10-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {56; GFX10-NEXT: call void @with_private_to_flat_addrspacecast(ptr addrspace(5) [[PTR]])57; GFX10-NEXT: ret void58;59 call void @with_private_to_flat_addrspacecast(ptr addrspace(5) %ptr)60 ret void61}62 63define amdgpu_kernel void @call_with_private_to_flat_addrspacecast_cc_kernel(ptr addrspace(5) %ptr) #0 {64; GFX9-LABEL: define amdgpu_kernel void @call_with_private_to_flat_addrspacecast_cc_kernel(65; GFX9-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {66; GFX9-NEXT: call void @with_private_to_flat_addrspacecast(ptr addrspace(5) [[PTR]])67; GFX9-NEXT: ret void68;69; GFX10-LABEL: define amdgpu_kernel void @call_with_private_to_flat_addrspacecast_cc_kernel(70; GFX10-SAME: ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0]] {71; GFX10-NEXT: call void @with_private_to_flat_addrspacecast(ptr addrspace(5) [[PTR]])72; GFX10-NEXT: ret void73;74 call void @with_private_to_flat_addrspacecast(ptr addrspace(5) %ptr)75 ret void76}77 78;; tests of addrspacecast in a constant79 80define amdgpu_kernel void @private_constant_expression_use(ptr addrspace(1) nocapture %out) #0 {81; GFX9-LABEL: define amdgpu_kernel void @private_constant_expression_use(82; GFX9-SAME: ptr addrspace(1) captures(none) [[OUT:%.*]]) #[[ATTR0]] {83; GFX9-NEXT: store volatile ptr addrspacecast (ptr addrspace(5) inttoptr (i32 123 to ptr addrspace(5)) to ptr), ptr addrspace(1) [[OUT]], align 884; GFX9-NEXT: ret void85;86; GFX10-LABEL: define amdgpu_kernel void @private_constant_expression_use(87; GFX10-SAME: ptr addrspace(1) captures(none) [[OUT:%.*]]) #[[ATTR0]] {88; GFX10-NEXT: store volatile ptr addrspacecast (ptr addrspace(5) inttoptr (i32 123 to ptr addrspace(5)) to ptr), ptr addrspace(1) [[OUT]], align 889; GFX10-NEXT: ret void90;91 store volatile ptr addrspacecast (ptr addrspace(5) inttoptr (i32 123 to ptr addrspace(5)) to ptr), ptr addrspace(1) %out, align 892 ret void93}94 95;; tests of intrinsics96 97define amdgpu_kernel void @calls_intrin_ascast_cc_kernel(ptr addrspace(3) %ptr) #0 {98; GFX9-LABEL: define amdgpu_kernel void @calls_intrin_ascast_cc_kernel(99; GFX9-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {100; GFX9-NEXT: [[TMP1:%.*]] = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) [[PTR]])101; GFX9-NEXT: store volatile i32 7, ptr [[TMP1]], align 4102; GFX9-NEXT: ret void103;104; GFX10-LABEL: define amdgpu_kernel void @calls_intrin_ascast_cc_kernel(105; GFX10-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {106; GFX10-NEXT: [[TMP1:%.*]] = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) [[PTR]])107; GFX10-NEXT: store volatile i32 7, ptr [[TMP1]], align 4108; GFX10-NEXT: ret void109;110 %1 = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) %ptr)111 store volatile i32 7, ptr %1, align 4112 ret void113}114 115define void @calls_intrin_ascast(ptr addrspace(3) %ptr) #0 {116; GFX9-LABEL: define void @calls_intrin_ascast(117; GFX9-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {118; GFX9-NEXT: [[TMP1:%.*]] = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) [[PTR]])119; GFX9-NEXT: store volatile i32 7, ptr [[TMP1]], align 4120; GFX9-NEXT: ret void121;122; GFX10-LABEL: define void @calls_intrin_ascast(123; GFX10-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {124; GFX10-NEXT: [[TMP1:%.*]] = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) [[PTR]])125; GFX10-NEXT: store volatile i32 7, ptr [[TMP1]], align 4126; GFX10-NEXT: ret void127;128 %1 = call ptr @llvm.amdgcn.addrspacecast.nonnull.p0.p3(ptr addrspace(3) %ptr)129 store volatile i32 7, ptr %1, align 4130 ret void131}132 133define amdgpu_kernel void @call_calls_intrin_ascast_cc_kernel(ptr addrspace(3) %ptr) #0 {134; GFX9-LABEL: define amdgpu_kernel void @call_calls_intrin_ascast_cc_kernel(135; GFX9-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {136; GFX9-NEXT: call void @calls_intrin_ascast(ptr addrspace(3) [[PTR]])137; GFX9-NEXT: ret void138;139; GFX10-LABEL: define amdgpu_kernel void @call_calls_intrin_ascast_cc_kernel(140; GFX10-SAME: ptr addrspace(3) [[PTR:%.*]]) #[[ATTR0]] {141; GFX10-NEXT: call void @calls_intrin_ascast(ptr addrspace(3) [[PTR]])142; GFX10-NEXT: ret void143;144 call void @calls_intrin_ascast(ptr addrspace(3) %ptr)145 ret void146}147 148attributes #0 = { "amdgpu-no-flat-scratch-init" }149;.150; GFX9: attributes #[[ATTR0]] = { "amdgpu-no-cluster-id-x" "amdgpu-no-cluster-id-y" "amdgpu-no-cluster-id-z" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "target-cpu"="gfx900" "uniform-work-group-size"="false" }151; GFX9: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) "target-cpu"="gfx900" }152;.153; GFX10: attributes #[[ATTR0]] = { "amdgpu-no-cluster-id-x" "amdgpu-no-cluster-id-y" "amdgpu-no-cluster-id-z" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "target-cpu"="gfx1010" "uniform-work-group-size"="false" }154; GFX10: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) "target-cpu"="gfx1010" }155;.156; GFX9: [[META0]] = !{i32 1, i32 5, i32 6, i32 10}157;.158; GFX10: [[META0]] = !{i32 1, i32 5, i32 6, i32 10}159;.160