brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 3aeaa1d Raw
98 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s --amdgpu-lower-module-lds-strategy=module | FileCheck -check-prefixes=CHECK,M_OR_HY %s3; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s --amdgpu-lower-module-lds-strategy=table | FileCheck -check-prefixes=CHECK,TABLE %s4; RUN: not opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s --amdgpu-lower-module-lds-strategy=kernel 2>&1 | FileCheck -check-prefixes=KERNEL %s5; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s --amdgpu-lower-module-lds-strategy=hybrid | FileCheck -check-prefixes=CHECK,M_OR_HY %s6 7;; Two kernels access the same variable, specialisation gives them each their own copy of it8 9@kernel.lds = addrspace(3) global i8 poison10define amdgpu_kernel void @k0() {11; CHECK-LABEL: @k0(12; CHECK-NEXT:    [[LD:%.*]] = load i8, ptr addrspace(3) @llvm.amdgcn.kernel.k0.lds, align 113; CHECK-NEXT:    [[MUL:%.*]] = mul i8 [[LD]], 214; CHECK-NEXT:    store i8 [[MUL]], ptr addrspace(3) @llvm.amdgcn.kernel.k0.lds, align 115; CHECK-NEXT:    ret void16;17  %ld = load i8, ptr addrspace(3) @kernel.lds18  %mul = mul i8 %ld, 219  store i8 %mul, ptr  addrspace(3) @kernel.lds20  ret void21}22 23define amdgpu_kernel void @k1() {24; CHECK-LABEL: @k1(25; CHECK-NEXT:    [[LD:%.*]] = load i8, ptr addrspace(3) @llvm.amdgcn.kernel.k1.lds, align 126; CHECK-NEXT:    [[MUL:%.*]] = mul i8 [[LD]], 327; CHECK-NEXT:    store i8 [[MUL]], ptr addrspace(3) @llvm.amdgcn.kernel.k1.lds, align 128; CHECK-NEXT:    ret void29;30  %ld = load i8, ptr addrspace(3) @kernel.lds31  %mul = mul i8 %ld, 332  store i8 %mul, ptr  addrspace(3) @kernel.lds33  ret void34}35 36;; Function accesses variable, reachable from two kernels, can't use kernel lowering for either37;; Hybrid can put it in module lds without cost as the first variable is free38 39; KERNEL: LLVM ERROR: cannot lower LDS 'function.lds' to kernel access as it is reachable from multiple kernels40 41@function.lds = addrspace(3) global i16 poison42define void @f0() {43; M_OR_HY-LABEL: @f0(44; M_OR_HY-NEXT:    [[LD:%.*]] = load i16, ptr addrspace(3) @llvm.amdgcn.module.lds, align 245; M_OR_HY-NEXT:    [[MUL:%.*]] = mul i16 [[LD]], 446; M_OR_HY-NEXT:    store i16 [[MUL]], ptr addrspace(3) @llvm.amdgcn.module.lds, align 247; M_OR_HY-NEXT:    ret void48;49; TABLE-LABEL: @f0(50; TABLE-NEXT:    [[TMP1:%.*]] = call i32 @llvm.amdgcn.lds.kernel.id()51; TABLE-NEXT:    [[FUNCTION_LDS2:%.*]] = getelementptr inbounds [2 x [1 x i32]], ptr addrspace(4) @llvm.amdgcn.lds.offset.table, i32 0, i32 [[TMP1]], i32 052; TABLE-NEXT:    [[TMP2:%.*]] = load i32, ptr addrspace(4) [[FUNCTION_LDS2]], align 453; TABLE-NEXT:    [[FUNCTION_LDS3:%.*]] = inttoptr i32 [[TMP2]] to ptr addrspace(3)54; TABLE-NEXT:    [[LD:%.*]] = load i16, ptr addrspace(3) [[FUNCTION_LDS3]], align 255; TABLE-NEXT:    [[MUL:%.*]] = mul i16 [[LD]], 456; TABLE-NEXT:    [[FUNCTION_LDS:%.*]] = getelementptr inbounds [2 x [1 x i32]], ptr addrspace(4) @llvm.amdgcn.lds.offset.table, i32 0, i32 [[TMP1]], i32 057; TABLE-NEXT:    [[TMP3:%.*]] = load i32, ptr addrspace(4) [[FUNCTION_LDS]], align 458; TABLE-NEXT:    [[FUNCTION_LDS1:%.*]] = inttoptr i32 [[TMP3]] to ptr addrspace(3)59; TABLE-NEXT:    store i16 [[MUL]], ptr addrspace(3) [[FUNCTION_LDS1]], align 260; TABLE-NEXT:    ret void61;62  %ld = load i16, ptr addrspace(3) @function.lds63  %mul = mul i16 %ld, 464  store i16 %mul, ptr  addrspace(3) @function.lds65  ret void66}67 68 69define amdgpu_kernel void @k0_f0() {70; M_OR_HY-LABEL: @k0_f0(71; M_OR_HY-NEXT:    call void @llvm.donothing() [ "ExplicitUse"(ptr addrspace(3) @llvm.amdgcn.module.lds) ]72; M_OR_HY-NEXT:    call void @f0()73; M_OR_HY-NEXT:    ret void74;75; TABLE-LABEL: @k0_f0(76; TABLE-NEXT:    call void @llvm.donothing() [ "ExplicitUse"(ptr addrspace(3) @llvm.amdgcn.kernel.k0_f0.lds) ]77; TABLE-NEXT:    call void @f0()78; TABLE-NEXT:    ret void79;80  call void @f0()81  ret void82}83 84define amdgpu_kernel void @k1_f0() {85; M_OR_HY-LABEL: @k1_f0(86; M_OR_HY-NEXT:    call void @llvm.donothing() [ "ExplicitUse"(ptr addrspace(3) @llvm.amdgcn.module.lds) ]87; M_OR_HY-NEXT:    call void @f0()88; M_OR_HY-NEXT:    ret void89;90; TABLE-LABEL: @k1_f0(91; TABLE-NEXT:    call void @llvm.donothing() [ "ExplicitUse"(ptr addrspace(3) @llvm.amdgcn.kernel.k1_f0.lds) ]92; TABLE-NEXT:    call void @f0()93; TABLE-NEXT:    ret void94;95  call void @f0()96  ret void97}98