Skip to content

Commit 8771de8

Browse files
agrabezhigcbot
authored andcommitted
Fix max alloca size to promote accordingly to GRF width
Consider GRF width in alloca register promotion limit
1 parent d0f64c0 commit 8771de8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

IGC/Compiler/CISACodeGen/LowerGEPForPrivMem.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ StatusPrivArr2Reg LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst*
286286
bool useAssumeUniform = pAlloca->getMetadata("UseAssumeUniform") != nullptr;
287287
unsigned int allocaSize = extractConstAllocaSize(pAlloca);
288288
unsigned int allowedAllocaSizeInBytes = MAX_ALLOCA_PROMOTE_GRF_NUM * 4;
289-
unsigned int SIMDSize = numLanes(SIMDMode::SIMD8);
289+
unsigned int SIMDSize = numLanes(m_ctx->platform.getMinDispatchMode());
290+
291+
// consider GRF width in alloca register promotion limit
292+
allowedAllocaSizeInBytes = allowedAllocaSizeInBytes * m_ctx->platform.getGRFSize() / 32;
290293

291294
// scale alloc size based on the number of GRFs we have
292295
float grfRatio = m_ctx->getNumGRFPerThread() / 128.0f;
@@ -298,9 +301,10 @@ StatusPrivArr2Reg LowerGEPForPrivMem::CheckIfAllocaPromotable(llvm::AllocaInst*
298301
SubGroupSizeMetaDataHandle subGroupSize = funcInfoMD->getSubGroupSize();
299302
if (subGroupSize->hasValue())
300303
{
301-
SIMDSize = (uint32_t)subGroupSize->getSIMD_size();
302-
allowedAllocaSizeInBytes = (allowedAllocaSizeInBytes * 8) / SIMDSize;
304+
SIMDSize = std::max((uint32_t)subGroupSize->getSIMD_size(), SIMDSize);
303305
}
306+
307+
allowedAllocaSizeInBytes = (allowedAllocaSizeInBytes * 8) / SIMDSize;
304308
}
305309
Type* baseType = nullptr;
306310
bool allUsesAreVector = false;

0 commit comments

Comments
 (0)