From 5b9e6b24f1e9fd24552ca887a65a404459ec76da Mon Sep 17 00:00:00 2001 From: Mike Danes Date: Mon, 19 Dec 2016 21:53:56 +0200 Subject: [PATCH] Stop narrowing cmp(cast(icon), 0) This isn't useful and requires special code to narrow the cast operand. The expression is constant and compiling such an expression shows that JIT does fold it so it doesn't reach lowering. No FX diffs. Commit migrated from https://github.com/dotnet/coreclr/commit/4c198a2cbbc8412901a83d908d904e177050ef37 --- src/coreclr/src/jit/lower.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/coreclr/src/jit/lower.cpp b/src/coreclr/src/jit/lower.cpp index 29f205a..2aae6ba 100644 --- a/src/coreclr/src/jit/lower.cpp +++ b/src/coreclr/src/jit/lower.cpp @@ -2041,8 +2041,8 @@ void Lowering::LowerCompare(GenTree* cmp) if (((castToType == TYP_BOOL) || (castToType == TYP_UBYTE)) && FitsIn(op2Value)) { - bool canNarrow = ((castOp->OperGet() == GT_CNS_INT) || (castOp->OperGet() == GT_CALL) || - (castOp->OperGet() == GT_LCL_VAR) || castOp->OperIsLogical() || castOp->isMemoryOp()); + bool canNarrow = ((castOp->OperGet() == GT_CALL) || (castOp->OperGet() == GT_LCL_VAR) || + castOp->OperIsLogical() || castOp->isMemoryOp()); if (canNarrow) { @@ -2050,11 +2050,6 @@ void Lowering::LowerCompare(GenTree* cmp) castOp->gtType = castToType; - if (castOp->IsIntegralConst()) - { - castOp->AsIntCon()->SetIconValue(castOp->AsIntCon()->IconValue() & 255); - } - cmp->gtOp.gtOp1 = castOp; cmp->gtFlags |= GTF_UNSIGNED; op2->gtType = castToType; -- 2.7.4