Skip to content

Commit d9f6b98

Browse files
authored
JIT: Always consider empty remainders to be dying in physical promotion (#88665)
Liveness takes a few shortcuts that means it doesn't always handle the case where there is no remainder as the remainder dying, so add a special case in StructDeaths::IsRemainderDying to take care of this case. Some minor improvements from more last-use copy omission are expected.
1 parent 65611bd commit d9f6b98

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/coreclr/jit/promotion.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ class Promotion
208208
// Class to represent liveness information for a struct local's fields and remainder.
209209
class StructDeaths
210210
{
211-
BitVec m_deaths;
212-
unsigned m_numFields = 0;
211+
BitVec m_deaths;
212+
AggregateInfo* m_aggregate = nullptr;
213213

214214
friend class PromotionLiveness;
215215

216216
private:
217-
StructDeaths(BitVec deaths, unsigned numFields) : m_deaths(deaths), m_numFields(numFields)
217+
StructDeaths(BitVec deaths, AggregateInfo* agg) : m_deaths(deaths), m_aggregate(agg)
218218
{
219219
}
220220

src/coreclr/jit/promotionliveness.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ StructDeaths PromotionLiveness::GetDeathsForStructLocal(GenTreeLclVarCommon* lcl
808808

809809
unsigned lclNum = lcl->GetLclNum();
810810
AggregateInfo* aggInfo = m_aggregates.Lookup(lclNum);
811-
return StructDeaths(aggDeaths, (unsigned)aggInfo->Replacements.size());
811+
return StructDeaths(aggDeaths, aggInfo);
812812
}
813813

814814
//------------------------------------------------------------------------
@@ -820,7 +820,13 @@ StructDeaths PromotionLiveness::GetDeathsForStructLocal(GenTreeLclVarCommon* lcl
820820
//
821821
bool StructDeaths::IsRemainderDying() const
822822
{
823-
BitVecTraits traits(1 + m_numFields, nullptr);
823+
if (m_aggregate->UnpromotedMax <= m_aggregate->UnpromotedMin)
824+
{
825+
// No remainder.
826+
return true;
827+
}
828+
829+
BitVecTraits traits(1 + (unsigned)m_aggregate->Replacements.size(), nullptr);
824830
return BitVecOps::IsMember(&traits, m_deaths, 0);
825831
}
826832

@@ -833,7 +839,9 @@ bool StructDeaths::IsRemainderDying() const
833839
//
834840
bool StructDeaths::IsReplacementDying(unsigned index) const
835841
{
836-
BitVecTraits traits(1 + m_numFields, nullptr);
842+
assert(index < m_aggregate->Replacements.size());
843+
844+
BitVecTraits traits(1 + (unsigned)m_aggregate->Replacements.size(), nullptr);
837845
return BitVecOps::IsMember(&traits, m_deaths, 1 + index);
838846
}
839847

0 commit comments

Comments
 (0)