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
This commit is contained in:
Liou, Jhe-Yu
2025-08-22 17:34:55 +00:00
committed by igcbot
parent 8ae6734b82
commit cd5c825d4d

View File

@ -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? // TODO: Can a alloca with a fixed size not reside in the entry block?
if (!AI->isStaticAlloca()) if (!AI->isStaticAlloca())
continue; continue;
// Assume every iteration consumes 1 alloca element.
if (cast<ConstantInt>(AI->getArraySize())->getZExtValue() > UnrollMaxCountForAlloca)
continue;
// Using alloca size in bytes as the threshold boost seems a bit tricky. // Using alloca size in bytes as the threshold boost seems a bit tricky.
unsigned AllocaSize = *(AI->getAllocationSizeInBits(DL)) / 8; unsigned AllocaSize = *(AI->getAllocationSizeInBits(DL)) / 8;
// Assume every iteration consumes 1 DW (64 bytes).
if (AllocaSize/8 > UnrollMaxCountForAlloca)
continue;
ThresholdBoost += AllocaSize; ThresholdBoost += AllocaSize;
if (GEP) if (GEP)
isGEPLoopInduction[GEP] = true; isGEPLoopInduction[GEP] = true;