`defaultIsSmallAlloc` called `ShapedType::getNumElements()` which
asserts when the static element count overflows `int64_t` (e.g. a
`memref<3090540x3090540x3090540xi32>` whose element count is ~29e18).
Switch to `ShapedType::tryGetNumElements()`, which returns
`std::nullopt` on overflow. An overflowing element count means the
allocation is definitely not small, so we return `false` immediately. A
secondary overflow guard is added for the final size comparison.
Fixes#64638
Assisted-by: Claude Code