[flang-commits] [PATCH] D155976: [flang][runtime] Fix NORM2([negative, ...])
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Jul 21 08:47:57 PDT 2023
klausler created this revision.
klausler added a reviewer: vzakhari.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.
https://reviews.llvm.org/D155976
Files:
flang/runtime/extrema.cpp
Index: flang/runtime/extrema.cpp
===================================================================
--- flang/runtime/extrema.cpp
+++ flang/runtime/extrema.cpp
@@ -800,7 +800,7 @@
bool Accumulate(Type x) {
auto absX{std::abs(static_cast<AccumType>(x))};
if (!max_) {
- max_ = x;
+ max_ = absX;
} else if (absX > max_) {
auto t{max_ / absX}; // < 1.0
auto tsq{t * t};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155976.542953.patch
Type: text/x-patch
Size: 410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230721/8dbee4eb/attachment-0001.bin>
More information about the flang-commits
mailing list