Skip to content

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

Merged
jakobbotsch merged 5 commits into
dotnet:mainfrom
SingleAccretion:LclMorph-Simd-Use
Sep 26, 2022
Merged

Fold SIMD-typed partial access to locals; delete base types from vector constants#74580
jakobbotsch merged 5 commits into
dotnet:mainfrom
SingleAccretion:LclMorph-Simd-Use

Conversation

@SingleAccretion

Copy link
Copy Markdown
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_SIMDIND/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.

@ghostghost added 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 labels Aug 25, 2022
@ghost

Copy link
Copy Markdown

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_SIMDIND/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:-

@JulieLeeMSFTJulieLeeMSFT 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
Copy Markdown
ContributorAuthor

@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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
Member

/azp run runtime-coreclr superpmi-diffs

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch

Copy link
Copy Markdown
Member

Failures are #76041 according to build analysis.

@jakobbotsch
jakobbotsch merged commit 78443b8 into dotnet:mainSep 26, 2022
@SingleAccretion
SingleAccretion deleted the LclMorph-Simd-Use branch September 26, 2022 17:32
@SingleAccretionSingleAccretion mentioned this pull request Sep 28, 2022
jkotas added a commit to jkotas/runtime that referenced this pull request Oct 5, 2022
@ghostghost locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIcommunity-contributionIndicates 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

@SingleAccretion@jakobbotsch@JulieLeeMSFT