Stop narrowing cmp(cast<ubyte>(icon), 0)
authorMike Danes <onemihaid@hotmail.com>
Mon, 19 Dec 2016 19:53:56 +0000 (21:53 +0200)
committerMike Danes <onemihaid@hotmail.com>
Tue, 17 Jan 2017 18:26:27 +0000 (20:26 +0200)
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.

src/jit/lower.cpp

index 29f205a..2aae6ba 100644 (file)
@@ -2041,8 +2041,8 @@ void Lowering::LowerCompare(GenTree* cmp)
 
             if (((castToType == TYP_BOOL) || (castToType == TYP_UBYTE)) && FitsIn<UINT8>(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;