// Next statement seems suitable.
// See if we can forward sub without changing semantics.
//
- // Bail if types disagree.
- // Might be able to tolerate these by retyping.
- //
- if (fsv.GetNode()->TypeGet() != fwdSubNode->TypeGet())
+ if (genActualType(fsv.GetNode()) != genActualType(fwdSubNode))
{
JITDUMP(" mismatched types (substitution)\n");
return false;
}
}
- // If the initial has truncate on store semantics, we need to replicate
- // that here with a cast.
+ // If the value is being roundtripped through a small-typed local then we
+ // may need to insert an explicit cast to emulate normalize-on-load/store.
//
- if (varDsc->lvNormalizeOnStore() && fgCastNeeded(fwdSubNode, varDsc->TypeGet()))
+ if (varTypeIsSmall(varDsc) && fgCastNeeded(fwdSubNode, varDsc->TypeGet()))
{
- JITDUMP(" [adding cast for normalize on store]");
+ JITDUMP(" [adding cast for small-typed local]");
fwdSubNode = gtNewCastNode(TYP_INT, fwdSubNode, false, varDsc->TypeGet());
}