Skip to content

Commit

Permalink
Do not discard byref zeros in native int + byref additions (#68086)
Browse files Browse the repository at this point in the history
* Delete morph transform

* Reinstate assert
  • Loading branch information
SingleAccretion committed May 12, 2022
1 parent 3f4585c commit 70b5d83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6189,8 +6189,7 @@ struct GenTreeArrAddr : GenTreeUnOp
, m_elemType(elemType)
, m_firstElemOffset(firstElemOffset)
{
// Temporarily disable this assert. Tracking: https://github.com/dotnet/runtime/issues/67600
// assert(addr->TypeIs(TYP_BYREF) || addr->IsIntegralConst(0));
assert(addr->TypeIs(TYP_BYREF));
assert(((elemType == TYP_STRUCT) && (elemClassHandle != NO_CLASS_HANDLE)) ||
(elemClassHandle == NO_CLASS_HANDLE));

Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13074,9 +13074,8 @@ GenTree* Compiler::fgOptimizeAddition(GenTreeOp* add)
DEBUG_DESTROY_NODE(constTwo);
}

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

0 comments on commit 70b5d83

Please sign in to comment.