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

Fold SIMD-typed partial access to locals; delete base types from vector constants #74580

Merged
merged 5 commits into from
Sep 26, 2022

Conversation

SingleAccretion
Copy link
Contributor

Enabling the folding of SIMD-typed indirs in local morph, it was observed that some CSEs were getting lost. The reason was that we always used FLOAT-derived handles for TYP_SIMD IND/LCL_FLD nodes, which would not be available in methods that only used Vector128<int> (for example). This change enhances the "canonical handle" logic to capture handles of other types to use for handle-less nodes.

We have positive diffs due to more CSEs, some light regressions due to more CSEs, and a couple large regressions due to more unrolling (IND<simd> appears cheaper to gtSetEvalOrder than OBJ<simd>).

Closes #70052.

@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 Aug 25, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 25, 2022
@ghost
Copy link

ghost commented Aug 25, 2022

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

Issue Details

Enabling the folding of SIMD-typed indirs in local morph, it was observed that some CSEs were getting lost. The reason was that we always used FLOAT-derived handles for TYP_SIMD IND/LCL_FLD nodes, which would not be available in methods that only used Vector128<int> (for example). This change enhances the "canonical handle" logic to capture handles of other types to use for handle-less nodes.

We have positive diffs due to more CSEs, some light regressions due to more CSEs, and a couple large regressions due to more unrolling (IND<simd> appears cheaper to gtSetEvalOrder than OBJ<simd>).

Closes #70052.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Aug 25, 2022
@SingleAccretion SingleAccretion marked this pull request as ready for review August 25, 2022 22:44
@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib

Comment on lines +914 to +936
CORINFO_CLASS_HANDLE* pCanonicalHnd = nullptr;
switch (size)
{
case 8:
pCanonicalHnd = &m_simdHandleCache->CanonicalSimd8Handle;
break;
case 12:
// There is no need for a canonical SIMD12 handle because it is always Vector3.
break;
case 16:
pCanonicalHnd = &m_simdHandleCache->CanonicalSimd16Handle;
break;
case 32:
pCanonicalHnd = &m_simdHandleCache->CanonicalSimd32Handle;
break;
default:
unreached();
}

if ((pCanonicalHnd != nullptr) && (*pCanonicalHnd == NO_CLASS_HANDLE))
{
*pCanonicalHnd = typeHnd;
}
Copy link
Member

Choose a reason for hiding this comment

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

So essentially the first SIMD handle we see in this function becomes the canonical handle for this compilation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. It's a workaround of course, but doing this "properly" would imply breaking the assumption that (most / all that are looked at) varTypeIsStruct locals have handles. Which is work that will be done at some point, but not now.

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr superpmi-diffs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch
Copy link
Member

Failures are #76041 according to build analysis.

@jakobbotsch jakobbotsch merged commit 78443b8 into dotnet:main Sep 26, 2022
@SingleAccretion SingleAccretion deleted the LclMorph-Simd-Use branch September 26, 2022 17:32
jkotas added a commit to jkotas/runtime that referenced this pull request Oct 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 26, 2022
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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate removing gtSimdBaseJitType from GenTreeVecCon
3 participants