Skip to content

Commit 2541b7b

Browse files
Report more accurately when loop unrolling changes the IR (#80310)
Since unrolling rarely kicks in, reduce JitDump volume by not printing IR in the JitDump after the unrolling phase unless necessary.
1 parent b577e6b commit 2541b7b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/coreclr/jit/optimizer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4035,16 +4035,10 @@ PhaseStatus Compiler::optUnrollLoops()
40354035
}
40364036
#endif
40374037

4038-
#ifdef DEBUG
4039-
if (verbose)
4040-
{
4041-
printf("*************** In optUnrollLoops()\n");
4042-
}
4043-
#endif
4044-
40454038
/* Look for loop unrolling candidates */
40464039

40474040
bool change = false;
4041+
bool anyIRchange = false;
40484042
bool anyNestedLoopsUnrolled = false;
40494043
INDEBUG(int unrollCount = 0); // count of loops unrolled
40504044
INDEBUG(int unrollFailures = 0); // count of loops attempted to be unrolled, but failed
@@ -4273,6 +4267,11 @@ PhaseStatus Compiler::optUnrollLoops()
42734267
}
42744268
// clang-format on
42754269

4270+
// After this point, assume we've changed the IR. In particular, we call gtSetStmtInfo() which
4271+
// can modify the IR. We may still fail to unroll if the EH region conditions don't hold, if
4272+
// the size heuristics don't succeed, or if cloning any individual block fails.
4273+
anyIRchange = true;
4274+
42764275
// Heuristic: Estimated cost in code size of the unrolled loop.
42774276

42784277
{
@@ -4544,6 +4543,8 @@ PhaseStatus Compiler::optUnrollLoops()
45444543

45454544
if (change)
45464545
{
4546+
assert(anyIRchange);
4547+
45474548
#ifdef DEBUG
45484549
if (verbose)
45494550
{
@@ -4588,7 +4589,7 @@ PhaseStatus Compiler::optUnrollLoops()
45884589
fgDebugCheckBBlist(true);
45894590
#endif // DEBUG
45904591

4591-
return PhaseStatus::MODIFIED_EVERYTHING;
4592+
return anyIRchange ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
45924593
}
45934594
#ifdef _PREFAST_
45944595
#pragma warning(pop)

0 commit comments

Comments
 (0)