diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2023-05-24 19:55:09 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2023-05-25 07:24:52 +0200 |
commit | fae324f1901aff86be3183d87447eddaf33ec262 (patch) | |
tree | ec2f11cb375397b900e0516eb70b2c59cef61def /gcc/value-query.cc | |
parent | cd64ba5a7265b5733da6b54cf72b726113dd68d8 (diff) | |
download | gcc-fae324f1901aff86be3183d87447eddaf33ec262.zip gcc-fae324f1901aff86be3183d87447eddaf33ec262.tar.gz gcc-fae324f1901aff86be3183d87447eddaf33ec262.tar.bz2 |
Disallow setting of NANs in frange setter unless setting trees.
frange::set() is confusing in that we can set a NAN by specifying a
bound of +-NAN, even though we tecnically disallow NANs in the setter
because the kind can never be VR_NAN. This is a wart for
get_tree_range(), which builds a range out of a tree from the source,
to work correctly. It's ugly, and it showed its limitation while
implementing LTO streaming of ranges.
This patch disallows passing NAN bounds in frange::set() and fixes
get_tree_range.
gcc/ChangeLog:
* value-query.cc (range_query::get_tree_range): Set NAN directly
if necessary.
* value-range.cc (frange::set): Assert that bounds are not NAN.
Diffstat (limited to 'gcc/value-query.cc')
-rw-r--r-- | gcc/value-query.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 43297f1..a84f164 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -189,9 +189,16 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt) { frange &f = as_a <frange> (r); REAL_VALUE_TYPE *rv = TREE_REAL_CST_PTR (expr); - f.set (TREE_TYPE (expr), *rv, *rv); - if (!real_isnan (rv)) - f.clear_nan (); + if (real_isnan (rv)) + { + bool sign = real_isneg (rv); + f.set_nan (TREE_TYPE (expr), sign); + } + else + { + nan_state nan (false); + f.set (TREE_TYPE (expr), *rv, *rv, nan); + } return true; } |