File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments