Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Allow forward substituting small-typed nodes #83969

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/coreclr/jit/forwardsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,7 @@ bool Compiler::fgForwardSubStatement(Statement* stmt)
// 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;
Expand Down Expand Up @@ -845,12 +842,12 @@ bool Compiler::fgForwardSubStatement(Statement* stmt)
}
}

// 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());
}

Expand Down