[flang-commits] [PATCH] D154374: [flang] Fix overflow detection for folding SUM/PRODUCT

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jul 3 13:03:58 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58d7484360e7: [flang] Fix overflow detection for folding SUM/PRODUCT (authored by klausler).

Changed prior to commit:
  https://reviews.llvm.org/D154374?vs=536835&id=536876#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154374/new/

https://reviews.llvm.org/D154374

Files:
  flang/lib/Evaluate/fold-reduction.h


Index: flang/lib/Evaluate/fold-reduction.h
===================================================================
--- flang/lib/Evaluate/fold-reduction.h
+++ flang/lib/Evaluate/fold-reduction.h
@@ -260,12 +260,12 @@
         element = prod.value;
       }
     }};
+    auto result{Expr<T>{DoReduction<T>(*array, dim, identity, accumulator)}};
     if (overflow) {
       context.messages().Say(
           "PRODUCT() of %s data overflowed"_warn_en_US, T::AsFortran());
-    } else {
-      return Expr<T>{DoReduction<T>(*array, dim, identity, accumulator)};
     }
+    return result;
   }
   return Expr<T>{std::move(ref)};
 }
@@ -301,12 +301,12 @@
         element = sum.value;
       }
     }};
+    auto result{Expr<T>{DoReduction<T>(*array, dim, identity, accumulator)}};
     if (overflow) {
       context.messages().Say(
           "SUM() of %s data overflowed"_warn_en_US, T::AsFortran());
-    } else {
-      return Expr<T>{DoReduction<T>(*array, dim, identity, accumulator)};
     }
+    return result;
   }
   return Expr<T>{std::move(ref)};
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154374.536876.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230703/6adf18f7/attachment-0001.bin>


More information about the flang-commits mailing list