[flang-commits] [flang] 2665fbe - [flang] NINT(-.4999) is 0, not overflow
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jun 16 10:48:03 PDT 2022
Author: Peter Klausler
Date: 2022-06-16T10:47:52-07:00
New Revision: 2665fbe71e1d1897da3abad6c6cc3c32020e0bff
URL: https://github.com/llvm/llvm-project/commit/2665fbe71e1d1897da3abad6c6cc3c32020e0bff
DIFF: https://github.com/llvm/llvm-project/commit/2665fbe71e1d1897da3abad6c6cc3c32020e0bff.diff
LOG: [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
Added:
Modified:
flang/include/flang/Evaluate/real.h
Removed:
################################################################################
diff --git a/flang/include/flang/Evaluate/real.h b/flang/include/flang/Evaluate/real.h
index 2b5562a7eee9..7665c64ef1eb 100644
--- a/flang/include/flang/Evaluate/real.h
+++ b/flang/include/flang/Evaluate/real.h
@@ -280,8 +280,10 @@ class Real : public common::RealDetails<PREC> {
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 =
More information about the flang-commits
mailing list