Line data Source code
1 : /* Support routines for value ranges.
2 : Copyright (C) 2019-2026 Free Software Foundation, Inc.
3 : Contributed by Aldy Hernandez <aldyh@redhat.com> and
4 : Andrew Macleod <amacleod@redhat.com>.
5 :
6 : This file is part of GCC.
7 :
8 : GCC is free software; you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation; either version 3, or (at your option)
11 : any later version.
12 :
13 : GCC is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with GCC; see the file COPYING3. If not see
20 : <http://www.gnu.org/licenses/>. */
21 :
22 : #ifndef GCC_VALUE_RANGE_H
23 : #define GCC_VALUE_RANGE_H
24 :
25 : class irange;
26 :
27 : // Types of value ranges.
28 : enum value_range_kind
29 : {
30 : /* Empty range. */
31 : VR_UNDEFINED,
32 : /* Range spans the entire domain. */
33 : VR_VARYING,
34 : /* Range is [MIN, MAX]. */
35 : VR_RANGE,
36 : /* Range is ~[MIN, MAX]. */
37 : VR_ANTI_RANGE,
38 : /* Range is a NAN. */
39 : VR_NAN,
40 : /* Range is a nice guy. */
41 : VR_LAST
42 : };
43 :
44 : // Discriminator between different vrange types.
45 :
46 : enum value_range_discriminator
47 : {
48 : // Range holds an integer or pointer.
49 : VR_IRANGE,
50 : // Pointer range.
51 : VR_PRANGE,
52 : // Floating point range.
53 : VR_FRANGE,
54 : // Range holds an unsupported type.
55 : VR_UNKNOWN
56 : };
57 :
58 : // Abstract class for representing subsets of values for various
59 : // supported types, such as the possible values of a variable.
60 : //
61 : // There are subclasses for each of integer, floating point, and pointer
62 : // types, each with their own strategies for efficiently representing
63 : // subsets of values.
64 : //
65 : // For efficiency, we can't precisely represent any arbitrary subset
66 : // of values of a type (which could require 2^N bits for a type of size N)
67 : // Hence operations on the subclasses may introduce imprecision
68 : // due to over-approximating the possible subsets.
69 : //
70 : // To query what types ranger and the entire ecosystem can support,
71 : // use value_range::supports_type_p(tree type). This is a static
72 : // method available independently of any vrange object.
73 : //
74 : // To query what a given vrange variant can support, use:
75 : // irange::supports_p ()
76 : // frange::supports_p ()
77 : // etc
78 : //
79 : // To query what a range object can support, use:
80 : // void foo (vrange &v, irange &i, frange &f)
81 : // {
82 : // if (v.supports_type_p (type)) ...
83 : // if (i.supports_type_p (type)) ...
84 : // if (f.supports_type_p (type)) ...
85 : // }
86 :
87 : class vrange
88 : {
89 : template <typename T> friend bool is_a (vrange &);
90 : friend class value_range;
91 : friend void streamer_write_vrange (struct output_block *, const vrange &);
92 : friend class range_op_handler;
93 : public:
94 : virtual void accept (const class vrange_visitor &v) const = 0;
95 : virtual void set (tree, tree, value_range_kind = VR_RANGE) = 0;
96 : virtual tree type () const = 0;
97 : virtual bool supports_type_p (const_tree type) const = 0;
98 : virtual void set_varying (tree type) = 0;
99 : virtual void set_undefined () = 0;
100 : virtual bool union_ (const vrange &) = 0;
101 : virtual bool intersect (const vrange &) = 0;
102 : virtual bool singleton_p (tree *result = NULL) const = 0;
103 : virtual bool contains_p (tree cst) const = 0;
104 : virtual bool zero_p () const = 0;
105 : // True if val == 0 may hold for some value in the range; for a float
106 : // range that means +0.0 or -0.0.
107 : virtual bool contains_zero_p () const = 0;
108 : virtual void set_nonzero (tree type) = 0;
109 : virtual void set_zero (tree type) = 0;
110 : virtual void set_nonnegative (tree type) = 0;
111 : virtual bool fits_p (const vrange &r) const = 0;
112 5957217843 : virtual ~vrange () { }
113 : virtual tree lbound () const = 0;
114 : virtual tree ubound () const = 0;
115 : virtual void update_bitmask (const class irange_bitmask &);
116 : virtual irange_bitmask get_bitmask () const;
117 : wide_int get_nonzero_bits () const;
118 : void set_nonzero_bits (const wide_int &bits);
119 :
120 : bool varying_p () const;
121 : bool undefined_p () const;
122 : vrange& operator= (const vrange &);
123 : bool operator== (const vrange &) const;
124 164544496 : bool operator!= (const vrange &r) const { return !(*this == r); }
125 : void dump (FILE *) const;
126 0 : virtual void verify_range () const { }
127 : protected:
128 7470008572 : vrange (enum value_range_discriminator d) : m_discriminator (d) { }
129 : enum value_range_kind m_kind : 8;
130 : const enum value_range_discriminator m_discriminator : 4;
131 : };
132 :
133 : namespace inchash
134 : {
135 : extern void add_vrange (const vrange &, hash &, unsigned flags = 0);
136 : }
137 :
138 : // A pair of values representing the known bits of a value. Zero bits
139 : // in MASK cover constant values. Set bits in MASK cover unknown
140 : // values. VALUE are the known bits for the bits where MASK is zero,
141 : // and must be zero for the unknown bits where MASK is set (needed as an
142 : // optimization of union and intersect)
143 : // For example:
144 : // VALUE: [..., 0, 1, 0]
145 : // MASK: [..., 1, 0, 0]
146 : // ^ ^ ^
147 : // | | known bit: {0}
148 : // | known bit: {1}
149 : // unknown bit: {0, 1}
150 :
151 : class irange_bitmask
152 : {
153 : public:
154 7244352736 : irange_bitmask () { /* uninitialized */ }
155 84114564 : irange_bitmask (unsigned prec) { set_unknown (prec); }
156 : irange_bitmask (const wide_int &value, const wide_int &mask);
157 : irange_bitmask (tree type, const wide_int &min, const wide_int &max);
158 :
159 1656701850 : wide_int value () const { return m_value; }
160 2033492404 : wide_int mask () const { return m_mask; }
161 : void set_unknown (unsigned prec);
162 : bool unknown_p () const;
163 : unsigned get_precision () const;
164 : void union_ (const irange_bitmask &src);
165 : bool intersect (const irange_bitmask &src);
166 : bool operator== (const irange_bitmask &src) const;
167 4195418 : bool operator!= (const irange_bitmask &src) const { return !(*this == src); }
168 : void verify_mask () const;
169 : void dump (FILE *) const;
170 : bool range_from_mask (irange &r, tree type) const;
171 :
172 : bool member_p (const wide_int &val) const;
173 :
174 : // Convenience functions for nonzero bitmask compatibility.
175 : wide_int get_nonzero_bits () const;
176 : void set_nonzero_bits (const wide_int &bits);
177 : private:
178 : wide_int m_value;
179 : wide_int m_mask;
180 : };
181 :
182 : inline void
183 4225405331 : irange_bitmask::set_unknown (unsigned prec)
184 : {
185 4225405331 : m_value = wi::zero (prec);
186 4225405331 : m_mask = wi::minus_one (prec);
187 4225405331 : if (flag_checking)
188 4225392323 : verify_mask ();
189 4225405331 : }
190 :
191 : // Return TRUE if THIS does not have any meaningful information.
192 :
193 : inline bool
194 5774798228 : irange_bitmask::unknown_p () const
195 : {
196 4200364595 : return m_mask == -1;
197 : }
198 :
199 : inline
200 1260788045 : irange_bitmask::irange_bitmask (const wide_int &value, const wide_int &mask)
201 : {
202 1260788045 : m_value = value;
203 1260788045 : m_mask = mask;
204 1260788045 : if (flag_checking)
205 1260784348 : verify_mask ();
206 1260788045 : }
207 :
208 : inline unsigned
209 : irange_bitmask::get_precision () const
210 : {
211 : return m_mask.get_precision ();
212 : }
213 :
214 : // The following two functions are meant for backwards compatibility
215 : // with the nonzero bitmask. A cleared bit means the value must be 0.
216 : // A set bit means we have no information for the bit.
217 :
218 : // Return the nonzero bits.
219 : inline wide_int
220 46377708 : irange_bitmask::get_nonzero_bits () const
221 : {
222 46377708 : return m_value | m_mask;
223 : }
224 :
225 : // Set the bitmask to the nonzero bits in BITS.
226 : inline void
227 : irange_bitmask::set_nonzero_bits (const wide_int &bits)
228 : {
229 : m_value = wi::zero (bits.get_precision ());
230 : m_mask = bits;
231 : if (flag_checking)
232 : verify_mask ();
233 : }
234 :
235 : // Return TRUE if val could be a valid value with this bitmask.
236 :
237 : inline bool
238 299461281 : irange_bitmask::member_p (const wide_int &val) const
239 : {
240 299461281 : if (unknown_p ())
241 : return true;
242 34747697 : wide_int res = m_mask & val;
243 34747697 : if (m_value != 0)
244 1341652 : res |= ~m_mask & m_value;
245 34747697 : return res == val;
246 34747697 : }
247 :
248 : inline bool
249 1316592728 : irange_bitmask::operator== (const irange_bitmask &src) const
250 : {
251 1316592728 : bool unknown1 = unknown_p ();
252 1316592728 : bool unknown2 = src.unknown_p ();
253 1316592728 : if (unknown1 || unknown2)
254 1011636506 : return unknown1 == unknown2;
255 304956222 : return m_value == src.m_value && m_mask == src.m_mask;
256 : }
257 :
258 : inline void
259 19800889 : irange_bitmask::union_ (const irange_bitmask &src)
260 : {
261 19801475 : m_mask = (m_mask | src.m_mask) | (m_value ^ src.m_value);
262 19800889 : m_value = m_value & src.m_value;
263 19800889 : if (flag_checking)
264 19800889 : verify_mask ();
265 19800889 : }
266 :
267 : // Return FALSE if the bitmask intersection is undefined.
268 :
269 : inline bool
270 882536972 : irange_bitmask::intersect (const irange_bitmask &src)
271 : {
272 : // If we have two known bits that are incompatible, the resulting
273 : // bit and therefore entire range is undefined. Return FALSE.
274 1765214078 : if (wi::bit_and (~(m_mask | src.m_mask),
275 2647610916 : m_value ^ src.m_value) != 0)
276 : return false;
277 : else
278 : {
279 882483412 : m_mask = m_mask & src.m_mask;
280 882483412 : m_value = m_value | src.m_value;
281 : }
282 882483412 : if (flag_checking)
283 882480750 : verify_mask ();
284 : return true;
285 : }
286 :
287 : // A subset of possible values for an integer type, leaving
288 : // allocation of storage to subclasses.
289 :
290 11860554688 : class irange : public vrange
291 : {
292 : friend class irange_storage;
293 : friend class vrange_printer;
294 : public:
295 : // In-place setters.
296 : void set (tree type, const wide_int &, const wide_int &,
297 : value_range_kind = VR_RANGE);
298 : virtual void set_nonzero (tree type) override;
299 : virtual void set_zero (tree type) override;
300 : virtual void set_nonnegative (tree type) override;
301 : virtual void set_varying (tree type) override;
302 : virtual void set_undefined () override;
303 :
304 : // Range types.
305 : static bool supports_p (const_tree type);
306 : virtual bool supports_type_p (const_tree type) const override;
307 : virtual tree type () const override;
308 :
309 : // Iteration over sub-ranges.
310 : unsigned num_pairs () const;
311 : wide_int lower_bound (unsigned = 0) const;
312 : wide_int upper_bound (unsigned) const;
313 : wide_int upper_bound () const;
314 : virtual tree lbound () const override;
315 : virtual tree ubound () const override;
316 :
317 : // Predicates.
318 : virtual bool zero_p () const override;
319 : virtual bool contains_zero_p () const override;
320 : virtual bool singleton_p (tree *result = NULL) const override;
321 : bool singleton_p (wide_int &) const;
322 : bool contains_p (const wide_int &) const;
323 : bool nonnegative_p () const;
324 : bool nonpositive_p () const;
325 :
326 : // In-place operators.
327 : virtual bool union_ (const vrange &) override;
328 : virtual bool intersect (const vrange &) override;
329 : bool invert ();
330 :
331 : // Operator overloads.
332 : irange& operator= (const irange &);
333 : bool operator== (const irange &) const;
334 : bool operator!= (const irange &r) const { return !(*this == r); }
335 :
336 : // Misc methods.
337 : virtual bool fits_p (const vrange &r) const override;
338 : virtual void accept (const vrange_visitor &v) const override;
339 :
340 : virtual void update_bitmask (const class irange_bitmask &) override;
341 : virtual irange_bitmask get_bitmask () const override;
342 :
343 : virtual void verify_range () const override;
344 : protected:
345 : void maybe_resize (int needed);
346 : virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
347 : virtual bool contains_p (tree cst) const override;
348 : irange (wide_int *, unsigned nranges, bool resizable);
349 :
350 : // In-place operators.
351 : bool irange_contains_p (const irange &) const;
352 : bool irange_single_pair_union (const irange &r);
353 :
354 : void normalize_kind ();
355 :
356 :
357 : // Hard limit on max ranges allowed.
358 : static const int HARD_MAX_RANGES = 255;
359 : private:
360 : bool varying_compatible_p () const;
361 : bool intersect_bitmask (const irange &r);
362 : bool union_bitmask (const irange &r);
363 : bool set_range_from_bitmask ();
364 : bool snap_subranges ();
365 : bool snap (const wide_int &, const wide_int &, wide_int &, wide_int &,
366 : bool &);
367 :
368 : bool intersect (const wide_int& lb, const wide_int& ub);
369 : bool union_append (const irange &r);
370 : unsigned char m_num_ranges;
371 : bool m_resizable;
372 : unsigned char m_max_ranges;
373 : tree m_type;
374 : irange_bitmask m_bitmask;
375 : protected:
376 : wide_int *m_base;
377 : };
378 :
379 : // Here we describe an irange with N pairs of ranges. The storage for
380 : // the pairs is embedded in the class as an array.
381 : //
382 : // If RESIZABLE is true, the storage will be resized on the heap when
383 : // the number of ranges needed goes past N up to a max of
384 : // HARD_MAX_RANGES. This new storage is freed upon destruction.
385 :
386 : template<unsigned N, bool RESIZABLE = false>
387 : class int_range final : public irange
388 : {
389 : public:
390 : int_range ();
391 : int_range (tree type, const wide_int &, const wide_int &,
392 : value_range_kind = VR_RANGE);
393 : int_range (tree type);
394 : int_range (const int_range &);
395 : int_range (const irange &);
396 : ~int_range () final override;
397 : int_range& operator= (const int_range &);
398 : protected:
399 : int_range (tree, tree, value_range_kind = VR_RANGE);
400 : private:
401 : wide_int m_ranges[N*2];
402 : };
403 :
404 : class prange final : public vrange
405 : {
406 : friend class prange_storage;
407 : friend class vrange_printer;
408 : public:
409 : prange ();
410 : prange (const prange &);
411 : prange (tree type);
412 : prange (tree type, const wide_int &, const wide_int &,
413 : value_range_kind = VR_RANGE);
414 : static bool supports_p (const_tree type);
415 : virtual bool supports_type_p (const_tree type) const final override;
416 : virtual void accept (const vrange_visitor &v) const final override;
417 : virtual void set_undefined () final override;
418 : virtual void set_varying (tree type) final override;
419 : virtual void set_nonzero (tree type) final override;
420 : virtual void set_zero (tree type) final override;
421 : virtual void set_nonnegative (tree type) final override;
422 : virtual bool contains_p (tree cst) const final override;
423 : virtual bool fits_p (const vrange &v) const final override;
424 : virtual bool singleton_p (tree *result = NULL) const final override;
425 : virtual bool zero_p () const final override;
426 : virtual bool contains_zero_p () const final override;
427 : virtual void set (tree, tree, value_range_kind = VR_RANGE) final override;
428 : virtual tree type () const final override;
429 : virtual bool union_ (const vrange &v) final override;
430 : virtual bool intersect (const vrange &v) final override;
431 : virtual tree lbound () const final override;
432 : virtual tree ubound () const final override;
433 :
434 : prange& operator= (const prange &);
435 : bool operator== (const prange &) const;
436 : void set (tree type, const wide_int &, const wide_int &,
437 : value_range_kind = VR_RANGE);
438 : bool invert ();
439 : bool contains_p (const wide_int &) const;
440 : wide_int lower_bound () const;
441 : wide_int upper_bound () const;
442 : virtual void verify_range () const final override;
443 : irange_bitmask get_bitmask () const final override;
444 : void update_bitmask (const irange_bitmask &) final override;
445 :
446 : // prange interface to address information.
447 : // It can be known to be a particular address, or exclude that address.
448 : // This represents both sides of a conditional. ie:
449 : // if (p == &foo)
450 : // // p known to be foo.
451 : // else
452 : // // p excludes foo.
453 :
454 : // The address is is_gimple_min_invariant, which is relative to the
455 : // current function -- it is NOT is_gimple_ip_invariant, and may name a
456 : // local. Any consumer crossing a function boundary must re-check.
457 :
458 : // Set this address to the same as R, if any.
459 : void set_addr (const prange &r);
460 : void set_addr (tree addr, bool known_p = true);
461 :
462 : void set_addr_unknown ();
463 : bool addr_unknown_p () const;
464 :
465 : // If addr is local to a function, clear it.
466 : bool clear_function_local_addr ();
467 :
468 : // Return expression or NULL_TREE for known or excluded.
469 : tree addr_known () const;
470 : tree addr_excluded () const;
471 :
472 : // Return true if THIS and R are known to be the same address.
473 : bool addr_same_known_p (const prange &r) const;
474 : // Return true if THIS and R both exclude the same address.
475 : bool addr_same_excluded_p (const prange &r) const;
476 :
477 : // If either known or excluded, invert and return TRUE.
478 : bool addr_invert ();
479 : // Return true if THIS and R refer to the same address, and one is inverted
480 : // from the other, Ie, both known and excluded
481 : bool addr_inverted_p (const prange &r) const;
482 :
483 : protected:
484 : bool varying_compatible_p () const;
485 :
486 : tree m_type;
487 : wide_int m_min;
488 : wide_int m_max;
489 : irange_bitmask m_bitmask;
490 :
491 : // A prange can be known to be a particular address, or known to exclude
492 : // one.
493 : tree m_addr; // Address referred to.
494 : bool m_known_p; // Is it known (TRUE), or excluded (FALSE).
495 : // Return TRUE if P has the same address fields as THIS.
496 : bool addr_equal_p (const class prange &p) const;
497 : };
498 :
499 : // Unsupported temporaries may be created by ranger before it's known
500 : // they're unsupported, or by vr_values::get_value_range.
501 :
502 0 : class unsupported_range : public vrange
503 : {
504 : public:
505 75221454 : unsupported_range ()
506 75221454 : : vrange (VR_UNKNOWN)
507 : {
508 75221454 : set_undefined ();
509 : }
510 655935 : unsupported_range (const unsupported_range &src)
511 655935 : : vrange (VR_UNKNOWN)
512 : {
513 655935 : unsupported_range::operator= (src);
514 : }
515 : void set (tree min, tree, value_range_kind = VR_RANGE) final override;
516 : tree type () const final override;
517 : bool supports_type_p (const_tree) const final override;
518 : void set_varying (tree) final override;
519 : void set_undefined () final override;
520 : void accept (const vrange_visitor &v) const final override;
521 : bool union_ (const vrange &r) final override;
522 : bool intersect (const vrange &r) final override;
523 : bool singleton_p (tree * = NULL) const final override;
524 : bool contains_p (tree) const final override;
525 : bool zero_p () const final override;
526 : bool contains_zero_p () const final override;
527 : void set_nonzero (tree type) final override;
528 : void set_zero (tree type) final override;
529 : void set_nonnegative (tree type) final override;
530 : bool fits_p (const vrange &) const final override;
531 : unsupported_range& operator= (const unsupported_range &r);
532 : tree lbound () const final override;
533 : tree ubound () const final override;
534 : };
535 :
536 : // The possible NAN state of a floating point value as an opaque object.
537 : // This represents one of the four subsets of { -NaN, +NaN },
538 : // i.e. one of {}, { -NaN }, { +NaN}, or { -NaN, +NaN }.
539 :
540 : class nan_state
541 : {
542 : public:
543 : nan_state (bool);
544 : nan_state (bool pos_nan, bool neg_nan);
545 : bool neg_p () const;
546 : bool pos_p () const;
547 : private:
548 : bool m_pos_nan;
549 : bool m_neg_nan;
550 : };
551 :
552 : // Set NAN state to +-NAN if NAN_P is true. Otherwise set NAN state
553 : // to false.
554 :
555 : inline
556 33948382 : nan_state::nan_state (bool nan_p)
557 : {
558 33948382 : m_pos_nan = nan_p;
559 29903871 : m_neg_nan = nan_p;
560 : }
561 :
562 : // Constructor initializing the object to +NAN if POS_NAN is set, -NAN
563 : // if NEG_NAN is set, or +-NAN if both are set. Otherwise POS_NAN and
564 : // NEG_NAN are clear, and the object cannot be a NAN.
565 :
566 : inline
567 3268669 : nan_state::nan_state (bool pos_nan, bool neg_nan)
568 : {
569 3268669 : m_pos_nan = pos_nan;
570 3258814 : m_neg_nan = neg_nan;
571 : }
572 :
573 : // Return if +NAN is possible.
574 :
575 : inline bool
576 36747689 : nan_state::pos_p () const
577 : {
578 36645621 : return m_pos_nan;
579 : }
580 :
581 : // Return if -NAN is possible.
582 :
583 : inline bool
584 36487085 : nan_state::neg_p () const
585 : {
586 36436007 : return m_neg_nan;
587 : }
588 :
589 : // A sub-range in an frange.
590 :
591 : struct frange_pair
592 : {
593 : REAL_VALUE_TYPE min;
594 : REAL_VALUE_TYPE max;
595 : };
596 :
597 : // A subset of possible values for a floating point type.
598 : //
599 : // The representation is a handful of disjoint intervals, unioned with a
600 : // subset of { -NaN, +NaN }.
601 :
602 26305211 : class frange final : public vrange
603 : {
604 : friend class frange_storage;
605 : friend class vrange_printer;
606 : public:
607 : frange ();
608 : frange (const frange &);
609 : frange (tree, tree, value_range_kind = VR_RANGE);
610 : frange (tree type);
611 : frange (tree type, const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max,
612 : value_range_kind = VR_RANGE);
613 527212541 : static bool supports_p (const_tree type)
614 : {
615 : // ?? Decimal floats can have multiple representations for the
616 : // same number. Supporting them may be as simple as just
617 : // disabling them in singleton_p. No clue.
618 527212541 : return SCALAR_FLOAT_TYPE_P (type) && !DECIMAL_FLOAT_TYPE_P (type);
619 : }
620 : virtual tree type () const override;
621 : void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
622 : value_range_kind = VR_RANGE);
623 : void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
624 : const nan_state &, value_range_kind = VR_RANGE);
625 : void set_nan (tree type);
626 : void set_nan (tree type, bool sign);
627 : void set_nan (tree type, const nan_state &);
628 : virtual void set_varying (tree type) override;
629 : virtual void set_undefined () override;
630 : virtual bool union_ (const vrange &) override;
631 : virtual bool intersect (const vrange &) override;
632 : bool contains_p (const REAL_VALUE_TYPE &) const;
633 : virtual bool singleton_p (tree *result = NULL) const override;
634 : bool singleton_p (REAL_VALUE_TYPE &r) const;
635 : virtual bool supports_type_p (const_tree type) const override;
636 : virtual void accept (const vrange_visitor &v) const override;
637 : virtual bool zero_p () const override;
638 : virtual bool contains_zero_p () const override;
639 : virtual void set_nonzero (tree type) override;
640 : virtual void set_zero (tree type) override;
641 : virtual void set_nonnegative (tree type) override;
642 : virtual bool fits_p (const vrange &) const override;
643 : frange& operator= (const frange &);
644 : bool operator== (const frange &) const;
645 9538705 : bool operator!= (const frange &r) const { return !(*this == r); }
646 : const REAL_VALUE_TYPE &lower_bound () const;
647 : const REAL_VALUE_TYPE &upper_bound () const;
648 : virtual tree lbound () const override;
649 : virtual tree ubound () const override;
650 : nan_state get_nan_state () const;
651 : void update_nan ();
652 : void update_nan (bool sign);
653 : void update_nan (tree) = delete; // Disallow silent conversion to bool.
654 : void update_nan (const nan_state &);
655 : void clear_nan ();
656 : void flush_denormals_to_zero ();
657 :
658 : // fpclassify like API
659 : bool known_isfinite () const;
660 : bool known_isnan () const;
661 : bool known_isinf () const;
662 : bool maybe_isnan () const;
663 : bool maybe_isnan (bool sign) const;
664 : bool maybe_isinf () const;
665 : bool signbit_p (bool &signbit) const;
666 : bool nan_signbit_p (bool &signbit) const;
667 : bool known_isnormal () const;
668 : bool known_isdenormal_or_zero () const;
669 : virtual void verify_range () const override;
670 :
671 : static const unsigned int MAX_PAIRS = 2;
672 32327672 : unsigned num_pairs () const { return m_num_ranges; }
673 : const REAL_VALUE_TYPE &lower_bound (unsigned pair) const;
674 : const REAL_VALUE_TYPE &upper_bound (unsigned pair) const;
675 :
676 : void widen (tree);
677 : protected:
678 : virtual bool contains_p (tree cst) const override;
679 : virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
680 :
681 : private:
682 : bool internal_singleton_p (REAL_VALUE_TYPE * = NULL) const;
683 : bool normalize_kind ();
684 : bool union_nans (const frange &);
685 : bool intersect_nans (const frange &);
686 : void set_pairs (frange_pair *, unsigned);
687 : void canonicalize_zeros (frange_pair &);
688 : void set_excluding (tree type, const REAL_VALUE_TYPE &,
689 : const REAL_VALUE_TYPE &, const nan_state &);
690 :
691 : tree m_type;
692 : frange_pair m_pairs[MAX_PAIRS];
693 : unsigned char m_num_ranges;
694 : bool m_pos_nan;
695 : bool m_neg_nan;
696 : };
697 :
698 : inline const REAL_VALUE_TYPE &
699 5635561 : frange::lower_bound () const
700 : {
701 5635561 : gcc_checking_assert (!undefined_p () && !known_isnan ());
702 5635561 : return m_pairs[0].min;
703 : }
704 :
705 : inline const REAL_VALUE_TYPE &
706 3866426 : frange::upper_bound () const
707 : {
708 3866426 : gcc_checking_assert (!undefined_p () && !known_isnan ());
709 3866426 : return m_pairs[m_num_ranges - 1].max;
710 : }
711 :
712 : inline const REAL_VALUE_TYPE &
713 12396420 : frange::lower_bound (unsigned pair) const
714 : {
715 12396420 : gcc_checking_assert (!undefined_p () && !known_isnan ());
716 12396420 : gcc_checking_assert (pair < m_num_ranges);
717 12396420 : return m_pairs[pair].min;
718 : }
719 :
720 : inline const REAL_VALUE_TYPE &
721 12396420 : frange::upper_bound (unsigned pair) const
722 : {
723 12396420 : gcc_checking_assert (!undefined_p () && !known_isnan ());
724 12396420 : gcc_checking_assert (pair < m_num_ranges);
725 12396420 : return m_pairs[pair].max;
726 : }
727 :
728 : // Return the NAN state.
729 :
730 : inline nan_state
731 1115529 : frange::get_nan_state () const
732 : {
733 1115529 : return nan_state (m_pos_nan, m_neg_nan);
734 : }
735 :
736 : // is_a<> and as_a<> implementation for vrange.
737 :
738 : // Anything we haven't specialized is a hard fail.
739 : template <typename T>
740 : inline bool
741 : is_a (vrange &)
742 : {
743 : gcc_unreachable ();
744 : return false;
745 : }
746 :
747 : template <typename T>
748 : inline bool
749 5161131054 : is_a (const vrange &v)
750 : {
751 : // Reuse is_a <vrange> to implement the const version.
752 5370543881 : const T &derived = static_cast<const T &> (v);
753 2247102296 : return is_a <T> (const_cast<T &> (derived));
754 : }
755 :
756 : template <typename T>
757 : inline T &
758 2965663386 : as_a (vrange &v)
759 : {
760 0 : gcc_checking_assert (is_a <T> (v));
761 2965663386 : return static_cast <T &> (v);
762 : }
763 :
764 : template <typename T>
765 : inline const T &
766 4410874585 : as_a (const vrange &v)
767 : {
768 0 : gcc_checking_assert (is_a <T> (v));
769 4410874585 : return static_cast <const T &> (v);
770 : }
771 :
772 : // Specializations for the different range types.
773 :
774 : template <>
775 : inline bool
776 6624729918 : is_a <irange> (vrange &v)
777 : {
778 6497620839 : return v.m_discriminator == VR_IRANGE;
779 : }
780 :
781 : template <>
782 : inline bool
783 1692408702 : is_a <prange> (vrange &v)
784 : {
785 1546751214 : return v.m_discriminator == VR_PRANGE;
786 : }
787 :
788 : template <>
789 : inline bool
790 216366983 : is_a <frange> (vrange &v)
791 : {
792 216366983 : return v.m_discriminator == VR_FRANGE;
793 : }
794 :
795 : template <>
796 : inline bool
797 655935 : is_a <unsupported_range> (vrange &v)
798 : {
799 655935 : return v.m_discriminator == VR_UNKNOWN;
800 : }
801 :
802 : // For resizable ranges, resize the range up to HARD_MAX_RANGES if the
803 : // NEEDED pairs is greater than the current capacity of the range.
804 :
805 : inline void
806 1514487950 : irange::maybe_resize (int needed)
807 : {
808 1514487950 : if (!m_resizable || m_max_ranges == HARD_MAX_RANGES)
809 : return;
810 :
811 1006907086 : if (needed > m_max_ranges)
812 : {
813 70474274 : m_max_ranges = HARD_MAX_RANGES;
814 36012354014 : wide_int *newmem = new wide_int[m_max_ranges * 2];
815 70474274 : unsigned n = num_pairs () * 2;
816 402078490 : for (unsigned i = 0; i < n; ++i)
817 331604216 : newmem[i] = m_base[i];
818 70474274 : m_base = newmem;
819 : }
820 : }
821 :
822 : template<unsigned N, bool RESIZABLE>
823 : inline
824 5930277344 : int_range<N, RESIZABLE>::~int_range ()
825 : {
826 4507911813 : if (RESIZABLE && m_base != m_ranges)
827 35890756454 : delete[] m_base;
828 37072990946 : }
829 :
830 : // This is an "infinite" precision irange for use in temporary
831 : // calculations. It starts with a sensible default covering 99% of
832 : // uses, and goes up to HARD_MAX_RANGES when needed. Any allocated
833 : // storage is freed upon destruction.
834 : typedef int_range<3, /*RESIZABLE=*/true> int_range_max;
835 :
836 44861 : class vrange_visitor
837 : {
838 : public:
839 0 : virtual void visit (const irange &) const { }
840 0 : virtual void visit (const prange &) const { }
841 0 : virtual void visit (const frange &) const { }
842 0 : virtual void visit (const unsupported_range &) const { }
843 : };
844 :
845 : // This is an "infinite" precision range object for use in temporary
846 : // calculations for any of the handled types. The object can be
847 : // transparently used as a vrange.
848 : //
849 : // Using any of the various constructors initializes the object
850 : // appropriately, but the default constructor is uninitialized and
851 : // must be initialized either with set_range_class() or by assigning into it.
852 : //
853 : // Assigning between incompatible types is allowed. For example if a
854 : // temporary holds an irange, you can assign an frange into it, and
855 : // all the right things will happen. However, before passing this
856 : // object to a function accepting a vrange, the correct type must be
857 : // set. If it isn't, you can do so with set_range_class().
858 :
859 : class value_range
860 : {
861 : public:
862 : value_range ();
863 : value_range (const vrange &r);
864 : value_range (tree type);
865 : value_range (tree, tree, value_range_kind kind = VR_RANGE);
866 : value_range (const value_range &);
867 : ~value_range ();
868 : void set_range_class (tree type);
869 : vrange& operator= (const vrange &);
870 : value_range& operator= (const value_range &);
871 : bool operator== (const value_range &r) const;
872 : bool operator!= (const value_range &r) const;
873 : operator vrange &();
874 : operator const vrange &() const;
875 : void dump (FILE *) const;
876 : void print (pretty_printer *) const;
877 : static bool supports_type_p (const_tree type);
878 :
879 3583579 : tree type () { return m_vrange->type (); }
880 161747820 : bool varying_p () const { return m_vrange->varying_p (); }
881 177336445 : bool undefined_p () const { return m_vrange->undefined_p (); }
882 331325143 : void set_varying (tree type) { init (type); m_vrange->set_varying (type); }
883 23753162 : void set_undefined () { m_vrange->set_undefined (); }
884 18854963 : bool union_ (const vrange &r) { return m_vrange->union_ (r); }
885 106207129 : bool intersect (const vrange &r) { return m_vrange->intersect (r); }
886 1434100 : bool contains_p (tree cst) const { return m_vrange->contains_p (cst); }
887 427383089 : bool singleton_p (tree *result = NULL) const
888 427383089 : { return m_vrange->singleton_p (result); }
889 1085 : void set_zero (tree type) { init (type); return m_vrange->set_zero (type); }
890 0 : void set_nonzero (tree type)
891 0 : { init (type); return m_vrange->set_nonzero (type); }
892 260828 : bool contains_zero_p () const { return m_vrange->contains_zero_p (); }
893 4529 : bool zero_p () const { return m_vrange->zero_p (); }
894 11315169 : tree lbound () const { return m_vrange->lbound (); }
895 360194 : tree ubound () const { return m_vrange->ubound (); }
896 504661 : irange_bitmask get_bitmask () const { return m_vrange->get_bitmask (); }
897 1488832 : void update_bitmask (const class irange_bitmask &bm)
898 1488832 : { return m_vrange->update_bitmask (bm); }
899 3067 : void accept (const vrange_visitor &v) const { m_vrange->accept (v); }
900 : void verify_range () const { m_vrange->verify_range (); }
901 : private:
902 : void init (tree type);
903 : void init (const vrange &);
904 :
905 : vrange *m_vrange;
906 : union buffer_type {
907 : int_range_max ints;
908 : frange floats;
909 : unsupported_range unsupported;
910 : prange pointers;
911 7244521302 : buffer_type () { }
912 7355608555 : ~buffer_type () { }
913 : } m_buffer;
914 : };
915 :
916 : // The default constructor is uninitialized and must be initialized
917 : // with either set_range_class() or with an assignment into it.
918 :
919 : inline
920 3999774496 : value_range::value_range ()
921 3999774496 : : m_buffer ()
922 : {
923 3999774496 : m_vrange = NULL;
924 : }
925 :
926 : // Copy constructor.
927 :
928 : inline
929 12726428 : value_range::value_range (const value_range &r)
930 : {
931 12726428 : init (*r.m_vrange);
932 : }
933 :
934 : // Copy constructor from a vrange.
935 :
936 : inline
937 79704420 : value_range::value_range (const vrange &r)
938 : {
939 79704420 : init (r);
940 : }
941 :
942 : // Construct an UNDEFINED range that can hold ranges of TYPE. If TYPE
943 : // is not supported, default to unsupported_range.
944 :
945 : inline
946 3152242060 : value_range::value_range (tree type)
947 : {
948 2972545997 : init (type);
949 : }
950 :
951 : // Construct a range that can hold a range of [MIN, MAX], where MIN
952 : // and MAX are trees.
953 :
954 : inline
955 73898 : value_range::value_range (tree min, tree max, value_range_kind kind)
956 : {
957 73898 : init (TREE_TYPE (min));
958 73898 : m_vrange->set (min, max, kind);
959 73898 : }
960 :
961 : inline
962 7355608555 : value_range::~value_range ()
963 : {
964 7355608555 : if (m_vrange)
965 3602340231 : m_vrange->~vrange ();
966 7355608555 : }
967 :
968 : // Initialize object to an UNDEFINED range that can hold ranges of
969 : // TYPE. Clean-up memory if there was a previous object.
970 : // Note that this does *not* set the type of the underlying vrange.
971 :
972 : inline void
973 125958067 : value_range::set_range_class (tree type)
974 : {
975 125958067 : if (m_vrange)
976 9481444 : m_vrange->~vrange ();
977 125958067 : init (type);
978 125958067 : }
979 :
980 : // Initialize object to an UNDEFINED range that can hold ranges of
981 : // TYPE.
982 : // Note that this does *not* set the type of the underlying vrange.
983 :
984 : inline void
985 3609600253 : value_range::init (tree type)
986 : {
987 3609600253 : gcc_checking_assert (TYPE_P (type));
988 :
989 3609600253 : if (irange::supports_p (type))
990 2621375870 : m_vrange = new (&m_buffer.ints) int_range_max ();
991 988224383 : else if (prange::supports_p (type))
992 806473741 : m_vrange = new (&m_buffer.pointers) prange ();
993 181750642 : else if (frange::supports_p (type))
994 106529188 : m_vrange = new (&m_buffer.floats) frange ();
995 : else
996 75221454 : m_vrange = new (&m_buffer.unsupported) unsupported_range ();
997 3609600253 : }
998 :
999 : // Initialize object with a copy of R.
1000 :
1001 : inline void
1002 126664724 : value_range::init (const vrange &r)
1003 : {
1004 126664724 : if (is_a <irange> (r))
1005 74528494 : m_vrange = new (&m_buffer.ints) int_range_max (as_a <irange> (r));
1006 52136230 : else if (is_a <prange> (r))
1007 102532702 : m_vrange = new (&m_buffer.pointers) prange (as_a <prange> (r));
1008 869879 : else if (is_a <frange> (r))
1009 427888 : m_vrange = new (&m_buffer.floats) frange (as_a <frange> (r));
1010 : else
1011 1311870 : m_vrange = new (&m_buffer.unsupported)
1012 655935 : unsupported_range (as_a <unsupported_range> (r));
1013 126664724 : }
1014 :
1015 : // Assignment operator. Copying incompatible types is allowed. That
1016 : // is, assigning an frange to an object holding an irange does the
1017 : // right thing.
1018 :
1019 : inline vrange &
1020 34233876 : value_range::operator= (const vrange &r)
1021 : {
1022 34233876 : if (m_vrange)
1023 10225773 : m_vrange->~vrange ();
1024 34233876 : init (r);
1025 34233876 : return *m_vrange;
1026 : }
1027 :
1028 : inline value_range &
1029 10297346 : value_range::operator= (const value_range &r)
1030 : {
1031 : // No need to call the m_vrange destructor here, as we will do so in
1032 : // the assignment below.
1033 1577393 : *this = *r.m_vrange;
1034 10297346 : return *this;
1035 : }
1036 :
1037 : inline bool
1038 23979833 : value_range::operator== (const value_range &r) const
1039 : {
1040 23979833 : return *m_vrange == *r.m_vrange;
1041 : }
1042 :
1043 : inline bool
1044 13922049 : value_range::operator!= (const value_range &r) const
1045 : {
1046 13922049 : return *m_vrange != *r.m_vrange;
1047 : }
1048 :
1049 : inline
1050 4936312681 : value_range::operator vrange &()
1051 : {
1052 4610413694 : return *m_vrange;
1053 : }
1054 :
1055 : inline
1056 43848553 : value_range::operator const vrange &() const
1057 : {
1058 43848553 : return *m_vrange;
1059 : }
1060 :
1061 : // Return TRUE if TYPE is supported by the vrange infrastructure.
1062 :
1063 : inline bool
1064 6904791003 : value_range::supports_type_p (const_tree type)
1065 : {
1066 6904791003 : return irange::supports_p (type)
1067 1633563260 : || prange::supports_p (type)
1068 248426541 : || frange::supports_p (type);
1069 : }
1070 :
1071 : extern value_range_kind get_legacy_range (const vrange &, tree &min, tree &max);
1072 : extern void dump_value_range (FILE *, const vrange *);
1073 : extern bool vrp_operand_equal_p (const_tree, const_tree);
1074 : inline REAL_VALUE_TYPE frange_val_min (const_tree type);
1075 : inline REAL_VALUE_TYPE frange_val_max (const_tree type);
1076 :
1077 : // Number of sub-ranges in a range.
1078 :
1079 : inline unsigned
1080 38447048198 : irange::num_pairs () const
1081 : {
1082 6214971647 : return m_num_ranges;
1083 : }
1084 :
1085 : inline tree
1086 13236200036 : irange::type () const
1087 : {
1088 13236200036 : gcc_checking_assert (m_num_ranges > 0);
1089 13236200036 : return m_type;
1090 : }
1091 :
1092 : inline bool
1093 5594873435 : irange::varying_compatible_p () const
1094 : {
1095 5594873435 : if (m_num_ranges != 1)
1096 : return false;
1097 :
1098 4142378777 : const wide_int &l = m_base[0];
1099 4142378777 : const wide_int &u = m_base[1];
1100 4142378777 : tree t = m_type;
1101 :
1102 4142378777 : if (m_kind == VR_VARYING)
1103 : return true;
1104 :
1105 3878618710 : unsigned prec = TYPE_PRECISION (t);
1106 3878618710 : signop sign = TYPE_SIGN (t);
1107 3878618710 : if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t))
1108 7757237420 : return (l == wi::min_value (prec, sign)
1109 5065368282 : && u == wi::max_value (prec, sign)
1110 3885934848 : && m_bitmask.unknown_p ());
1111 : return true;
1112 : }
1113 :
1114 : inline bool
1115 1111229759 : vrange::varying_p () const
1116 : {
1117 1106141744 : return m_kind == VR_VARYING;
1118 : }
1119 :
1120 : inline bool
1121 24525777152 : vrange::undefined_p () const
1122 : {
1123 13544932802 : return m_kind == VR_UNDEFINED;
1124 : }
1125 :
1126 : inline bool
1127 281441323 : irange::zero_p () const
1128 : {
1129 268449895 : return (m_kind == VR_RANGE && m_num_ranges == 1
1130 520376466 : && lower_bound (0) == 0
1131 549891237 : && upper_bound (0) == 0);
1132 : }
1133 :
1134 : inline bool
1135 45231550 : irange::contains_zero_p () const
1136 : {
1137 45231550 : if (undefined_p ())
1138 : return false;
1139 :
1140 45231550 : wide_int zero = wi::zero (TYPE_PRECISION (type ()));
1141 45231550 : return contains_p (zero);
1142 45231550 : }
1143 :
1144 : inline bool
1145 17210280559 : irange::supports_p (const_tree type)
1146 : {
1147 16216439490 : return INTEGRAL_TYPE_P (type);
1148 : }
1149 :
1150 : inline bool
1151 89180992 : irange::contains_p (tree cst) const
1152 : {
1153 89180992 : return contains_p (wi::to_wide (cst));
1154 : }
1155 :
1156 : inline bool
1157 37143560 : range_includes_zero_p (const vrange &vr)
1158 : {
1159 37143560 : if (vr.undefined_p ())
1160 : return false;
1161 :
1162 37143560 : if (vr.varying_p ())
1163 : return true;
1164 :
1165 27918272 : return vr.contains_p (build_zero_cst (vr.type ()));
1166 : }
1167 :
1168 : // Constructors for irange
1169 :
1170 : inline
1171 6013802283 : irange::irange (wide_int *base, unsigned nranges, bool resizable)
1172 : : vrange (VR_IRANGE),
1173 6013802283 : m_resizable (resizable),
1174 6013802283 : m_max_ranges (nranges)
1175 : {
1176 6013802283 : m_base = base;
1177 6013802283 : set_undefined ();
1178 : }
1179 :
1180 : // Constructors for int_range<>.
1181 :
1182 : template<unsigned N, bool RESIZABLE>
1183 : inline
1184 4563119580 : int_range<N, RESIZABLE>::int_range ()
1185 31234723314 : : irange (m_ranges, N, RESIZABLE)
1186 : {
1187 4563119580 : }
1188 :
1189 : template<unsigned N, bool RESIZABLE>
1190 573891 : int_range<N, RESIZABLE>::int_range (const int_range &other)
1191 4017229 : : irange (m_ranges, N, RESIZABLE)
1192 : {
1193 573891 : irange::operator= (other);
1194 573891 : }
1195 :
1196 : template<unsigned N, bool RESIZABLE>
1197 : int_range<N, RESIZABLE>::int_range (tree min, tree max, value_range_kind kind)
1198 : : irange (m_ranges, N, RESIZABLE)
1199 : {
1200 : irange::set (min, max, kind);
1201 : }
1202 :
1203 : template<unsigned N, bool RESIZABLE>
1204 167733897 : int_range<N, RESIZABLE>::int_range (tree type)
1205 666961039 : : irange (m_ranges, N, RESIZABLE)
1206 : {
1207 167733897 : set_varying (type);
1208 167733897 : }
1209 :
1210 : template<unsigned N, bool RESIZABLE>
1211 866575148 : int_range<N, RESIZABLE>::int_range (tree type, const wide_int &wmin, const wide_int &wmax,
1212 : value_range_kind kind)
1213 3005760950 : : irange (m_ranges, N, RESIZABLE)
1214 : {
1215 866575148 : set (type, wmin, wmax, kind);
1216 866575148 : }
1217 :
1218 : template<unsigned N, bool RESIZABLE>
1219 415799767 : int_range<N, RESIZABLE>::int_range (const irange &other)
1220 2675966673 : : irange (m_ranges, N, RESIZABLE)
1221 : {
1222 415799767 : irange::operator= (other);
1223 415799767 : }
1224 :
1225 : template<unsigned N, bool RESIZABLE>
1226 : int_range<N, RESIZABLE>&
1227 69602701 : int_range<N, RESIZABLE>::operator= (const int_range &src)
1228 : {
1229 69595647 : irange::operator= (src);
1230 0 : return *this;
1231 : }
1232 :
1233 : inline void
1234 6432433181 : irange::set_undefined ()
1235 : {
1236 6432433181 : m_kind = VR_UNDEFINED;
1237 6334671319 : m_num_ranges = 0;
1238 413573056 : }
1239 :
1240 : inline void
1241 1346086250 : irange::set_varying (tree type)
1242 : {
1243 1346086250 : m_kind = VR_VARYING;
1244 1346086250 : m_num_ranges = 1;
1245 1346086250 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1246 :
1247 1346086250 : if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
1248 : {
1249 1346086250 : m_type = type;
1250 : // Strict enum's require varying to be not TYPE_MIN/MAX, but rather
1251 : // min_value and max_value.
1252 1346086250 : m_base[0] = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1253 1346104157 : m_base[1] = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1254 : }
1255 : else
1256 0 : m_type = error_mark_node;
1257 1346086250 : }
1258 :
1259 : // Return the lower bound of a sub-range. PAIR is the sub-range in
1260 : // question.
1261 :
1262 : inline wide_int
1263 13325402483 : irange::lower_bound (unsigned pair) const
1264 : {
1265 13325402483 : gcc_checking_assert (m_num_ranges > 0);
1266 13325402483 : gcc_checking_assert (pair + 1 <= num_pairs ());
1267 13325402483 : return m_base[pair * 2];
1268 : }
1269 :
1270 : // Return the upper bound of a sub-range. PAIR is the sub-range in
1271 : // question.
1272 :
1273 : inline wide_int
1274 15286445128 : irange::upper_bound (unsigned pair) const
1275 : {
1276 15286445128 : gcc_checking_assert (m_num_ranges > 0);
1277 15286445128 : gcc_checking_assert (pair + 1 <= num_pairs ());
1278 15286445128 : return m_base[pair * 2 + 1];
1279 : }
1280 :
1281 : // Return the highest bound of a range.
1282 :
1283 : inline wide_int
1284 3967537675 : irange::upper_bound () const
1285 : {
1286 3967537675 : unsigned pairs = num_pairs ();
1287 3967537675 : gcc_checking_assert (pairs > 0);
1288 3967537675 : return upper_bound (pairs - 1);
1289 : }
1290 :
1291 : // Set value range VR to a nonzero range of type TYPE.
1292 :
1293 : inline void
1294 4102798 : irange::set_nonzero (tree type)
1295 : {
1296 4102798 : unsigned prec = TYPE_PRECISION (type);
1297 :
1298 4102798 : if (TYPE_UNSIGNED (type))
1299 : {
1300 3495611 : m_type = type;
1301 3495611 : m_kind = VR_RANGE;
1302 3495611 : m_base[0] = wi::one (prec);
1303 3495611 : m_base[1] = wi::minus_one (prec);
1304 3495611 : m_bitmask.set_unknown (prec);
1305 3495611 : m_num_ranges = 1;
1306 :
1307 3495611 : if (flag_checking)
1308 3495611 : verify_range ();
1309 : }
1310 : else
1311 : {
1312 607187 : wide_int zero = wi::zero (prec);
1313 607187 : set (type, zero, zero, VR_ANTI_RANGE);
1314 607187 : }
1315 4102798 : }
1316 :
1317 : // Set value range VR to a ZERO range of type TYPE.
1318 :
1319 : inline void
1320 3858448 : irange::set_zero (tree type)
1321 : {
1322 3858448 : wide_int zero = wi::zero (TYPE_PRECISION (type));
1323 3858448 : set (type, zero, zero);
1324 3858448 : }
1325 :
1326 : // Normalize a range to VARYING or UNDEFINED if possible.
1327 :
1328 : inline void
1329 620757841 : irange::normalize_kind ()
1330 : {
1331 620757841 : if (m_num_ranges == 0)
1332 19869 : set_undefined ();
1333 620737972 : else if (varying_compatible_p ())
1334 : {
1335 28151606 : if (m_kind == VR_RANGE)
1336 7158988 : m_kind = VR_VARYING;
1337 20992618 : else if (m_kind == VR_ANTI_RANGE)
1338 0 : set_undefined ();
1339 : }
1340 620757841 : if (flag_checking)
1341 620756996 : verify_range ();
1342 620757841 : }
1343 :
1344 : inline wide_int
1345 103750715 : irange_val_min (const_tree type)
1346 : {
1347 103750715 : gcc_checking_assert (irange::supports_p (type));
1348 103750715 : return wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1349 : }
1350 :
1351 : inline wide_int
1352 105501620 : irange_val_max (const_tree type)
1353 : {
1354 105501620 : gcc_checking_assert (irange::supports_p (type));
1355 105501620 : return wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1356 : }
1357 :
1358 : inline
1359 868570674 : prange::prange ()
1360 868570674 : : vrange (VR_PRANGE)
1361 : {
1362 1737141348 : set_undefined ();
1363 868570674 : }
1364 :
1365 : inline
1366 145233069 : prange::prange (const prange &r)
1367 145233069 : : vrange (VR_PRANGE)
1368 : {
1369 145233069 : *this = r;
1370 : }
1371 :
1372 : inline
1373 216310474 : prange::prange (tree type)
1374 216310474 : : vrange (VR_PRANGE)
1375 : {
1376 216310474 : set_varying (type);
1377 : }
1378 :
1379 : inline
1380 3971429 : prange::prange (tree type, const wide_int &lb, const wide_int &ub,
1381 : value_range_kind kind)
1382 3971429 : : vrange (VR_PRANGE)
1383 : {
1384 3971429 : set (type, lb, ub, kind);
1385 : }
1386 :
1387 : inline bool
1388 4347140358 : prange::supports_p (const_tree type)
1389 : {
1390 4347140358 : return POINTER_TYPE_P (type);
1391 : }
1392 :
1393 : inline bool
1394 602932813 : prange::supports_type_p (const_tree type) const
1395 : {
1396 602932813 : return POINTER_TYPE_P (type);
1397 : }
1398 :
1399 : inline void
1400 1011925792 : prange::set_undefined ()
1401 : {
1402 1011925792 : m_kind = VR_UNDEFINED;
1403 1011925792 : set_addr_unknown ();
1404 142025917 : }
1405 :
1406 : inline void
1407 661358468 : prange::set_varying (tree type)
1408 : {
1409 661358468 : m_kind = VR_VARYING;
1410 661358468 : m_type = type;
1411 661358468 : m_min = wi::zero (TYPE_PRECISION (type));
1412 661358468 : m_max = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
1413 661358468 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1414 661358468 : set_addr_unknown ();
1415 :
1416 661358468 : if (flag_checking)
1417 661358285 : verify_range ();
1418 661358468 : }
1419 :
1420 : inline void
1421 397243422 : prange::set_nonzero (tree type)
1422 : {
1423 397243422 : m_kind = VR_RANGE;
1424 397243422 : m_type = type;
1425 397243422 : m_min = wi::one (TYPE_PRECISION (type));
1426 397243422 : m_max = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
1427 397243422 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1428 397243422 : set_addr_unknown ();
1429 :
1430 397243422 : if (flag_checking)
1431 397243041 : verify_range ();
1432 397243422 : }
1433 :
1434 : inline void
1435 763627 : prange::set_zero (tree type)
1436 : {
1437 763627 : m_kind = VR_RANGE;
1438 763627 : m_type = type;
1439 763627 : wide_int zero = wi::zero (TYPE_PRECISION (type));
1440 763627 : m_min = m_max = zero;
1441 763627 : m_bitmask = irange_bitmask (zero, zero);
1442 763627 : set_addr_unknown ();
1443 :
1444 763627 : if (flag_checking)
1445 763627 : verify_range ();
1446 763627 : }
1447 :
1448 : inline bool
1449 27863 : prange::contains_p (tree cst) const
1450 : {
1451 27863 : return contains_p (wi::to_wide (cst));
1452 : }
1453 :
1454 : inline bool
1455 288200337 : prange::zero_p () const
1456 : {
1457 288200337 : bool ret = m_kind == VR_RANGE && m_min == 0 && m_max == 0;
1458 288200337 : return ret;
1459 : }
1460 :
1461 : inline bool
1462 28789587 : prange::contains_zero_p () const
1463 : {
1464 28789587 : if (undefined_p ())
1465 : return false;
1466 :
1467 27885644 : wide_int zero = wi::zero (TYPE_PRECISION (type ()));
1468 27885644 : return contains_p (zero);
1469 27885644 : }
1470 :
1471 : inline tree
1472 2883733279 : prange::type () const
1473 : {
1474 2883733279 : gcc_checking_assert (!undefined_p ());
1475 2883733279 : return m_type;
1476 : }
1477 :
1478 : inline wide_int
1479 722180040 : prange::lower_bound () const
1480 : {
1481 722180040 : gcc_checking_assert (!undefined_p ());
1482 722180040 : return m_min;
1483 : }
1484 :
1485 : inline wide_int
1486 678812587 : prange::upper_bound () const
1487 : {
1488 678812587 : gcc_checking_assert (!undefined_p ());
1489 678812587 : return m_max;
1490 : }
1491 :
1492 : inline bool
1493 2420640586 : prange::varying_compatible_p () const
1494 : {
1495 2420640511 : return (!undefined_p () && m_min == 0 && m_max == -1
1496 3956835978 : && get_bitmask ().unknown_p () && addr_unknown_p ());
1497 : }
1498 :
1499 : inline irange_bitmask
1500 1035249393 : prange::get_bitmask () const
1501 : {
1502 1035249393 : return m_bitmask;
1503 : }
1504 :
1505 : inline bool
1506 0 : prange::fits_p (const vrange &) const
1507 : {
1508 0 : return true;
1509 : }
1510 :
1511 : // Copy the address information from R, if it has any.
1512 :
1513 : inline void
1514 230778347 : prange::set_addr (const prange &r)
1515 : {
1516 : // Do not set address info if this is zero or undefined.
1517 12258815 : if (!r.addr_unknown_p () && (undefined_p () || zero_p()))
1518 : return;
1519 :
1520 230778272 : m_addr = r.m_addr;
1521 230778272 : m_known_p = r.m_known_p;
1522 :
1523 230778272 : if (r.undefined_p ())
1524 : return;
1525 : // Check whether this is now VARYING or not.
1526 230711400 : if (varying_compatible_p ())
1527 24554451 : set_varying (type ());
1528 : else
1529 206156949 : m_kind = VR_RANGE;
1530 : }
1531 :
1532 : // prange_pt methods.
1533 : // ------------------------------------------------------------------
1534 :
1535 : inline void
1536 2116589121 : prange::set_addr_unknown ()
1537 : {
1538 2116589121 : m_addr = NULL_TREE;
1539 2116589121 : m_known_p = false;
1540 : // If this is a transition from a range, check for varying compatibility.
1541 2116589121 : if (m_kind == VR_RANGE && varying_compatible_p ())
1542 506 : m_kind = VR_VARYING;
1543 2116589121 : }
1544 :
1545 : inline bool
1546 2077647118 : prange::addr_unknown_p () const
1547 : {
1548 2004124052 : return (m_addr == NULL_TREE);
1549 : }
1550 :
1551 : inline bool
1552 90557613 : prange::addr_equal_p (const prange &p) const
1553 : {
1554 : // A prange object invokes vrp_operand_equal_p as we want ranges to compare
1555 : // equal to each other if they refer to the same object, even if the
1556 : // tree has become unshared.
1557 90557613 : return (m_known_p == p.m_known_p
1558 90557613 : && vrp_operand_equal_p (m_addr, p.m_addr));
1559 : }
1560 :
1561 : inline bool
1562 90697887 : prange::addr_inverted_p (const prange &r) const
1563 : {
1564 2134619 : return m_addr && vrp_operand_equal_p (m_addr, r.m_addr)
1565 91228358 : && m_known_p != r.m_known_p;
1566 : }
1567 :
1568 : inline bool
1569 2746506 : prange::addr_invert ()
1570 : {
1571 2746506 : if (m_addr)
1572 : {
1573 0 : m_known_p = !m_known_p;
1574 0 : return true;
1575 : }
1576 : return false;
1577 : }
1578 :
1579 : inline tree
1580 82868945 : prange::addr_known () const
1581 : {
1582 82868945 : if (m_addr && m_known_p)
1583 1304894 : return m_addr;
1584 : return NULL_TREE;
1585 : }
1586 :
1587 : inline tree
1588 4175570 : prange::addr_excluded () const
1589 : {
1590 4175570 : if (m_addr && !m_known_p)
1591 1005552 : return m_addr;
1592 : return NULL_TREE;
1593 : }
1594 :
1595 : inline bool
1596 17869305 : prange::addr_same_known_p (const prange &r) const
1597 : {
1598 401682 : if (m_addr && m_known_p && vrp_operand_equal_p (r.m_addr, m_addr)
1599 17887365 : && m_known_p == r.m_known_p)
1600 16646 : return true;
1601 : return false;
1602 : }
1603 :
1604 : inline bool
1605 : prange::addr_same_excluded_p (const prange &r) const
1606 : {
1607 : if (m_addr && !m_known_p && vrp_operand_equal_p (r.m_addr, m_addr)
1608 : && m_known_p == r.m_known_p)
1609 : return true;
1610 : return false;
1611 : }
1612 :
1613 :
1614 : // -----------------------------------------------------------------------
1615 :
1616 : inline
1617 116395519 : frange::frange ()
1618 116395519 : : vrange (VR_FRANGE)
1619 : {
1620 116395455 : set_undefined ();
1621 : }
1622 :
1623 : inline
1624 12144783 : frange::frange (const frange &src)
1625 12144783 : : vrange (VR_FRANGE)
1626 : {
1627 11727650 : *this = src;
1628 : }
1629 :
1630 : inline
1631 796699 : frange::frange (tree type)
1632 796699 : : vrange (VR_FRANGE)
1633 : {
1634 796699 : set_varying (type);
1635 : }
1636 :
1637 : // frange constructor from REAL_VALUE_TYPE endpoints.
1638 :
1639 : inline
1640 16906253 : frange::frange (tree type,
1641 : const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max,
1642 : value_range_kind kind)
1643 16906253 : : vrange (VR_FRANGE)
1644 : {
1645 16906253 : set (type, min, max, kind);
1646 : }
1647 :
1648 : // frange constructor from trees.
1649 :
1650 : inline
1651 : frange::frange (tree min, tree max, value_range_kind kind)
1652 : : vrange (VR_FRANGE)
1653 : {
1654 : set (min, max, kind);
1655 : }
1656 :
1657 : inline tree
1658 68284275 : frange::type () const
1659 : {
1660 68284275 : gcc_checking_assert (!undefined_p ());
1661 68284275 : return m_type;
1662 : }
1663 :
1664 : inline void
1665 71817504 : frange::set_varying (tree type)
1666 : {
1667 71817504 : m_kind = VR_VARYING;
1668 71817504 : m_type = type;
1669 71817504 : m_num_ranges = 1;
1670 71817504 : m_pairs[0].min = frange_val_min (type);
1671 71817504 : m_pairs[0].max = frange_val_max (type);
1672 71817504 : if (HONOR_NANS (m_type))
1673 : {
1674 : m_pos_nan = true;
1675 : m_neg_nan = true;
1676 : }
1677 : else
1678 : {
1679 4195530 : m_pos_nan = false;
1680 4195530 : m_neg_nan = false;
1681 : }
1682 71817504 : }
1683 :
1684 : inline void
1685 156226075 : frange::set_undefined ()
1686 : {
1687 156226075 : m_kind = VR_UNDEFINED;
1688 156226075 : m_type = NULL;
1689 156226075 : m_num_ranges = 1;
1690 156226075 : m_pos_nan = false;
1691 156226075 : m_neg_nan = false;
1692 : // Leave the rest undefined; as it speeds up initializing undefined ranges.
1693 156226075 : if (flag_checking)
1694 156226075 : verify_range ();
1695 156226075 : }
1696 :
1697 : // Set the NAN bits to NAN and adjust the range.
1698 :
1699 : inline void
1700 6017248 : frange::update_nan (const nan_state &nan)
1701 : {
1702 6017248 : gcc_checking_assert (!undefined_p ());
1703 6017248 : if (HONOR_NANS (m_type))
1704 : {
1705 6016452 : m_pos_nan = nan.pos_p ();
1706 6016452 : m_neg_nan = nan.neg_p ();
1707 6016452 : normalize_kind ();
1708 6016452 : if (flag_checking)
1709 6016452 : verify_range ();
1710 : }
1711 6017248 : }
1712 :
1713 : // Set the NAN bit to +-NAN.
1714 :
1715 : inline void
1716 3994376 : frange::update_nan ()
1717 : {
1718 3994376 : gcc_checking_assert (!undefined_p ());
1719 3994376 : nan_state nan (true);
1720 3994376 : update_nan (nan);
1721 3994376 : }
1722 :
1723 : // Like above, but set the sign of the NAN.
1724 :
1725 : inline void
1726 2022872 : frange::update_nan (bool sign)
1727 : {
1728 2022872 : gcc_checking_assert (!undefined_p ());
1729 2022872 : nan_state nan (/*pos=*/!sign, /*neg=*/sign);
1730 2022872 : update_nan (nan);
1731 2022872 : }
1732 :
1733 : inline bool
1734 0 : frange::contains_p (tree cst) const
1735 : {
1736 0 : return contains_p (*TREE_REAL_CST_PTR (cst));
1737 : }
1738 :
1739 : // Clear the NAN bit and adjust the range.
1740 :
1741 : inline void
1742 12736926 : frange::clear_nan ()
1743 : {
1744 12736926 : gcc_checking_assert (!undefined_p ());
1745 12736926 : m_pos_nan = false;
1746 12736926 : m_neg_nan = false;
1747 12736926 : normalize_kind ();
1748 12736926 : if (flag_checking)
1749 12736926 : verify_range ();
1750 12736926 : }
1751 :
1752 : // Set R to maximum representable value for TYPE.
1753 :
1754 : inline REAL_VALUE_TYPE
1755 14198445 : real_max_representable (const_tree type)
1756 : {
1757 14198445 : REAL_VALUE_TYPE r;
1758 14198445 : char buf[128];
1759 14198445 : get_max_float (REAL_MODE_FORMAT (TYPE_MODE (type)),
1760 : buf, sizeof (buf), false);
1761 14198445 : int res = real_from_string (&r, buf);
1762 14198445 : gcc_checking_assert (!res);
1763 14198445 : return r;
1764 : }
1765 :
1766 : // Return the minimum representable value for TYPE.
1767 :
1768 : inline REAL_VALUE_TYPE
1769 7521049 : real_min_representable (const_tree type)
1770 : {
1771 7521049 : REAL_VALUE_TYPE r = real_max_representable (type);
1772 7521049 : r = real_value_negate (&r);
1773 7521049 : return r;
1774 : }
1775 :
1776 : // Return the minimum value for TYPE.
1777 :
1778 : inline REAL_VALUE_TYPE
1779 165282584 : frange_val_min (const_tree type)
1780 : {
1781 165282584 : if (HONOR_INFINITIES (type))
1782 158034845 : return dconstninf;
1783 : else
1784 7247739 : return real_min_representable (type);
1785 : }
1786 :
1787 : // Return the maximum value for TYPE.
1788 :
1789 : inline REAL_VALUE_TYPE
1790 109666333 : frange_val_max (const_tree type)
1791 : {
1792 109666333 : if (HONOR_INFINITIES (type))
1793 103355625 : return dconstinf;
1794 : else
1795 6310708 : return real_max_representable (type);
1796 : }
1797 :
1798 : // Return TRUE if R is the minimum value for TYPE.
1799 :
1800 : inline bool
1801 90035828 : frange_val_is_min (const REAL_VALUE_TYPE &r, const_tree type)
1802 : {
1803 90035828 : REAL_VALUE_TYPE min = frange_val_min (type);
1804 90035828 : return real_identical (&min, &r);
1805 : }
1806 :
1807 : // Return TRUE if R is the max value for TYPE.
1808 :
1809 : inline bool
1810 34110687 : frange_val_is_max (const REAL_VALUE_TYPE &r, const_tree type)
1811 : {
1812 34110687 : REAL_VALUE_TYPE max = frange_val_max (type);
1813 34110687 : return real_identical (&max, &r);
1814 : }
1815 :
1816 : // Build a NAN with a state of NAN.
1817 :
1818 : inline void
1819 366214 : frange::set_nan (tree type, const nan_state &nan)
1820 : {
1821 366214 : gcc_checking_assert (nan.pos_p () || nan.neg_p ());
1822 366214 : if (HONOR_NANS (type))
1823 : {
1824 366213 : m_kind = VR_NAN;
1825 366213 : m_type = type;
1826 366213 : m_num_ranges = 1;
1827 366213 : m_neg_nan = nan.neg_p ();
1828 366213 : m_pos_nan = nan.pos_p ();
1829 366213 : if (flag_checking)
1830 366213 : verify_range ();
1831 : }
1832 : else
1833 1 : set_undefined ();
1834 366214 : }
1835 :
1836 : // Build a signless NAN of type TYPE.
1837 :
1838 : inline void
1839 157264 : frange::set_nan (tree type)
1840 : {
1841 157264 : nan_state nan (true);
1842 157252 : set_nan (type, nan);
1843 : }
1844 :
1845 : // Build a NAN of type TYPE with SIGN.
1846 :
1847 : inline void
1848 128651 : frange::set_nan (tree type, bool sign)
1849 : {
1850 128651 : nan_state nan (/*pos=*/!sign, /*neg=*/sign);
1851 128647 : set_nan (type, nan);
1852 : }
1853 :
1854 : // Return TRUE if range is known to be finite.
1855 :
1856 : inline bool
1857 0 : frange::known_isfinite () const
1858 : {
1859 0 : if (undefined_p () || varying_p () || m_kind == VR_ANTI_RANGE)
1860 : return false;
1861 0 : return (!maybe_isnan ()
1862 0 : && !real_isinf (&lower_bound ())
1863 0 : && !real_isinf (&upper_bound ()));
1864 : }
1865 :
1866 : // Return TRUE if range is known to be normal.
1867 :
1868 : inline bool
1869 0 : frange::known_isnormal () const
1870 : {
1871 0 : if (!known_isfinite ())
1872 : return false;
1873 :
1874 0 : machine_mode mode = TYPE_MODE (type ());
1875 0 : const REAL_VALUE_TYPE &min = lower_bound ();
1876 0 : const REAL_VALUE_TYPE &max = upper_bound ();
1877 0 : return (!real_isdenormal (&min, mode) && !real_isdenormal (&max, mode)
1878 0 : && !real_iszero (&min) && !real_iszero (&max)
1879 0 : && (!real_isneg (&min) || real_isneg (&max)));
1880 : }
1881 :
1882 : // Return TRUE if range is known to be denormal.
1883 :
1884 : inline bool
1885 0 : frange::known_isdenormal_or_zero () const
1886 : {
1887 0 : if (!known_isfinite ())
1888 : return false;
1889 :
1890 0 : machine_mode mode = TYPE_MODE (type ());
1891 0 : const REAL_VALUE_TYPE &min = lower_bound ();
1892 0 : const REAL_VALUE_TYPE &max = upper_bound ();
1893 0 : return ((real_isdenormal (&min, mode) || real_iszero (&min))
1894 0 : && (real_isdenormal (&max, mode) || real_iszero (&max)));
1895 : }
1896 :
1897 : // Return TRUE if range may be infinite.
1898 :
1899 : inline bool
1900 40761 : frange::maybe_isinf () const
1901 : {
1902 40761 : if (undefined_p () || m_kind == VR_ANTI_RANGE || m_kind == VR_NAN)
1903 : return false;
1904 40761 : if (varying_p ())
1905 : return true;
1906 38236 : return real_isinf (&lower_bound ()) || real_isinf (&upper_bound ());
1907 : }
1908 :
1909 : // Return TRUE if range is known to be the [-INF,-INF] or [+INF,+INF].
1910 :
1911 : inline bool
1912 5367396 : frange::known_isinf () const
1913 : {
1914 5367396 : return (m_kind == VR_RANGE
1915 1145810 : && m_num_ranges == 1
1916 7055054 : && !maybe_isnan ()
1917 843823 : && real_identical (&m_pairs[0].min, &m_pairs[0].max)
1918 5402642 : && real_isinf (&m_pairs[0].min));
1919 : }
1920 :
1921 : // Return TRUE if range is possibly a NAN.
1922 :
1923 : inline bool
1924 18010982 : frange::maybe_isnan () const
1925 : {
1926 16706269 : if (undefined_p ())
1927 : return false;
1928 18006495 : return m_pos_nan || m_neg_nan;
1929 : }
1930 :
1931 : // Return TRUE if range is possibly a NAN with SIGN.
1932 :
1933 : inline bool
1934 157869 : frange::maybe_isnan (bool sign) const
1935 : {
1936 157869 : if (undefined_p ())
1937 : return false;
1938 157869 : if (sign)
1939 157869 : return m_neg_nan;
1940 : return m_pos_nan;
1941 : }
1942 :
1943 : // Return TRUE if range is a +NAN or -NAN.
1944 :
1945 : inline bool
1946 26887408 : frange::known_isnan () const
1947 : {
1948 23412185 : return m_kind == VR_NAN;
1949 : }
1950 :
1951 : // If the signbit for the range is known, set it in SIGNBIT and return
1952 : // TRUE.
1953 :
1954 : inline bool
1955 1716468 : frange::signbit_p (bool &signbit) const
1956 : {
1957 1716468 : if (undefined_p ())
1958 : return false;
1959 :
1960 : // NAN with unknown sign.
1961 1716454 : if (m_pos_nan && m_neg_nan)
1962 : return false;
1963 : // No NAN.
1964 119468 : if (!m_pos_nan && !m_neg_nan)
1965 : {
1966 97752 : if (lower_bound ().sign == upper_bound ().sign)
1967 : {
1968 20145 : signbit = lower_bound ().sign;
1969 20145 : return true;
1970 : }
1971 : return false;
1972 : }
1973 : // NAN with known sign.
1974 21716 : bool nan_sign = m_neg_nan;
1975 21716 : if (known_isnan ()
1976 21716 : || (nan_sign == lower_bound ().sign
1977 20343 : && nan_sign == upper_bound ().sign))
1978 : {
1979 20516 : signbit = nan_sign;
1980 20516 : return true;
1981 : }
1982 : return false;
1983 : }
1984 :
1985 : // If range has a NAN with a known sign, set it in SIGNBIT and return
1986 : // TRUE.
1987 :
1988 : inline bool
1989 49789 : frange::nan_signbit_p (bool &signbit) const
1990 : {
1991 49789 : if (undefined_p ())
1992 : return false;
1993 :
1994 49789 : if (m_pos_nan == m_neg_nan)
1995 : return false;
1996 :
1997 2611 : signbit = m_neg_nan;
1998 2611 : return true;
1999 : }
2000 :
2001 : void frange_nextafter (enum machine_mode, REAL_VALUE_TYPE &,
2002 : const REAL_VALUE_TYPE &);
2003 : void frange_arithmetic (enum tree_code, tree, REAL_VALUE_TYPE &,
2004 : const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
2005 : const REAL_VALUE_TYPE &);
2006 :
2007 : // Return true if TYPE1 and TYPE2 are compatible range types.
2008 :
2009 : inline bool
2010 1755269060 : range_compatible_p (tree type1, tree type2)
2011 : {
2012 : // types_compatible_p requires conversion in both directions to be useless.
2013 : // GIMPLE only requires a cast one way in order to be compatible.
2014 : // Ranges really only need the sign and precision to be the same.
2015 1755269060 : return (TYPE_PRECISION (type1) == TYPE_PRECISION (type2)
2016 1755269060 : && TYPE_SIGN (type1) == TYPE_SIGN (type2));
2017 : }
2018 : #endif // GCC_VALUE_RANGE_H
|