From 40af4853a24ff6a861d33b9a3ecf4d5bb3a474f7 Mon Sep 17 00:00:00 2001 From: Eugene Rozenfeld Date: Tue, 25 Apr 2017 13:38:39 -0700 Subject: [PATCH] Add missing opcodes for morph cast narrowing. The narrowing can be applied to GT_SUB, GT_NOT, GT_NEG, and GT_LSH in addition to GT_ADD, GT_MUL, GT_AND, GT_OR, and GT_XOR that were already supported. --- src/jit/morph.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index aad413d1cb..07c09b5e76 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -450,14 +450,16 @@ GenTreePtr Compiler::fgMorphCast(GenTreePtr tree) // For these operations the lower 32 bits of the result only depends // upon the lower 32 bits of the operands // - if ((oper->OperGet() == GT_ADD) || (oper->OperGet() == GT_MUL) || (oper->OperGet() == GT_AND) || - (oper->OperGet() == GT_OR) || (oper->OperGet() == GT_XOR)) + if (oper->OperIs(GT_ADD, GT_SUB, GT_MUL, GT_AND, GT_OR, GT_XOR, GT_NOT, GT_NEG, GT_LSH)) { DEBUG_DESTROY_NODE(tree); // Insert narrowing casts for op1 and op2 oper->gtOp.gtOp1 = gtNewCastNode(TYP_INT, oper->gtOp.gtOp1, dstType); - oper->gtOp.gtOp2 = gtNewCastNode(TYP_INT, oper->gtOp.gtOp2, dstType); + if (oper->gtOp.gtOp2 != nullptr) + { + oper->gtOp.gtOp2 = gtNewCastNode(TYP_INT, oper->gtOp.gtOp2, dstType); + } // Clear the GT_MUL_64RSLT if it is set if (oper->gtOper == GT_MUL && (oper->gtFlags & GTF_MUL_64RSLT)) -- 2.34.1