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

Allow deleting any kind of nodes after address mode formation #77872

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5399,28 +5399,19 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable, GenTree* par
{
GenTree* unused = unusedStack.Pop();

// Use a loop to process some of the nodes iteratively
// instead of pushing them on the stack.
while ((unused != base) && (unused != index))
if ((unused != base) && (unused != index))
{
JITDUMP("Removing unused node:\n ");
DISPNODE(unused);

BlockRange().Remove(unused);

if (unused->OperIs(GT_ADD, GT_MUL, GT_LSH))
for (GenTree* operand : unused->Operands())
{
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add DEBUG_DESTROY_NODE(unused); after the for loop?

// Push the first operand and loop back to process the second one.
// This minimizes the stack depth because the second one tends to be
// a constant so it gets processed and then the first one gets popped.
unusedStack.Push(unused->AsOp()->gtGetOp1());
unused = unused->AsOp()->gtGetOp2();
}
else
{
assert(unused->OperIs(GT_CNS_INT));
break;
unusedStack.Push(operand);
}

DEBUG_DESTROY_NODE(unused);
}
}

Expand Down