[flang-commits] [PATCH] D127785: [flang] NINT(-.4999) is 0, not overflow

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Jun 14 13:51:39 PDT 2022


klausler created this revision.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

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


https://reviews.llvm.org/D127785

Files:
  flang/include/flang/Evaluate/real.h


Index: flang/include/flang/Evaluate/real.h
===================================================================
--- flang/include/flang/Evaluate/real.h
+++ flang/include/flang/Evaluate/real.h
@@ -280,8 +280,10 @@
     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 =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127785.436917.patch
Type: text/x-patch
Size: 626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220614/97b8b217/attachment.bin>


More information about the flang-commits mailing list