1; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck %s 2 3declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i1) #0 4declare void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* nocapture, i8* nocapture, i32, i1) #0 5 6declare void @llvm.memmove.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i1) #0 7declare void @llvm.memmove.p1i8.p0i8.i32(i8 addrspace(1)* nocapture, i8* nocapture, i32, i1) #0 8 9declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) #0 10 11declare i32 @llvm.objectsize.i32.p0i8(i8*, i1, i1, i1) #1 12 13; CHECK-LABEL: @promote_with_memcpy( 14; CHECK: getelementptr inbounds [64 x [17 x i32]], [64 x [17 x i32]] addrspace(3)* @promote_with_memcpy.alloca, i32 0, i32 %{{[0-9]+}} 15; CHECK: call void @llvm.memcpy.p3i8.p1i8.i32(i8 addrspace(3)* align 4 %alloca.bc, i8 addrspace(1)* align 4 %in.bc, i32 68, i1 false) 16; CHECK: call void @llvm.memcpy.p1i8.p3i8.i32(i8 addrspace(1)* align 4 %out.bc, i8 addrspace(3)* align 4 %alloca.bc, i32 68, i1 false) 17define amdgpu_kernel void @promote_with_memcpy(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { 18 %alloca = alloca [17 x i32], align 4 19 %alloca.bc = bitcast [17 x i32]* %alloca to i8* 20 %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)* 21 %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)* 22 call void @llvm.memcpy.p0i8.p1i8.i32(i8* align 4 %alloca.bc, i8 addrspace(1)* align 4 %in.bc, i32 68, i1 false) 23 call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 4 %out.bc, i8* align 4 %alloca.bc, i32 68, i1 false) 24 ret void 25} 26 27; CHECK-LABEL: @promote_with_memmove( 28; CHECK: getelementptr inbounds [64 x [17 x i32]], [64 x [17 x i32]] addrspace(3)* @promote_with_memmove.alloca, i32 0, i32 %{{[0-9]+}} 29; CHECK: call void @llvm.memmove.p3i8.p1i8.i32(i8 addrspace(3)* align 4 %alloca.bc, i8 addrspace(1)* align 4 %in.bc, i32 68, i1 false) 30; CHECK: call void @llvm.memmove.p1i8.p3i8.i32(i8 addrspace(1)* align 4 %out.bc, i8 addrspace(3)* align 4 %alloca.bc, i32 68, i1 false) 31define amdgpu_kernel void @promote_with_memmove(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { 32 %alloca = alloca [17 x i32], align 4 33 %alloca.bc = bitcast [17 x i32]* %alloca to i8* 34 %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)* 35 %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)* 36 call void @llvm.memmove.p0i8.p1i8.i32(i8* align 4 %alloca.bc, i8 addrspace(1)* align 4 %in.bc, i32 68, i1 false) 37 call void @llvm.memmove.p1i8.p0i8.i32(i8 addrspace(1)* align 4 %out.bc, i8* align 4 %alloca.bc, i32 68, i1 false) 38 ret void 39} 40 41; CHECK-LABEL: @promote_with_memset( 42; CHECK: getelementptr inbounds [64 x [17 x i32]], [64 x [17 x i32]] addrspace(3)* @promote_with_memset.alloca, i32 0, i32 %{{[0-9]+}} 43; CHECK: call void @llvm.memset.p3i8.i32(i8 addrspace(3)* align 4 %alloca.bc, i8 7, i32 68, i1 false) 44define amdgpu_kernel void @promote_with_memset(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 { 45 %alloca = alloca [17 x i32], align 4 46 %alloca.bc = bitcast [17 x i32]* %alloca to i8* 47 %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)* 48 %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)* 49 call void @llvm.memset.p0i8.i32(i8* align 4 %alloca.bc, i8 7, i32 68, i1 false) 50 ret void 51} 52 53; CHECK-LABEL: @promote_with_objectsize( 54; CHECK: [[PTR:%[0-9]+]] = getelementptr inbounds [64 x [17 x i32]], [64 x [17 x i32]] addrspace(3)* @promote_with_objectsize.alloca, i32 0, i32 %{{[0-9]+}} 55; CHECK: call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* %alloca.bc, i1 false, i1 false, i1 false) 56define amdgpu_kernel void @promote_with_objectsize(i32 addrspace(1)* %out) #0 { 57 %alloca = alloca [17 x i32], align 4 58 %alloca.bc = bitcast [17 x i32]* %alloca to i8* 59 %size = call i32 @llvm.objectsize.i32.p0i8(i8* %alloca.bc, i1 false, i1 false, i1 false) 60 store i32 %size, i32 addrspace(1)* %out 61 ret void 62} 63 64attributes #0 = { nounwind "amdgpu-flat-work-group-size"="64,64" "amdgpu-waves-per-eu"="1,3" } 65attributes #1 = { nounwind readnone } 66