Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments and cleanup for loop cloning #49768

Merged
merged 3 commits into from
Mar 23, 2021

Conversation

BruceForstall
Copy link
Member

This is a no-diff change

Added various comments to document loop cloning.

Standardized and improved some logging.

Consolidated more loop cloning condition checking into
optIsLoopClonable that was previously in optIdentifyLoopOptInfo.

Replaced some 0 weights with BB_ZERO_WEIGHT.

Made FMT_BB use pervasive.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 17, 2021
@BruceForstall
Copy link
Member Author

@dotnet/jit-contrib

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments. Likely you can defer them for future PRs.

src/coreclr/jit/loopcloning.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Show resolved Hide resolved
@@ -346,6 +346,9 @@ void CodeGen::genCodeForBBlist()
if ((block->bbPrev != nullptr) && (block->bbPrev->bbJumpKind == BBJ_COND) &&
(block->bbWeight != block->bbPrev->bbWeight))
{
JITDUMP("Adding label due to BB weight difference: BBJ_COND " FMT_BB " with weight " FMT_WT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are here, I am wondering if there is an easy way to add towards the end the mapping of BB -> IG somehow? While looking at JITDump, it is not straightforward to find this mapping and is very helpful overall when we look backward in JITDump.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments.

src/coreclr/jit/loopcloning.h Show resolved Hide resolved
@@ -43,45 +117,78 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Heuristic:
Therefore we will not clone if we exceed creating 4 blocks.
Note: this means we never clone more than 2-dimension a[i][j] expressions
(see optComputeDerefConditions()).
REVIEW: make this heuristic defined by a COMPlus variable, for easier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this heuristic defined by a COMPlus variable,

+1 on that.

src/coreclr/jit/loopcloning.h Show resolved Hide resolved
src/coreclr/jit/loopcloning.cpp Show resolved Hide resolved
src/coreclr/jit/loopcloning.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/optimizer.cpp Outdated Show resolved Hide resolved
This is a no-diff change

Added various comments to document loop cloning.

Standardized and improved some logging.

Consolidated more loop cloning condition checking into
`optIsLoopClonable` that was previously in `optIdentifyLoopOptInfo`.

Replaced some `0` weights with `BB_ZERO_WEIGHT`.

Made FMT_BB use pervasive.
Added FMT_LP formatting string.

Cached often-used `optLoopTable[loopInd]` expression.

Added `const` to many loop query member functions.

Added static `GenTree::OperIs(compareOper, oper, oper, oper...)`
functions for simplifying oper check expressions where the
compareOper isn't from a GenTree node `OperGet()`. (This doesn't
need to be part of GenTree, but it doesn't hurt, either.)

Added a few more comments.
Rename to StaticOperIs. It appears the compiler uses the wrong
template in some cases, but doesn't complain about duplicate
options, leading to run-time failures.
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Mar 23, 2021
@BruceForstall BruceForstall merged commit cb88894 into dotnet:main Mar 23, 2021
@BruceForstall BruceForstall deleted the LoopOpts3 branch March 23, 2021 21:01
@ghost ghost locked as resolved and limited conversation to collaborators Apr 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants