[llvm] r294030 - AMDGPU: Don't unroll for private with dynamic allocas
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 11:36:00 PST 2017
Author: arsenm
Date: Fri Feb 3 13:36:00 2017
New Revision: 294030
URL: http://llvm.org/viewvc/llvm-project?rev=294030&view=rev
Log:
AMDGPU: Don't unroll for private with dynamic allocas
This won't be elimnated, so this will just bloat code
if/when these are ever used/supported.
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
llvm/trunk/test/Transforms/LoopUnroll/AMDGPU/unroll-for-private.ll
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp?rev=294030&r1=294029&r2=294030&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp Fri Feb 3 13:36:00 2017
@@ -54,7 +54,7 @@ void AMDGPUTTIImpl::getUnrollingPreferen
const Value *Ptr = GEP->getPointerOperand();
const AllocaInst *Alloca =
dyn_cast<AllocaInst>(GetUnderlyingObject(Ptr, DL));
- if (Alloca) {
+ if (Alloca && Alloca->isStaticAlloca()) {
Type *Ty = Alloca->getAllocatedType();
unsigned AllocaSize = Ty->isSized() ? DL.getTypeAllocSize(Ty) : 0;
if (AllocaSize > MaxAlloca)
Modified: llvm/trunk/test/Transforms/LoopUnroll/AMDGPU/unroll-for-private.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/AMDGPU/unroll-for-private.ll?rev=294030&r1=294029&r2=294030&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/AMDGPU/unroll-for-private.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/AMDGPU/unroll-for-private.ll Fri Feb 3 13:36:00 2017
@@ -109,6 +109,40 @@ for.body:
br i1 %exitcond, label %for.cond.cleanup, label %for.body
}
+; Check we do not enforce unroll if alloca is dynamic
+; CHECK-LABEL: @dynamic_size_alloca(
+; CHECK: alloca i32, i32 %n
+; CHECK: for.body:
+; CHECK: icmp eq i32 %{{.*}}, 100
+; CHECK: br
+
+define void @dynamic_size_alloca(i32 addrspace(1)* nocapture %a, i32 %n, i32 %x) {
+entry:
+ %arr = alloca i32, i32 %n, align 4
+ %tmp1 = tail call i32 @llvm.amdgcn.workitem.id.x() #1
+ br label %for.body
+
+for.cond.cleanup: ; preds = %for.body
+ %arrayidx5 = getelementptr inbounds i32, i32* %arr, i32 %x
+ %tmp15 = load i32, i32* %arrayidx5, align 4
+ %arrayidx7 = getelementptr inbounds i32, i32 addrspace(1)* %a, i32 %tmp1
+ store i32 %tmp15, i32 addrspace(1)* %arrayidx7, align 4
+ ret void
+
+for.body: ; preds = %for.body, %entry
+ %i.015 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %idxprom = sext i32 %i.015 to i64
+ %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %a, i64 %idxprom
+ %tmp16 = load i32, i32 addrspace(1)* %arrayidx, align 4
+ %add = add nsw i32 %i.015, %tmp1
+ %rem = srem i32 %add, 64
+ %arrayidx3 = getelementptr inbounds i32, i32* %arr, i32 %rem
+ store i32 %tmp16, i32* %arrayidx3, align 4
+ %inc = add nuw nsw i32 %i.015, 1
+ %exitcond = icmp eq i32 %inc, 100
+ br i1 %exitcond, label %for.cond.cleanup, label %for.body
+}
+
declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #1
declare i32 @llvm.amdgcn.workitem.id.x() #1
More information about the llvm-commits
mailing list