Provide an optimized replicateM_ implementation #11795