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

Do not CSE constant operands for GT_SIMD vector constructors #71174

Merged
merged 9 commits into from
Jun 23, 2022

Conversation

TIHan
Copy link
Contributor

@TIHan TIHan commented Jun 22, 2022

Description
If a GT_SIMD op contains all constants and is an Init/InitN, then mark each constant as DoNotCSE. This logic already exists for GT_HWINTRINSIC nodes when creating vectors.

Acceptance Criteria

  • CI passes

Diffs

@ghost ghost assigned TIHan Jun 22, 2022
@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 Jun 22, 2022
@ghost
Copy link

ghost commented Jun 22, 2022

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

Issue Details

Description
If a GT_SIMD op contains all constants, then mark each constant as DoNotCSE.

Acceptance Criteria

  • CI passes
Author: TIHan
Assignees: TIHan
Labels:

area-CodeGen-coreclr

Milestone: -

@TIHan
Copy link
Contributor Author

TIHan commented Jun 22, 2022

@dotnet/jit-contrib This is ready. Just will wait for CI to pass.

The diffs that I got were some improvements, but this is going to help us tweak the double constant heuristic in #65176 since we do not want to hoist or CSE these kinds of constants.

@EgorBo
Copy link
Member

EgorBo commented Jun 23, 2022

There is already a similar logic in that method that skips CSE for IMM-able arguments and also for Vector128/256.Create() (because if we do CSE for any argument of constant Vector128 we likely won't be able to replace it with a data section load)

Can you show some examples? I assume you target new Vector(...) - in this case you can just extend the existing logic

runtime/src/coreclr/jit/morph.cpp

Lines 13923 to 13938 in df3bd55

case NI_Vector128_Create:
#if defined(TARGET_XARCH)
case NI_Vector256_Create:
#elif defined(TARGET_ARMARCH)
case NI_Vector64_Create:
#endif
{
bool hwAllArgsAreConst = true;
for (GenTree** use : multiOp->UseEdges())
{
if (!(*use)->OperIsConst())
{
hwAllArgsAreConst = false;
break;
}
}

@TIHan
Copy link
Contributor Author

TIHan commented Jun 23, 2022

An example of this is:

new Vector3(1, 0, 0)

I did see the existing logic there. Wanted to keep it separate but makes sense to combine them since they are so similar.

@TIHan TIHan changed the title Do not CSE constant operands for GT_SIMD Do not CSE constant operands for GT_SIMD vector constructors Jun 23, 2022
@TIHan TIHan added this to the 7.0.0 milestone Jun 23, 2022
@TIHan
Copy link
Contributor Author

TIHan commented Jun 23, 2022

Diffs

@TIHan
Copy link
Contributor Author

TIHan commented Jun 23, 2022

@dotnet/jit-contrib This is ready again, diffs look pretty good. x64 has more improvements because we always CSE double constants in x64, except for positive zero.

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

@TIHan TIHan merged commit 831f778 into dotnet:main Jun 23, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 24, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants