[llvm-branch-commits] [llvm-branch] r271593 - Merging r259558:
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 2 14:01:46 PDT 2016
Author: tstellar
Date: Thu Jun 2 16:01:46 2016
New Revision: 271593
URL: http://llvm.org/viewvc/llvm-project?rev=271593&view=rev
Log:
Merging r259558:
------------------------------------------------------------------------
r259558 | Matthew.Arsenault | 2016-02-02 12:28:10 -0800 (Tue, 02 Feb 2016) | 4 lines
AMDGPU: Handle promoting memmove
Also add missing tests for the others.
------------------------------------------------------------------------
Added:
llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll
Modified:
llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Modified: llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp?rev=271593&r1=271592&r2=271593&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp (original)
+++ llvm/branches/release_38/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp Thu Jun 2 16:01:46 2016
@@ -268,12 +268,14 @@ static bool isCallPromotable(CallInst *C
switch (II->getIntrinsicID()) {
case Intrinsic::memcpy:
+ case Intrinsic::memmove:
case Intrinsic::memset:
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
case Intrinsic::invariant_start:
case Intrinsic::invariant_end:
case Intrinsic::invariant_group_barrier:
+ case Intrinsic::objectsize:
return true;
default:
return false;
@@ -450,6 +452,14 @@ void AMDGPUPromoteAlloca::visitAlloca(Al
Intr->eraseFromParent();
continue;
}
+ case Intrinsic::memmove: {
+ MemMoveInst *MemMove = cast<MemMoveInst>(Intr);
+ Builder.CreateMemMove(MemMove->getRawDest(), MemMove->getRawSource(),
+ MemMove->getLength(), MemMove->getAlignment(),
+ MemMove->isVolatile());
+ Intr->eraseFromParent();
+ continue;
+ }
case Intrinsic::memset: {
MemSetInst *MemSet = cast<MemSetInst>(Intr);
Builder.CreateMemSet(MemSet->getRawDest(), MemSet->getValue(),
@@ -466,6 +476,20 @@ void AMDGPUPromoteAlloca::visitAlloca(Al
// but the intrinsics need to be changed to accept pointers with any
// address space.
continue;
+ case Intrinsic::objectsize: {
+ Value *Src = Intr->getOperand(0);
+ Type *SrcTy = Src->getType()->getPointerElementType();
+ Function *ObjectSize = Intrinsic::getDeclaration(Mod,
+ Intrinsic::objectsize,
+ { Intr->getType(), PointerType::get(SrcTy, AMDGPUAS::LOCAL_ADDRESS) }
+ );
+
+ CallInst *NewCall
+ = Builder.CreateCall(ObjectSize, { Src, Intr->getOperand(1) });
+ Intr->replaceAllUsesWith(NewCall);
+ Intr->eraseFromParent();
+ continue;
+ }
default:
Intr->dump();
llvm_unreachable("Don't know how to promote alloca intrinsic use.");
Added: llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll?rev=271593&view=auto
==============================================================================
--- llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll (added)
+++ llvm/branches/release_38/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll Thu Jun 2 16:01:46 2016
@@ -0,0 +1,65 @@
+; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-promote-alloca < %s | FileCheck %s
+
+declare void @llvm.memcpy.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) #0
+declare void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* nocapture, i8* nocapture, i32, i32, i1) #0
+
+declare void @llvm.memmove.p0i8.p1i8.i32(i8* nocapture, i8 addrspace(1)* nocapture, i32, i32, i1) #0
+declare void @llvm.memmove.p1i8.p0i8.i32(i8 addrspace(1)* nocapture, i8* nocapture, i32, i32, i1) #0
+
+declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #0
+
+declare i32 @llvm.objectsize.i32.p0i8(i8*, i1) #1
+
+; CHECK-LABEL: @promote_with_memcpy(
+; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca, i32 0, i32 %{{[0-9]+}}
+; CHECK: call void @llvm.memcpy.p3i8.p1i8.i32(i8 addrspace(3)* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
+; CHECK: call void @llvm.memcpy.p1i8.p3i8.i32(i8 addrspace(1)* %out.bc, i8 addrspace(3)* %alloca.bc, i32 68, i32 4, i1 false)
+define void @promote_with_memcpy(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
+ %alloca = alloca [17 x i32], align 16
+ %alloca.bc = bitcast [17 x i32]* %alloca to i8*
+ %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)*
+ %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)*
+ call void @llvm.memcpy.p0i8.p1i8.i32(i8* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
+ call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* %out.bc, i8* %alloca.bc, i32 68, i32 4, i1 false)
+ ret void
+}
+
+; CHECK-LABEL: @promote_with_memmove(
+; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.1, i32 0, i32 %{{[0-9]+}}
+; CHECK: call void @llvm.memmove.p3i8.p1i8.i32(i8 addrspace(3)* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
+; CHECK: call void @llvm.memmove.p1i8.p3i8.i32(i8 addrspace(1)* %out.bc, i8 addrspace(3)* %alloca.bc, i32 68, i32 4, i1 false)
+define void @promote_with_memmove(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
+ %alloca = alloca [17 x i32], align 16
+ %alloca.bc = bitcast [17 x i32]* %alloca to i8*
+ %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)*
+ %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)*
+ call void @llvm.memmove.p0i8.p1i8.i32(i8* %alloca.bc, i8 addrspace(1)* %in.bc, i32 68, i32 4, i1 false)
+ call void @llvm.memmove.p1i8.p0i8.i32(i8 addrspace(1)* %out.bc, i8* %alloca.bc, i32 68, i32 4, i1 false)
+ ret void
+}
+
+; CHECK-LABEL: @promote_with_memset(
+; CHECK: getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.2, i32 0, i32 %{{[0-9]+}}
+; CHECK: call void @llvm.memset.p3i8.i32(i8 addrspace(3)* %alloca.bc, i8 7, i32 68, i32 4, i1 false)
+define void @promote_with_memset(i32 addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
+ %alloca = alloca [17 x i32], align 16
+ %alloca.bc = bitcast [17 x i32]* %alloca to i8*
+ %in.bc = bitcast i32 addrspace(1)* %in to i8 addrspace(1)*
+ %out.bc = bitcast i32 addrspace(1)* %out to i8 addrspace(1)*
+ call void @llvm.memset.p0i8.i32(i8* %alloca.bc, i8 7, i32 68, i32 4, i1 false)
+ ret void
+}
+
+; CHECK-LABEL: @promote_with_objectsize(
+; CHECK: [[PTR:%[0-9]+]] = getelementptr [256 x [17 x i32]], [256 x [17 x i32]] addrspace(3)* @alloca.3, i32 0, i32 %{{[0-9]+}}
+; CHECK: call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* %alloca.bc, i1 false)
+define void @promote_with_objectsize(i32 addrspace(1)* %out) #0 {
+ %alloca = alloca [17 x i32], align 16
+ %alloca.bc = bitcast [17 x i32]* %alloca to i8*
+ %size = call i32 @llvm.objectsize.i32.p0i8(i8* %alloca.bc, i1 false)
+ store i32 %size, i32 addrspace(1)* %out
+ ret void
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind readnone }
More information about the llvm-branch-commits
mailing list