Skip to content

Commit

Permalink
Correct branch folding for HCR guard versioning
Browse files Browse the repository at this point in the history
This logic has been inadvertently folding the versioning test instead of
the original guard since ce45970, which
is effectively the same as not versioning the guards. This can be
expected to have resulted in slower code than intended. Worse, if there
are HCR guards in the loop, then once the fixed-point analysis has
determined that it is possible to version them, they must be versioned
for correctness. This is because other transformations may rely on the
cold side being eliminated from the hot loop. In particular, by failing
to version HCR guards, we could privatize mutable fields even though
they could be modified by a cold call while the loop is still running.
  • Loading branch information
jdmpapin committed Dec 4, 2023
1 parent edcb5c6 commit 63a9134
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/optimizer/LoopVersioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4585,7 +4585,7 @@ void TR_LoopVersioner::versionNaturalLoop(TR_RegionStructure *whileLoop, List<TR
comparisonTrees.add(guard);

bool reverseBranch = false, origLoop = true;
FoldConditional fold(this, NULL, guard, reverseBranch, origLoop);
FoldConditional fold(this, NULL, tt->getNode(), reverseBranch, origLoop);
fold.improveLoop();
}
}
Expand Down

0 comments on commit 63a9134

Please sign in to comment.