[flang] NINT(-.4999) is 0, not overflow

Overflow detection in the folding of int/nint/ceiling is
incorrectly signalling overflow when a negative argument yields
a zero result.

Differential Revision: https://reviews.llvm.org/D127785
This commit is contained in:
Peter Klausler 2022-06-09 17:06:35 -07:00
parent 76782a65ee
commit 2665fbe71e
1 changed files with 4 additions and 2 deletions

View File

@ -280,8 +280,10 @@ public:
if (IsSignBitSet()) {
result.value = result.value.Negate().value;
}
if (IsSignBitSet() != result.value.IsNegative()) {
result.flags.set(RealFlag::Overflow);
if (!result.value.IsZero()) {
if (IsSignBitSet() != result.value.IsNegative()) {
result.flags.set(RealFlag::Overflow);
}
}
if (result.flags.test(RealFlag::Overflow)) {
result.value =