diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 8552fc85702f0..2e15bb79699b7 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -10386,6 +10386,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;