[polly][NFC] Refactor reduction detection code for modularity (#72343)

This patch pulls out the memory checks from the base reduction detection
algorithm. This is the first one in the reduction patch series, to
reduce the difference in future patches.

GitOrigin-RevId: 7ddd3d776402f9cc7d5f13b5940ba38a285223c2
1 file changed