[flang-commits] [PATCH] D132155: [flang] Fold SPACING() correctly when result is subnormal
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Aug 18 11:16:33 PDT 2022
klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
The intrinsic function SPACING() was being folded to the smallest
normal number (TINY(x)) rather than to a smaller subnormal result
when that result really was subnormal.
https://reviews.llvm.org/D132155
Files:
flang/lib/Evaluate/real.cpp
flang/test/Evaluate/fold-spacing.f90
Index: flang/test/Evaluate/fold-spacing.f90
===================================================================
--- flang/test/Evaluate/fold-spacing.f90
+++ flang/test/Evaluate/fold-spacing.f90
@@ -5,6 +5,8 @@
logical, parameter :: test_2 = spacing(-3.0) == scale(1.0, -22)
logical, parameter :: test_3 = spacing(3.0d0) == scale(1.0, -51)
logical, parameter :: test_4 = spacing(0.) == tiny(0.)
+ logical, parameter :: test_5 = spacing(tiny(0.)) == 1.e-45
+ logical, parameter :: test_6 = spacing(8388608.) == 1.
logical, parameter :: test_11 = rrspacing(3.0) == scale(0.75, 24)
logical, parameter :: test_12 = rrspacing(-3.0) == scale(0.75, 24)
logical, parameter :: test_13 = rrspacing(3.0d0) == scale(0.75, 53)
Index: flang/lib/Evaluate/real.cpp
===================================================================
--- flang/lib/Evaluate/real.cpp
+++ flang/lib/Evaluate/real.cpp
@@ -749,8 +749,7 @@
return TINY();
} else {
Real result;
- result.Normalize(
- false, Exponent() - binaryPrecision + 1, Fraction::MASKL(1));
+ result.Normalize(false, Exponent(), Fraction::MASKR(1));
return result;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132155.453719.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220818/ac652963/attachment.bin>
More information about the flang-commits
mailing list