[flang] Fix overflow detection for folding SUM/PRODUCT
authorPeter Klausler <pklausler@nvidia.com>
Wed, 28 Jun 2023 23:38:08 +0000 (16:38 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Mon, 3 Jul 2023 19:49:46 +0000 (12:49 -0700)
commit58d7484360e7987fec6f893da4b3e36da04bb643
tree7c3b47c840aad2557985d372ae845c6daa34e810
parentb288e668626bed43662669acb578fe05b14a355a
[flang] Fix overflow detection for folding SUM/PRODUCT

The overflow detection code in the templates that fold SUM and PRODUCT
was checking for overflow before performing the reduction, not after.
Fix and add tests.

Differential Revision: https://reviews.llvm.org/D154374
flang/lib/Evaluate/fold-reduction.h