Skip to content
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
Use local assertion prop to omit casts on returns
When inserting normalizing casts for returns in pre-order
morph, "fgMorphCast" was used, which did not account for
the fact that local assertion propagation could tell us
that the cast is in fact unnecessary. Fix this by calling
"fgMorphTree" instead.

Also some miscellaneous code cleanup.
  • Loading branch information
SingleAccretion committed Jul 14, 2021
commit 77da47c87ef4177dcb659119ea5424dcdcb1ccf5
7 changes: 3 additions & 4 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11478,7 +11478,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)

case GT_RETURN:
// normalize small integer return values
if (fgGlobalMorph && varTypeIsSmall(info.compRetType) && (op1 != nullptr) && (op1->TypeGet() != TYP_VOID) &&
if (fgGlobalMorph && varTypeIsSmall(info.compRetType) && (op1 != nullptr) && !op1->TypeIs(TYP_VOID) &&
fgCastNeeded(op1, info.compRetType))
{
// Small-typed return values are normalized by the callee
Expand All @@ -11487,11 +11487,10 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
// Propagate GTF_COLON_COND
op1->gtFlags |= (tree->gtFlags & GTF_COLON_COND);

tree->AsOp()->gtOp1 = fgMorphCast(op1);
tree->AsOp()->gtOp1 = fgMorphTree(op1);

// Propagate side effect flags
tree->gtFlags &= ~GTF_ALL_EFFECT;
tree->gtFlags |= (tree->AsOp()->gtOp1->gtFlags & GTF_ALL_EFFECT);
tree->SetAllEffectsFlags(tree->AsOp()->gtGetOp1());

return tree;
}
Expand Down