Skip to content

Commit 5a08c84

Browse files
authored
Merge pull request #6 from jakobbotsch/stack-allocate-unescaped-boxes-lclmorph
Minor fixes
2 parents 56500c3 + 67402d4 commit 5a08c84

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

src/coreclr/jit/lclmorph.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,34 +1033,30 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
10331033
assert(TopValue(1).Node() == node->AsOp()->gtOp1);
10341034
assert(TopValue(0).Node() == node->AsOp()->gtOp2);
10351035

1036-
GenTree* op1 = node->AsOp()->gtOp1;
1037-
GenTree* op2 = node->AsOp()->gtOp2;
1038-
bool rewrite = false;
1036+
Value& lhs = TopValue(1);
1037+
Value& rhs = TopValue(0);
10391038

1040-
if (op1->OperIs(GT_LCL_ADDR) && op2->IsIntegralConst(0))
1039+
if ((lhs.IsAddress() && rhs.Node()->IsIntegralConst(0)) ||
1040+
(rhs.IsAddress() && lhs.Node()->IsIntegralConst(0)))
10411041
{
1042-
op1 = m_compiler->gtNewIconNode(1);
1043-
op2->ChangeType(TYP_INT);
1044-
rewrite = true;
1045-
}
1046-
else if (op2->OperIs(GT_LCL_ADDR) && op1->IsIntegralConst(0))
1047-
{
1048-
op2 = m_compiler->gtNewIconNode(1);
1049-
op1->ChangeType(TYP_INT);
1050-
rewrite = true;
1051-
}
1042+
JITDUMP("Rewriting known address-of comparison [%06u]\n", m_compiler->dspTreeID(node));
1043+
*lhs.Use() = m_compiler->gtNewIconNode(0);
1044+
*rhs.Use() = m_compiler->gtNewIconNode(1);
1045+
m_stmtModified = true;
10521046

1053-
if (rewrite)
1047+
INDEBUG(TopValue(0).Consume());
1048+
INDEBUG(TopValue(1).Consume());
1049+
PopValue();
1050+
PopValue();
1051+
}
1052+
else
10541053
{
1055-
JITDUMP("Rewriting known address-of comparison [%06u]\n", m_compiler->dspTreeID(node));
1056-
node->AsOp()->gtOp1 = op1;
1057-
node->AsOp()->gtOp2 = op2;
1054+
EscapeValue(TopValue(0), node);
1055+
PopValue();
1056+
EscapeValue(TopValue(0), node);
1057+
PopValue();
10581058
}
10591059

1060-
INDEBUG(TopValue(0).Consume());
1061-
INDEBUG(TopValue(1).Consume());
1062-
PopValue();
1063-
PopValue();
10641060
break;
10651061
}
10661062

src/coreclr/jit/lclvars.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,7 @@ bool Compiler::StructPromotionHelper::CanPromoteStructVar(unsigned lclNum)
25502550
if (varDsc->lvStackAllocatedBox)
25512551
{
25522552
JITDUMP(" struct promotion of V%02u is disabled because it is a stack allocated box\n", lclNum);
2553+
return false;
25532554
}
25542555

25552556
#ifdef SWIFT_SUPPORT

0 commit comments

Comments
 (0)