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

Take into account the local involved in GT_SWITCH for resolution #97713

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

kunalspathak
Copy link
Member

No description provided.

@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 Jan 30, 2024
@ghost ghost assigned kunalspathak Jan 30, 2024
@ghost
Copy link

ghost commented Jan 30, 2024

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: kunalspathak
Assignees: kunalspathak
Labels:

area-CodeGen-coreclr

Milestone: -

Comment on lines 8858 to 8864
#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64) || defined(TARGET_X86)
if (op1->IsLocal())
{
GenTreeLclVarCommon* lcl = op1->AsLclVarCommon();
terminatorNodeLclVarDsc = &compiler->lvaTable[lcl->GetLclNum()];
}
#endif
Copy link
Member

@jakobbotsch jakobbotsch Jan 30, 2024

Choose a reason for hiding this comment

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

Nit: can we merge it with below if to make it consistent with the BBJ_COND case? I.e.

if (op1->OperIs(GT_COPY))
{
  // code below
}
else if (op1->IsLocal())
{
  // new code
}

Also, I think op2 should get the handling too

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I think op2 should get the handling too

For GT_SWITCH, isn't the op2 always GT_JMPTABLE?

Copy link
Member

Choose a reason for hiding this comment

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

I think so. But I don't think anything guarantees LSRA doesn't add a GT_COPY on top of it, or something in the future doesn't introduce a local... I think just making it consistent with all the other cases doesn't hurt. In fact we could probably unify all handling here by writing the code something like:

if (block->HasTerminator())
{
  LIR::AsRange(block).LastNode()->VisitOperands([](GenTree* op) {
    if (op->OperIs(GT_COPY))
    {
        ...
    }
    else if (op->IsLocal())
    {
        ...
    }
    return VisitResult::Continue;
  });
}

which would also be a bit more future proof. But I'm also ok with just keeping the special casing for BBJ_COND/BBJ_SWITCH.

@ryujit-bot
Copy link

Diff results for #97713

Throughput diffs

Throughput diffs for windows/arm64 ran on windows/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.windows.arm64.checked.mch -0.01%

Details here


@ryujit-bot
Copy link

Diff results for #97713

Throughput diffs

Throughput diffs for osx/arm64 ran on linux/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.osx.arm64.checked.mch -0.01%

Throughput diffs for windows/arm64 ran on linux/x64

MinOpts (-0.00% to +0.01%)
Collection PDIFF
libraries.pmi.windows.arm64.checked.mch +0.01%

Details here


@kunalspathak kunalspathak marked this pull request as ready for review February 7, 2024 15:42
@kunalspathak kunalspathak merged commit bafd250 into dotnet:main Feb 7, 2024
124 of 129 checks passed
@kunalspathak kunalspathak deleted the switch-resolution branch February 7, 2024 15:42
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2024
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