Skip to content

Commit cd5c825

Browse files
lioujheyuigcbot
authored andcommitted
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
1 parent 8ae6734 commit cd5c825

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

IGC/Compiler/GenTTI.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,13 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
344344
// TODO: Can a alloca with a fixed size not reside in the entry block?
345345
if (!AI->isStaticAlloca())
346346
continue;
347-
// Assume every iteration consumes 1 alloca element.
348-
if (cast<ConstantInt>(AI->getArraySize())->getZExtValue() > UnrollMaxCountForAlloca)
349-
continue;
350347

351348
// Using alloca size in bytes as the threshold boost seems a bit tricky.
352349
unsigned AllocaSize = *(AI->getAllocationSizeInBits(DL)) / 8;
350+
// Assume every iteration consumes 1 DW (64 bytes).
351+
if (AllocaSize/8 > UnrollMaxCountForAlloca)
352+
continue;
353+
353354
ThresholdBoost += AllocaSize;
354355
if (GEP)
355356
isGEPLoopInduction[GEP] = true;

0 commit comments

Comments
 (0)