Check rvc_normal in real_isdenormal.
Checks
Commit Message
[Jakub, thanks for pointing this out. OK?]
[-Inf, -Inf] is being flushed to [-Inf, -0.0] because real_isdenormal
is being overly pessimistic. It is missing a check for rvc_normal.
This doesn't cause problems in real.cc because all uses of
real_isdenormal are already on the rvc_normal path. The uses in
value-range.cc however, are not.
This patch adds a check for rvc_normal.
gcc/ChangeLog:
* real.h (real_isdenormal): Check rvc_normal.
* value-range.cc (range_tests_floats): New test.
---
gcc/real.h | 2 +-
gcc/value-range.cc | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
Comments
On Fri, Oct 14, 2022 at 04:30:47PM +0200, Aldy Hernandez wrote:
> [Jakub, thanks for pointing this out. OK?]
>
> [-Inf, -Inf] is being flushed to [-Inf, -0.0] because real_isdenormal
> is being overly pessimistic. It is missing a check for rvc_normal.
> This doesn't cause problems in real.cc because all uses of
> real_isdenormal are already on the rvc_normal path. The uses in
> value-range.cc however, are not.
>
> This patch adds a check for rvc_normal.
>
> gcc/ChangeLog:
>
> * real.h (real_isdenormal): Check rvc_normal.
> * value-range.cc (range_tests_floats): New test.
LGTM.
Jakub
@@ -290,7 +290,7 @@ extern bool real_issignaling_nan (const REAL_VALUE_TYPE *);
inline bool
real_isdenormal (const REAL_VALUE_TYPE *r)
{
- return (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+ return r->cl == rvc_normal && (r->sig[SIGSZ-1] & SIG_MSB) == 0;
}
/* Determine whether a floating-point value X is finite. */
@@ -4014,6 +4014,11 @@ range_tests_floats ()
r1.clear_nan ();
r0.intersect (r1);
ASSERT_TRUE (r0.undefined_p ());
+
+ // Make sure [-Inf, -Inf] doesn't get normalized.
+ r0 = frange_float ("-Inf", "-Inf");
+ ASSERT_TRUE (real_isinf (&r0.lower_bound (), true));
+ ASSERT_TRUE (real_isinf (&r0.upper_bound (), true));
}
void