aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-range.h
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2022-08-30 12:13:31 +0200
committerAldy Hernandez <aldyh@redhat.com>2022-08-30 14:26:38 +0200
commit7e3f18439904bf26eabc658caf843b297a052eb4 (patch)
treeb94a6c3f5c713df4290cd61e6636af5b89a678f0 /gcc/value-range.h
parent865d7352b6e73c1f2135561b0a18398b7e7df152 (diff)
downloadgcc-7e3f18439904bf26eabc658caf843b297a052eb4.zip
gcc-7e3f18439904bf26eabc658caf843b297a052eb4.tar.gz
gcc-7e3f18439904bf26eabc658caf843b297a052eb4.tar.bz2
Force a [NAN, NAN] range when the definite NAN property is set.
Setting the definite NAN property should also force a [NAN, NAN] range, otherwise we'd have two ways of representing a NAN: with the endpoints or with the property. In the ranger world we avoid at all costs having more than one representation for a range. In doing this, I removed the FRANGE_PROP_ACCESSOR macro, since it looks like setting a property may have repercurssions in the range itself, so it's best for the client to definte its own setter. gcc/ChangeLog: * value-range-storage.cc (frange_storage_slot::get_frange): Use frange_nan. * value-range.cc (frange::set_nan): New. (frange_nan): Move to header file. (range_tests_nan): Adjust frange_nan callers to pass type. New test. * value-range.h (FRANGE_PROP_ACCESSOR): Remove. (frange_nan): New.
Diffstat (limited to 'gcc/value-range.h')
-rw-r--r--gcc/value-range.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 43b231b..07379d5 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -323,16 +323,6 @@ private:
} u;
};
-// Accessors for getting/setting all FP properties at once.
-
-#define FRANGE_PROP_ACCESSOR(NAME) \
- fp_prop get_##NAME () const { return m_props.get_##NAME (); } \
- void set_##NAME (fp_prop::kind f) \
- { \
- m_props.set_##NAME (f); \
- normalize_kind (); \
- }
-
// A floating point range.
class frange : public vrange
@@ -371,8 +361,9 @@ public:
const REAL_VALUE_TYPE &lower_bound () const;
const REAL_VALUE_TYPE &upper_bound () const;
- // Each fp_prop can be accessed with get_PROP() and set_PROP().
- FRANGE_PROP_ACCESSOR(nan)
+ // Accessors for FP properties.
+ fp_prop get_nan () const { return m_props.get_nan (); }
+ void set_nan (fp_prop::kind f);
private:
void verify_range ();
bool normalize_kind ();
@@ -1186,4 +1177,15 @@ real_min_representable (REAL_VALUE_TYPE *r, tree type)
*r = real_value_negate (r);
}
+// Build a NAN of type TYPE.
+
+inline frange
+frange_nan (tree type)
+{
+ REAL_VALUE_TYPE r;
+
+ gcc_assert (real_nan (&r, "", 1, TYPE_MODE (type)));
+ return frange (type, r, r);
+}
+
#endif // GCC_VALUE_RANGE_H