diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index beb9089ab319d5..2e2732d2cc89a9 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -152,7 +152,25 @@ bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode) const if (immVal == 0) return true; break; -#endif +#endif // TARGET_ARM64 + + case GT_LSH: + case GT_RSH: + case GT_RSZ: + case GT_ROL: + case GT_ROR: + // genCodeForShift masks the constant to (immWidth - 1) before emitting, + // so any integer immediate is valid and containable. + return true; + +#ifdef TARGET_ARM + case GT_LSH_HI: + case GT_RSH_LO: + // genCodeForShiftLong does not mask, so validate the range. + // DecomposeLongs produces counts in 1..31; allow 0..32 for the + // LSR/ASR idiom where 0 encodes a shift of 32. + return (immVal >= 0) && (immVal <= 32); +#endif // TARGET_ARM default: break; @@ -2909,10 +2927,7 @@ void Lowering::ContainCheckShiftRotate(GenTreeOp* node) } #endif // TARGET_ARM - if (shiftBy->IsCnsIntOrI()) - { - MakeSrcContained(node, shiftBy); - } + CheckImmedAndMakeContained(node, shiftBy); } //------------------------------------------------------------------------