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

Fix a couple issues with Vector128.Get/WithElement #52985

Merged
13 commits merged into from
May 25, 2021

Conversation

tannergooding
Copy link
Member

@tannergooding tannergooding commented May 19, 2021

This resolves #52959 by ensuring that we don't have any unused nodes and that containment checks bail when encountering TYP_SIMD8 or TYP_SIMD12 values where a TYP_SIMD16 or TYP_SIMD32 value is required for containment.
This resolves #52954 by ensuring the expected exception is the one thrown by all Vector indexing
This resolves #53157
This resolves #37260

@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 May 19, 2021
@tannergooding
Copy link
Member Author

CC. @jkotas, @echesakovMSFT

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tannergooding tannergooding changed the title Fix an issue with Vector128.WithElement around unused nodes for pre SSE4.1 Fix a couple issues with Vector128.Get/WithElement May 19, 2021
@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jkotas
Copy link
Member

jkotas commented May 20, 2021

Now failing with:

D:\workspace\_work\1\s\src\coreclr\jit\lower.cpp:6025
Assertion failed 'compiler->lvaIsFieldOfDependentlyPromotedStruct(lclVar) || (lclVar->lvSize() == 12)' in 'System.Runtime.Intrinsics.Vector128:AsVector128(System.Numerics.Vector3):System.Runtime.Intrinsics.Vector128`1[System.Single]' during 'Lowering nodeinfo' (IL size 17)

@clamp03 clamp03 mentioned this pull request May 20, 2021
@tannergooding
Copy link
Member Author

Now failing with:

This was because we are cloning a TYP_SIMD12 LclVar in lowering. Lowering "widens" (changes the type) of these to TYP_SIMD16 which causes an assert when the types mismatch on clone.
I resolved this by allowing specifically the TYP_SIMD16 LclVar node over a TYP_SIMD12 backing VarDsc.

There is also a failure in the logic for WithElement in the pre-SSE4.1 path which I've fixed.

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jkotas
Copy link
Member

jkotas commented May 20, 2021

Assertion failed 'compiler->lvaIsFieldOfDependentlyPromotedStruct(lclVar) || (lclVar->lvSize() == 12)' in 'System.Runtime.Intrinsics.Vector128:AsVector128(System.Numerics.Vector3):System.Runtime.Intrinsics.Vector128`1[System.Single]' during 'Lowering nodeinfo' (IL size 17)

I am still seeing this failure even with the latest commit.

@tannergooding
Copy link
Member Author

I am still seeing this failure even with the latest commit.

Should be resolved now. Both the LclVar and assignment need to be lowered for ReplaceWithLclVar over TYP_SIMD12 nodes.

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@tannergooding
Copy link
Member Author

@jkotas, all tests are passing now. This should be good now.

@jkotas
Copy link
Member

jkotas commented May 21, 2021

@jkotas, all tests are passing now. This should be good now.

Thank you. I see all tests passing in runtimelab NativeAOT branch - where I found it initially - as well.

@tannergooding
Copy link
Member Author

@echesakovMSFT, @dotnet/jit-contrib can I get a review to unblock the failing jitstress/outerloop tests?

@tannergooding
Copy link
Member Author

@echesakovMSFT, @dotnet/jit-contrib can I get a review to unblock the failing jitstress/outerloop tests?

Copy link
Contributor

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

I am not against unblocking outerloop I am just worried it could create more issues, I suggest disabling the failing test in separate PR and take time to finish this.

// We need to lower the LclVar and assignment since there may be certain
// types or scenarios, such as TYP_SIMD12, that need special handling

LowerNode(assign);
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think it is a correct approach, this function is used during different phases, for example, during long decomposition, so calling LowerNode during it is incorrect.
ReplaceWithLclVar creates such IR:

currentNode
storeCurrentNodeToNewNode
NewNodeUse

and lowering works node by node, so after we are done with currentNode we should go to the next and lower it, why don't we?

See, for example, LowerSwitch

ReplaceWithLclVar(use);

we call ReplaceWithLclVar and it creates these new nodes, but then we return node->gtNext that is the created store:
GenTree* next = node->gtNext;
// Get rid of the GT_SWITCH(temp).
switchBBRange.Remove(node->AsOp()->gtOp1);
switchBBRange.Remove(node);
return next;

and it does their lowering.

Copy link
Member Author

Choose a reason for hiding this comment

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

The one used in long decomposition is the instance method exposed on LIR::Use which is distinct from this method that is explicit to lowering and which itself calls into the LIR::Use method

Copy link
Member Author

@tannergooding tannergooding May 24, 2021

Choose a reason for hiding this comment

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

and lowering works node by node, so after we are done with currentNode we should go to the next and lower it, why don't we?

We should already have lowered all the previous nodes, we aren't removing the "current" node, and we aren't inserting a node after the "current" node, so the "next" node is already correct. We simply need to ensure new nodes created and inserted before this node are also lowered.

This is how the existing HWIntrinsic and SimdIntrinsics lowering has been handled and so the same technique is used here as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should already have lowered all the previous nodes, we aren't removing the "current" node,

Agree

and we aren't inserting a node after the "current" node, so the "next" node is already correct.

Don't understand, ReplaceWithLclVar creates new nodes and inserts them after the "current" node, what do you mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't understand, ReplaceWithLclVar creates new nodes and inserts them after the "current" node, what do you mean?

ReplaceWithLclVar creates new nodes and inserts them after the node it replaces. In this case, we are replacing an operand of the "current" node, which means it precedes the current node in the list and will already have been lowered.

Copy link
Contributor

@echesakov echesakov left a comment

Choose a reason for hiding this comment

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

I am still reviewing the changes in 1a4e854
But I want to release some comments to speed up the review process

src/coreclr/jit/gentree.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/simd.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/lower.h Show resolved Hide resolved
@sandreenko sandreenko dismissed their stale review May 24, 2021 20:56

got an explanation

src/coreclr/jit/lowerxarch.cpp Show resolved Hide resolved
src/tests/JIT/SIMD/VectorGet.cs Show resolved Hide resolved
src/coreclr/jit/lower.h Show resolved Hide resolved
src/coreclr/jit/lowerxarch.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/morph.cpp Outdated Show resolved Hide resolved
@tannergooding
Copy link
Member Author

/azp run runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-arm, runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

@echesakov echesakov left a comment

Choose a reason for hiding this comment

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

Looks Good but have some additional questions

src/coreclr/jit/morph.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/morph.cpp Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented May 25, 2021

Hello @tannergooding!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 5f15498 into dotnet:main May 25, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2021
@tannergooding tannergooding deleted the fix-52959 branch November 11, 2022 15:27
This pull request was closed.
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
4 participants