Skip to content

Commit 70b5d83

Browse files
Do not discard byref zeros in native int + byref additions (#68086)
* Delete morph transform * Reinstate assert
1 parent 3f4585c commit 70b5d83

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/coreclr/jit/gentree.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,8 +6189,7 @@ struct GenTreeArrAddr : GenTreeUnOp
61896189
, m_elemType(elemType)
61906190
, m_firstElemOffset(firstElemOffset)
61916191
{
6192-
// Temporarily disable this assert. Tracking: https://github.com/dotnet/runtime/issues/67600
6193-
// assert(addr->TypeIs(TYP_BYREF) || addr->IsIntegralConst(0));
6192+
assert(addr->TypeIs(TYP_BYREF));
61946193
assert(((elemType == TYP_STRUCT) && (elemClassHandle != NO_CLASS_HANDLE)) ||
61956194
(elemClassHandle == NO_CLASS_HANDLE));
61966195

src/coreclr/jit/morph.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13074,9 +13074,8 @@ GenTree* Compiler::fgOptimizeAddition(GenTreeOp* add)
1307413074
DEBUG_DESTROY_NODE(constTwo);
1307513075
}
1307613076

13077-
// Fold (x + 0) - given it won't change the tree type to TYP_REF.
13078-
// TODO-Bug: this code will lose the GC-ness of a tree like "native int + byref(0)".
13079-
if (op2->IsIntegralConst(0) && ((add->TypeGet() == op1->TypeGet()) || !op1->TypeIs(TYP_REF)))
13077+
// Fold (x + 0) - given it won't change the tree type.
13078+
if (op2->IsIntegralConst(0) && (genActualType(add) == genActualType(op1)))
1308013079
{
1308113080
if (op2->IsCnsIntOrI() && varTypeIsI(op1))
1308213081
{

0 commit comments

Comments
 (0)