The RHS should always be a ConstantSDNode. You don't need the dyn_cast. Probably can just assert that it's less the NumElts. We shouldn't form it with out of range values. There's no intrinsic for it. We just use shuffles.