Skip to content

Commit b8a9364

Browse files
fftzengsys_zuul
authored andcommitted
Fix an issue with multiplation overhead for unrolling estimation
Change-Id: Idb6a62e8b87e295f8a7f9583c9cd698d744d79c0
1 parent 2a551e0 commit b8a9364

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

IGC/Compiler/GenTTI.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,17 @@ namespace llvm {
380380
}
381381
}
382382

383-
int estimateUnrolledInstCount = (instCount + sendMessage * 4) * TripCount;
384-
int unrollLimitInstCount = MAX(LoopUnrollThreshold - totalInstCountInShader, 0);
383+
unsigned int estimateUnrolledInstCount = (instCount + sendMessage * 4) * TripCount;
384+
unsigned int unrollLimitInstCount = LoopUnrollThreshold > totalInstCountInShader ? LoopUnrollThreshold - totalInstCountInShader : 0;
385+
bool limitUnrolling = (estimateUnrolledInstCount > unrollLimitInstCount) ||
386+
(TripCount > unrollLimitInstCount) ||
387+
(instCount + sendMessage * 4 > unrollLimitInstCount);
385388

386389
// if the loop doesn't have sample, skip the unrolling parameter change
387390
if (!sendMessage)
388391
{
389392
// if the estimated unrolled instruction count is larger than the unrolling threshold, limit unrolling.
390-
if (estimateUnrolledInstCount > unrollLimitInstCount)
393+
if (limitUnrolling)
391394
{
392395
UP.Count = MIN(unrollLimitInstCount / (instCount + sendMessage * 4), 4);
393396
if (TripCount != 0)
@@ -399,7 +402,7 @@ namespace llvm {
399402
}
400403

401404
// if the TripCount is known, and the estimated unrolled count exceed LoopUnrollThreshold, set the unrolling count to 4
402-
if (estimateUnrolledInstCount > unrollLimitInstCount)
405+
if (limitUnrolling)
403406
{
404407
UP.Count = MIN(TripCount, 4);
405408
UP.MaxCount = UP.Count;

0 commit comments

Comments
 (0)