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.
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)
{
castOp->gtType = castToType;
- if (castOp->IsIntegralConst())
- {
- castOp->AsIntCon()->SetIconValue(castOp->AsIntCon()->IconValue() & 255);
- }
-
cmp->gtOp.gtOp1 = castOp;
cmp->gtFlags |= GTF_UNSIGNED;
op2->gtType = castToType;