diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index eb4a019a73dfa..17a8ed97cbd26 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -16166,6 +16166,10 @@ void Compiler::fgMorphLocalField(GenTree* tree, GenTree* parent) } else { + // There is no existing field that has all the parts that we need + // So we must ensure that the struct lives in memory. + lvaSetVarDoNotEnregister(lclNum DEBUGARG(DoNotEnregisterReason::LocalField)); + #ifdef DEBUG // We can't convert this guy to a float because he really does have his // address taken.. @@ -16174,12 +16178,6 @@ void Compiler::fgMorphLocalField(GenTree* tree, GenTree* parent) } } } - - // If we haven't replaced the field, make sure to set DNER on the local. - if (tree->OperIs(GT_LCL_FLD)) - { - lvaSetVarDoNotEnregister(lclNum DEBUGARG(DoNotEnregisterReason::LocalField)); - } } //------------------------------------------------------------------------