[flang] Cope with overflow in real MOD/MODULO
authorPeter Klausler <pklausler@nvidia.com>
Fri, 1 Jul 2022 18:43:30 +0000 (11:43 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Thu, 7 Jul 2022 00:31:11 +0000 (17:31 -0700)
commit715283aa1792ed1dc0cf513128f272fd92dd06da
tree53f33d317d6372a5ff0ecb1b2709ca983676ab47
parent0508fd5935d91a684d178613b9bbf75760c41686
[flang] Cope with overflow in real MOD/MODULO

In folding and in the runtime library for real MOD/MODULO(A,P),
detect overflow from the division A/P and return a properly signed
zero result.  (When A/P overflows and both A and P are finite numbers
with nonzero P, the quotient would be a large integer when rounded to
the precision of the floating-point representation.)

Differential Revision: https://reviews.llvm.org/D129020
flang/lib/Evaluate/real.cpp
flang/runtime/numeric.cpp
flang/test/Evaluate/fold-mod.f90