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

Keep correct fieldSeq for 0-offset fields. #32085

Merged
merged 5 commits into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
48 changes: 43 additions & 5 deletions src/coreclr/src/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ GenTree* Lowering::LowerNode(GenTree* node)
break;

case GT_ADD:
LowerAdd(node->AsOp());
break;
{
GenTree* next = LowerAdd(node->AsOp());
if (next != nullptr)
{
return next;
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is missing a proper function header comment

}
}
break;

#if !defined(TARGET_64BIT)
case GT_ADD_LO:
Expand Down Expand Up @@ -4498,12 +4504,43 @@ bool Lowering::TryCreateAddrMode(GenTree* addr, bool isContainable)
// Arguments:
// node - the node we care about
//
void Lowering::LowerAdd(GenTreeOp* node)
// Returns:
Copy link
Contributor

Choose a reason for hiding this comment

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

This also needs to be in the (missing) function header for
GenTree* Lowering::LowerNode(GenTree* node)

// nullptr if no transformation was done, or the next node in the transformed node sequence that
// needs to be lowered.
//
GenTree* Lowering::LowerAdd(GenTreeOp* node)
{
#ifndef TARGET_ARMARCH
if (varTypeIsIntegralOrI(node->TypeGet()))
{
GenTree* op1 = node->gtGetOp1();
GenTree* op2 = node->gtGetOp2();
LIR::Use use;

// It is not the best place to do such simple arithmetic optimizations,
// but it allows us to avoid `LEA(addr, 0)` nodes and doing that in morph
// requires more changes. Delete that part if we get an expression optimizer.
if (op2->IsIntegralConst(0))
{
JITDUMP("Lower: optimize val + 0: ");
DISPNODE(node);
JITDUMP("Replaced with: ");
DISPNODE(op1);
if (BlockRange().TryGetUse(node, &use))
{
use.ReplaceWith(comp, op1);
}
else
{
op1->SetUnusedValue();
}
GenTree* next = node->gtNext;
BlockRange().Remove(op2);
BlockRange().Remove(node);
JITDUMP("Remove [06%u], [06%u]\n", op2->gtTreeID, node->gtTreeID);
return next;
}

#ifndef TARGET_ARMARCH
if (BlockRange().TryGetUse(node, &use))
{
// If this is a child of an indir, let the parent handle it.
Expand All @@ -4514,13 +4551,14 @@ void Lowering::LowerAdd(GenTreeOp* node)
TryCreateAddrMode(node, false);
}
}
}
#endif // !TARGET_ARMARCH
}

if (node->OperIs(GT_ADD))
{
ContainCheckBinary(node);
}
return nullptr;
}

//------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class Lowering final : public Phase

// Per tree node member functions
void LowerStoreIndir(GenTreeIndir* node);
void LowerAdd(GenTreeOp* node);
GenTree* LowerAdd(GenTreeOp* node);
bool LowerUnsignedDivOrMod(GenTreeOp* divMod);
GenTree* LowerConstIntDivOrMod(GenTree* node);
GenTree* LowerSignedDivOrMod(GenTree* node);
Expand Down
Loading