Skip to content

[JIT] ARM64 - Fix Assertion failed 'node->OperIs(GT_DIV, GT_UDIV, GT_MOD)' during 'Lowering nodeinfo' - #85664

Merged
TIHan merged 4 commits into
dotnet:mainfrom
TIHan:85630-fix
May 3, 2023
Merged

TIHan merged 4 commits into
dotnet:mainfrom
TIHan:85630-fix

Conversation

@TIHan

@TIHan TIHan commented May 2, 2023 •

Copy link
Copy Markdown
Contributor

Resolves #85630

Description

There was a case where the node was lowered from LowerModPow2 but node->gtNext would return nullptr from LowerConstIntDivOrMod which indicates the node was not transformed when it actually was.

Best way to solve this is return a bool indicating if the transformation was successful or not and also provide an out parameter for the next node to lower. So, this renames LowerConstIntDivOrMod to TryLowerConstIntDivOrMod with an out parameter for the next node to lower.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 2, 2023
@ghost ghost assigned TIHan May 2, 2023
@ghost

ghost commented May 2, 2023

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

Resolves #85630

Description

There was a case where the node was lowered from LowerModPow2 but node->gtNext would return nullptr from LowerConstIntDivOrMod which indicates the node was not transformed when it actually was.

Best way to solve this is return a bool indicating if the transformation was successful or not, and also provide an out parameter for the next node to lower. So, this renames LowerConstIntDivOrMod to TryLowerConstIntDivOrMod with an out parameter for the next node to lower.

Author: TIHan
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@TIHan

TIHan commented May 2, 2023 •

Copy link
Copy Markdown
Contributor Author

@dotnet/jit-contrib @kunalspathak this is ready - no diffs

Current CI failure is unrelated.

Comment thread src/tests/JIT/Regression/JitBlue/Runtime_85630/Runtime_85630.csproj
Comment thread src/coreclr/jit/lower.cpp
bool Lowering::TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode)
{
assert((node->OperGet() == GT_DIV) || (node->OperGet() == GT_MOD));
assert(nextNode != nullptr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be initialized *nextNode = nullptr which should be the case if this method returns false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We have a similar TryLowerAndNegativeOne with an out parameter nextNode and we do not set that to nullptr or when we return false.

Comment thread src/coreclr/jit/lower.cpp
if (TryLowerConstIntDivOrMod(node, &nextNode))
{
return newNode;
return nextNode;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assert(nextNode != nullptr)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue is that nextCode can be a nullptr even if the transformation was successful.

But, we could add an assert assert(nextNode == nullptr); if the transformation wasn't successful.

@ghost ghost added needs-author-action An issue or pull request that requires more info or actions from the author. and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels May 2, 2023
@TIHan

TIHan commented May 2, 2023

Copy link
Copy Markdown
Contributor Author

@kunalspathak this is ready again

@kunalspathak

Copy link
Copy Markdown
Contributor

Surprisingly the simplified test is still not simple, but don't want to waste your time trying to trim it further.

@kunalspathak kunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@TIHan

TIHan commented May 3, 2023

Copy link
Copy Markdown
Contributor Author

Merging. CI failure is unrelated.

@TIHan
TIHan merged commit 56eff9f into dotnet:main May 3, 2023
@TIHan
TIHan deleted the 85630-fix branch May 3, 2023 03:06
@ghost ghost locked as resolved and limited conversation to collaborators Jun 2, 2023
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.

Assertion failed 'node->OperIs(GT_DIV, GT_UDIV, GT_MOD)' during 'Lowering nodeinfo'

3 participants