Skip to content

Commit

Permalink
Discard casts when storing normalize-on-load locals (#66389)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch authored Apr 17, 2022
1 parent d81ac24 commit 0f8dd11
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11619,7 +11619,10 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
effectiveOp1 = op1->gtEffectiveVal();

// If we are storing a small type, we might be able to omit a cast.
if (effectiveOp1->OperIs(GT_IND, GT_CLS_VAR) && varTypeIsSmall(effectiveOp1))
if ((effectiveOp1->OperIs(GT_IND, GT_CLS_VAR) ||
(effectiveOp1->OperIs(GT_LCL_VAR) &&
lvaGetDesc(effectiveOp1->AsLclVarCommon()->GetLclNum())->lvNormalizeOnLoad())) &&
varTypeIsSmall(effectiveOp1))
{
if (!gtIsActiveCSE_Candidate(op2) && op2->OperIs(GT_CAST) &&
varTypeIsIntegral(op2->AsCast()->CastOp()) && !op2->gtOverflow())
Expand Down

0 comments on commit 0f8dd11

Please sign in to comment.