Skip to content

Commit ed9a505

Browse files
authored
JIT: Do not remove type changing casts in lowering optimization (#118636)
1 parent b86266d commit ed9a505

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/coreclr/jit/lower.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5316,11 +5316,12 @@ void Lowering::LowerFieldListToFieldListOfRegisters(GenTreeFieldList* fieldLis
53165316
if ((i == numRegs - 1) && varTypeUsesIntReg(regType))
53175317
{
53185318
GenTree* node = regEntry->GetNode();
5319-
// If this is a cast that affects only bits after the return size
5320-
// then it can be removed. Those bits are undefined in all our ABIs
5321-
// for structs.
5322-
while (node->OperIs(GT_CAST) && !node->gtOverflow() && varTypeUsesIntReg(node->CastToType()) &&
5323-
varTypeUsesIntReg(node->CastFromType()) && (genTypeSize(regType) <= genTypeSize(node->CastToType())))
5319+
// If this is a truncation that affects only bits after the return
5320+
// size then it can be removed. Those bits are undefined in all our
5321+
// ABIs for structs.
5322+
while (node->OperIs(GT_CAST) && !node->gtOverflow() && (genActualType(node->CastFromType()) == TYP_INT) &&
5323+
(genActualType(node->CastToType()) == TYP_INT) &&
5324+
(genTypeSize(regType) <= genTypeSize(node->CastToType())))
53245325
{
53255326
GenTree* op = node->AsCast()->CastOp();
53265327
regEntry->SetNode(op);

0 commit comments

Comments
 (0)