Backport Fix for #8871

Mapreduce didn't work with `Range{BigInt}`, because the length wasn't a
`Int`, because of potential overflow. This patch just converts the
length to Int with a checked conversion, because a mapreduce on larger
arrays will probably never finish anyway.

Also fix some broken test of prod

(cherry picked from commit 94934658e5a8d520a999b552c7116434ce7cc4c4)

Fix test for 32 bit

The test added in #8893 shouldn't use typemax(Int), but typemax(Int64)

(cherry picked from commit 49083be6e7c4ceaa3f457afd1d126084c18615d7)