diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 41ae0a9fc6d3b..87528fee51bdf 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -10377,6 +10377,22 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) op1 = node->Op(1); op1->ClearContained(); + + // Drop GT_CAST if it doesn't change the op1's bits we're about to broadcast + if (op1->OperIs(GT_CAST) && !op1->gtOverflow() && comp->opts.Tier0OptimizationEnabled()) + { + GenTreeCast* cast = op1->AsCast(); + if (!varTypeIsFloating(cast->CastToType()) && + !varTypeIsFloating(cast->CastFromType()) && + (genTypeSize(cast->CastToType()) >= genTypeSize(simdBaseType)) && + (genTypeSize(cast->CastFromType()) >= genTypeSize(simdBaseType))) + { + BlockRange().Remove(op1); + op1 = cast->CastOp(); + op1->ClearContained(); + node->Op(1) = op1; + } + } } } break;