diff options
author | Peter Klausler <pklausler@nvidia.com> | 2023-07-20 13:50:10 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2023-07-21 14:57:31 -0700 |
commit | b7585c75eeaf58f7602c1310f14e8e63b5501845 (patch) | |
tree | 28091283e369dfdd5521258763209e9086b392a5 /flang | |
parent | 863e8123df5e7dfb58af93e65e4da3ced96d358f (diff) | |
download | llvm-b7585c75eeaf58f7602c1310f14e8e63b5501845.zip llvm-b7585c75eeaf58f7602c1310f14e8e63b5501845.tar.gz llvm-b7585c75eeaf58f7602c1310f14e8e63b5501845.tar.bz2 |
[flang][runtime] Fix NORM2([negative, ...])
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.
Differential Revision: https://reviews.llvm.org/D155976
Diffstat (limited to 'flang')
-rw-r--r-- | flang/runtime/extrema.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/flang/runtime/extrema.cpp b/flang/runtime/extrema.cpp index c9dcc65b..d02cf46 100644 --- a/flang/runtime/extrema.cpp +++ b/flang/runtime/extrema.cpp @@ -800,7 +800,7 @@ public: 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}; |