Skip to content

Conversation

kunalspathak
Copy link
Contributor

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 26, 2021
@kunalspathak
Copy link
Contributor Author

@dotnet/jit-contrib

// Free Registers.
// We could use the freeRegisters() method, but we'd have to carefully manage the active intervals.
for (regNumber reg = REG_FIRST; reg < ACTUAL_REG_COUNT; reg = REG_NEXT(reg))
for (regNumber reg = REG_FIRST; reg < ACTUAL_REG_COUNT && regsToFree != RBM_NONE; reg = REG_NEXT(reg))
Copy link
Member

Choose a reason for hiding this comment

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

This new clause is a loop invariant, so maybe hoist it out...?

Suggested change
for (regNumber reg = REG_FIRST; reg < ACTUAL_REG_COUNT && regsToFree != RBM_NONE; reg = REG_NEXT(reg))
if (regsToFree != RBM_NONE)
{
for (regNumber reg = REG_FIRST; reg < ACTUAL_REG_COUNT; reg = REG_NEXT(reg))

Or perhaps better yet (but maybe more involved) only iterate over the set bits of regsToFree using find first bit or similar tech (presumably regsToFree is mostly zeros so iterating over each bit is a little wasteful).

Also a few lines below the code seems odd, we should make sure we know which of the assignments is the right one.

            regsToFree = delayRegsToFree;
            regsToFree = RBM_NONE;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out about the regsToFree = delayRegsToFree; , I should have noticed it. But I did notice other problem where delayRegsToFree in this method is never assigned and is always RBM_NONE so the odd code doesn't do any harm. Probably, some day, I should check right way to introduce delayRegsToFree, but for now, I will fix the odd code as well as get rid of delayRegsToFree variable from this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, regsToFree is never used and it was that way from initial commit (6 years back). So as a cleanup, I will also get rid of regsFree and investigate what is the right way as part of #48837.

These two variables were always set to `RBM_NONE`. As part of dotnet#48837, investigate how to reintroduce them.
Base automatically changed from master to main March 1, 2021 09:08
@kunalspathak
Copy link
Contributor Author

@AndyAyersMS or @BruceForstall - can you please review this?

@AndyAyersMS
Copy link
Member

Were you planning to make changes based on my earlier comments, or leave that for a subsequent PR?

@kunalspathak
Copy link
Contributor Author

Were you planning to make changes based on my earlier comments, or leave that for a subsequent PR?

Ah, sorry, I didn't push it. Let me do it.

@kunalspathak kunalspathak merged commit b51270d into dotnet:main Mar 3, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 2, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Apr 15, 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.

3 participants