From cd5c825d4dbd132ecf1b4dd4236d9a2ac8962c2d Mon Sep 17 00:00:00 2001 From: "Liou, Jhe-Yu" Date: Fri, 22 Aug 2025 17:34:55 +0000 Subject: [PATCH] Use alloca size instead number of element as the cutoff for promoting loop unrolling Use alloca size instead number of element as the cutoff for promoting loop unrolling --- IGC/Compiler/GenTTI.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IGC/Compiler/GenTTI.cpp b/IGC/Compiler/GenTTI.cpp index 1f6caa025..8bab7ea51 100644 --- a/IGC/Compiler/GenTTI.cpp +++ b/IGC/Compiler/GenTTI.cpp @@ -344,12 +344,13 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, // TODO: Can a alloca with a fixed size not reside in the entry block? if (!AI->isStaticAlloca()) continue; - // Assume every iteration consumes 1 alloca element. - if (cast(AI->getArraySize())->getZExtValue() > UnrollMaxCountForAlloca) - continue; // Using alloca size in bytes as the threshold boost seems a bit tricky. unsigned AllocaSize = *(AI->getAllocationSizeInBits(DL)) / 8; + // Assume every iteration consumes 1 DW (64 bytes). + if (AllocaSize/8 > UnrollMaxCountForAlloca) + continue; + ThresholdBoost += AllocaSize; if (GEP) isGEPLoopInduction[GEP] = true;