This is an archive of the discontinued LLVM Phabricator instance.

[LoopUtils] Consider unreachable-terminated blocks as deoptimizing
Needs RevisionPublic

Authored by dmakogon on Oct 1 2021, 5:11 AM.

Details

Summary

Previously in function getExpectedExitLoopLatchBranch we considered a block deoptimizing if it had a terminating deoptimize call.
Now updated to it to keep in sync with almost the same logic in LoopPeel (see https://reviews.llvm.org/D110922).
From that patch:

Added support for peeling loops with "deoptimizing" exits - such exits that it or any of its children (or any of their children, etc) either has a @llvm.experimental.deoptimize call
prior to the terminating return instruction of this basic block or is terminated with unreachable. All blocks in the the sequence must have a single successor, maybe except for the > last one.
Previously we only checked the exit block for being deoptimizing. Now we check if the last reachable block from the exit is deoptimizing.

So now we can consider a block deoptimizing if it meets the condition from the quote.
This should help peel loops which have profile data and which have such exits that all paths starting from them converge to a unreachable terminated block or a block which has a terminating deopt call.

Diff Detail

Event Timeline

dmakogon created this revision.Oct 1 2021, 5:11 AM
dmakogon requested review of this revision.Oct 1 2021, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 1 2021, 5:11 AM
dmakogon updated this revision to Diff 377758.Oct 7 2021, 1:24 AM
dmakogon edited the summary of this revision. (Show Details)

Added test and fixed getExpectedExitLoopLatchBranch annotation

reames requested changes to this revision.Oct 7 2021, 9:11 AM

This is not a comment on the code, but a comment on the commit message.

"deoptimizing" has a very specific meaning. An unreachable block is *not* deoptimizing. Given that, the description on the review makes zero sense. (As in, without looking at the code, I literally had no idea what you were trying for.) You need to rework the commit message before this is meaningfully reviewable.

This revision now requires changes to proceed.Oct 7 2021, 9:11 AM