Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move the "do not zero-extend setcc" to lowering
It is XARCH-specific and moving it eliminates questionable code
that is trying to compensate for CSE changing the store.
  • Loading branch information
SingleAccretion committed Jun 6, 2021
commit 8014879f0597d551e2b06480c08fdc6286d11442
6 changes: 6 additions & 0 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ void Lowering::LowerStoreIndir(GenTreeStoreInd* node)
}
}

// Optimization: do not unnecessarily zero-extend the result of setcc.
if (varTypeIsByte(node) && (node->Data()->OperIsCompare() || node->Data()->OperIs(GT_SETCC)))
{
node->Data()->ChangeType(TYP_BYTE);
}

ContainCheckStoreIndir(node);
}

Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13394,23 +13394,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
tree->AsOp()->gtOp2 = op2 = op2->AsCast()->CastOp();
}
}
else if (op2->OperIsCompare() && varTypeIsByte(effectiveOp1->TypeGet()))
{
/* We don't need to zero extend the setcc instruction */
op2->gtType = TYP_BYTE;
}
}
// If we introduced a CSE we may need to undo the optimization above
// (i.e. " op2->gtType = TYP_BYTE;" which depends upon op1 being a GT_IND of a byte type)
// When we introduce the CSE we remove the GT_IND and subsitute a GT_LCL_VAR in it place.
else if (op2->OperIsCompare() && (op2->gtType == TYP_BYTE) && (op1->gtOper == GT_LCL_VAR))
{
unsigned varNum = op1->AsLclVarCommon()->GetLclNum();
LclVarDsc* varDsc = &lvaTable[varNum];

/* We again need to zero extend the setcc instruction */
op2->gtType = varDsc->TypeGet();
}
fgAssignSetVarDef(tree);

/* We can't CSE the LHS of an assignment */
Expand Down