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 : virtual bool nonzero_p () const = 0;
106 : virtual void set_nonzero (tree type) = 0;
107 : virtual void set_zero (tree type) = 0;
108 : virtual void set_nonnegative (tree type) = 0;
109 : virtual bool fits_p (const vrange &r) const = 0;
110 5147590829 : virtual ~vrange () { }
111 : virtual tree lbound () const = 0;
112 : virtual tree ubound () const = 0;
113 : virtual void update_bitmask (const class irange_bitmask &);
114 : virtual irange_bitmask get_bitmask () const;
115 : wide_int get_nonzero_bits () const;
116 : void set_nonzero_bits (const wide_int &bits);
117 :
118 : bool varying_p () const;
119 : bool undefined_p () const;
120 : vrange& operator= (const vrange &);
121 : bool operator== (const vrange &) const;
122 13912157 : bool operator!= (const vrange &r) const { return !(*this == r); }
123 : void dump (FILE *) const;
124 0 : virtual void verify_range () const { }
125 : protected:
126 6496035076 : vrange (enum value_range_discriminator d) : m_discriminator (d) { }
127 : enum value_range_kind m_kind : 8;
128 : const enum value_range_discriminator m_discriminator : 4;
129 : };
130 :
131 : namespace inchash
132 : {
133 : extern void add_vrange (const vrange &, hash &, unsigned flags = 0);
134 : }
135 :
136 : // A pair of values representing the known bits of a value. Zero bits
137 : // in MASK cover constant values. Set bits in MASK cover unknown
138 : // values. VALUE are the known bits for the bits where MASK is zero,
139 : // and must be zero for the unknown bits where MASK is set (needed as an
140 : // optimization of union and intersect)
141 : // For example:
142 : // VALUE: [..., 0, 1, 0]
143 : // MASK: [..., 1, 0, 0]
144 : // ^ ^ ^
145 : // | | known bit: {0}
146 : // | known bit: {1}
147 : // unknown bit: {0, 1}
148 :
149 : class irange_bitmask
150 : {
151 : public:
152 6254816464 : irange_bitmask () { /* uninitialized */ }
153 0 : irange_bitmask (unsigned prec) { set_unknown (prec); }
154 : irange_bitmask (const wide_int &value, const wide_int &mask);
155 : irange_bitmask (tree type, const wide_int &min, const wide_int &max);
156 :
157 1513324075 : wide_int value () const { return m_value; }
158 1826300154 : wide_int mask () const { return m_mask; }
159 : void set_unknown (unsigned prec);
160 : bool unknown_p () const;
161 : unsigned get_precision () const;
162 : void union_ (const irange_bitmask &src);
163 : bool intersect (const irange_bitmask &src);
164 : bool operator== (const irange_bitmask &src) const;
165 8144344 : bool operator!= (const irange_bitmask &src) const { return !(*this == src); }
166 : void verify_mask () const;
167 : void dump (FILE *) const;
168 : bool range_from_mask (irange &r, tree type) const;
169 :
170 : bool member_p (const wide_int &val) const;
171 :
172 : // Convenience functions for nonzero bitmask compatibility.
173 : wide_int get_nonzero_bits () const;
174 : void set_nonzero_bits (const wide_int &bits);
175 : private:
176 : wide_int m_value;
177 : wide_int m_mask;
178 : };
179 :
180 : inline void
181 3429131823 : irange_bitmask::set_unknown (unsigned prec)
182 : {
183 3429131823 : m_value = wi::zero (prec);
184 3429131823 : m_mask = wi::minus_one (prec);
185 3429131823 : if (flag_checking)
186 3429119616 : verify_mask ();
187 3429131823 : }
188 :
189 : // Return TRUE if THIS does not have any meaningful information.
190 :
191 : inline bool
192 5011637420 : irange_bitmask::unknown_p () const
193 : {
194 2329013285 : return m_mask == -1;
195 : }
196 :
197 : inline
198 1133219321 : irange_bitmask::irange_bitmask (const wide_int &value, const wide_int &mask)
199 : {
200 1133219321 : m_value = value;
201 1133219321 : m_mask = mask;
202 1133219321 : if (flag_checking)
203 1133215721 : verify_mask ();
204 1133219321 : }
205 :
206 : inline unsigned
207 : irange_bitmask::get_precision () const
208 : {
209 : return m_mask.get_precision ();
210 : }
211 :
212 : // The following two functions are meant for backwards compatibility
213 : // with the nonzero bitmask. A cleared bit means the value must be 0.
214 : // A set bit means we have no information for the bit.
215 :
216 : // Return the nonzero bits.
217 : inline wide_int
218 4645 : irange_bitmask::get_nonzero_bits () const
219 : {
220 4645 : return m_value | m_mask;
221 : }
222 :
223 : // Set the bitmask to the nonzero bits in BITS.
224 : inline void
225 : irange_bitmask::set_nonzero_bits (const wide_int &bits)
226 : {
227 : m_value = wi::zero (bits.get_precision ());
228 : m_mask = bits;
229 : if (flag_checking)
230 : verify_mask ();
231 : }
232 :
233 : // Return TRUE if val could be a valid value with this bitmask.
234 :
235 : inline bool
236 252378416 : irange_bitmask::member_p (const wide_int &val) const
237 : {
238 252378416 : if (unknown_p ())
239 : return true;
240 30104834 : wide_int res = m_mask & val;
241 30104834 : if (m_value != 0)
242 909065 : res |= ~m_mask & m_value;
243 30104834 : return res == val;
244 30104834 : }
245 :
246 : inline bool
247 1193422745 : irange_bitmask::operator== (const irange_bitmask &src) const
248 : {
249 1193422745 : bool unknown1 = unknown_p ();
250 1193422745 : bool unknown2 = src.unknown_p ();
251 1193422745 : if (unknown1 || unknown2)
252 909698258 : return unknown1 == unknown2;
253 283724487 : return m_value == src.m_value && m_mask == src.m_mask;
254 : }
255 :
256 : inline void
257 18140365 : irange_bitmask::union_ (const irange_bitmask &src)
258 : {
259 18140421 : m_mask = (m_mask | src.m_mask) | (m_value ^ src.m_value);
260 18140365 : m_value = m_value & src.m_value;
261 18140365 : if (flag_checking)
262 18140365 : verify_mask ();
263 18140365 : }
264 :
265 : // Return FALSE if the bitmask intersection is undefined.
266 :
267 : inline bool
268 795459116 : irange_bitmask::intersect (const irange_bitmask &src)
269 : {
270 : // If we have two known bits that are incompatible, the resulting
271 : // bit and therefore entire range is undefined. Return FALSE.
272 1590922540 : if (wi::bit_and (~(m_mask | src.m_mask),
273 2386377348 : m_value ^ src.m_value) != 0)
274 : return false;
275 : else
276 : {
277 795410404 : m_mask = m_mask & src.m_mask;
278 795410404 : m_value = m_value | src.m_value;
279 : }
280 795410404 : if (flag_checking)
281 795407903 : verify_mask ();
282 : return true;
283 : }
284 :
285 : // A subset of possible values for an integer type, leaving
286 : // allocation of storage to subclasses.
287 :
288 10173620536 : class irange : public vrange
289 : {
290 : friend class irange_storage;
291 : friend class vrange_printer;
292 : public:
293 : // In-place setters.
294 : void set (tree type, const wide_int &, const wide_int &,
295 : value_range_kind = VR_RANGE);
296 : virtual void set_nonzero (tree type) override;
297 : virtual void set_zero (tree type) override;
298 : virtual void set_nonnegative (tree type) override;
299 : virtual void set_varying (tree type) override;
300 : virtual void set_undefined () override;
301 :
302 : // Range types.
303 : static bool supports_p (const_tree type);
304 : virtual bool supports_type_p (const_tree type) const override;
305 : virtual tree type () const override;
306 :
307 : // Iteration over sub-ranges.
308 : unsigned num_pairs () const;
309 : wide_int lower_bound (unsigned = 0) const;
310 : wide_int upper_bound (unsigned) const;
311 : wide_int upper_bound () const;
312 : virtual tree lbound () const override;
313 : virtual tree ubound () const override;
314 :
315 : // Predicates.
316 : virtual bool zero_p () const override;
317 : virtual bool nonzero_p () const override;
318 : virtual bool singleton_p (tree *result = NULL) const override;
319 : bool singleton_p (wide_int &) const;
320 : bool contains_p (const wide_int &) const;
321 : bool nonnegative_p () const;
322 : bool nonpositive_p () const;
323 :
324 : // In-place operators.
325 : virtual bool union_ (const vrange &) override;
326 : virtual bool intersect (const vrange &) override;
327 : void invert ();
328 :
329 : // Operator overloads.
330 : irange& operator= (const irange &);
331 : bool operator== (const irange &) const;
332 : bool operator!= (const irange &r) const { return !(*this == r); }
333 :
334 : // Misc methods.
335 : virtual bool fits_p (const vrange &r) const override;
336 : virtual void accept (const vrange_visitor &v) const override;
337 :
338 : virtual void update_bitmask (const class irange_bitmask &) override;
339 : virtual irange_bitmask get_bitmask () const override;
340 :
341 : virtual void verify_range () const override;
342 : protected:
343 : void maybe_resize (int needed);
344 : virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
345 : virtual bool contains_p (tree cst) const override;
346 : irange (wide_int *, unsigned nranges, bool resizable);
347 :
348 : // In-place operators.
349 : bool irange_contains_p (const irange &) const;
350 : bool irange_single_pair_union (const irange &r);
351 :
352 : void normalize_kind ();
353 :
354 :
355 : // Hard limit on max ranges allowed.
356 : static const int HARD_MAX_RANGES = 255;
357 : private:
358 : bool varying_compatible_p () const;
359 : bool intersect_bitmask (const irange &r);
360 : bool union_bitmask (const irange &r);
361 : bool set_range_from_bitmask ();
362 : bool snap_subranges ();
363 : bool snap (const wide_int &, const wide_int &, wide_int &, wide_int &,
364 : bool &);
365 :
366 : bool intersect (const wide_int& lb, const wide_int& ub);
367 : bool union_append (const irange &r);
368 : unsigned char m_num_ranges;
369 : bool m_resizable;
370 : unsigned char m_max_ranges;
371 : tree m_type;
372 : irange_bitmask m_bitmask;
373 : protected:
374 : wide_int *m_base;
375 : };
376 :
377 : // Here we describe an irange with N pairs of ranges. The storage for
378 : // the pairs is embedded in the class as an array.
379 : //
380 : // If RESIZABLE is true, the storage will be resized on the heap when
381 : // the number of ranges needed goes past N up to a max of
382 : // HARD_MAX_RANGES. This new storage is freed upon destruction.
383 :
384 : template<unsigned N, bool RESIZABLE = false>
385 : class int_range final : public irange
386 : {
387 : public:
388 : int_range ();
389 : int_range (tree type, const wide_int &, const wide_int &,
390 : value_range_kind = VR_RANGE);
391 : int_range (tree type);
392 : int_range (const int_range &);
393 : int_range (const irange &);
394 : ~int_range () final override;
395 : int_range& operator= (const int_range &);
396 : protected:
397 : int_range (tree, tree, value_range_kind = VR_RANGE);
398 : private:
399 : wide_int m_ranges[N*2];
400 : };
401 :
402 : class prange final : public vrange
403 : {
404 : friend class prange_storage;
405 : friend class vrange_printer;
406 : public:
407 : prange ();
408 : prange (const prange &);
409 : prange (tree type);
410 : prange (tree type, const wide_int &, const wide_int &,
411 : value_range_kind = VR_RANGE);
412 : static bool supports_p (const_tree type);
413 : virtual bool supports_type_p (const_tree type) const final override;
414 : virtual void accept (const vrange_visitor &v) const final override;
415 : virtual void set_undefined () final override;
416 : virtual void set_varying (tree type) final override;
417 : virtual void set_nonzero (tree type) final override;
418 : virtual void set_zero (tree type) final override;
419 : virtual void set_nonnegative (tree type) final override;
420 : virtual bool contains_p (tree cst) const final override;
421 : virtual bool fits_p (const vrange &v) const final override;
422 : virtual bool singleton_p (tree *result = NULL) const final override;
423 : virtual bool zero_p () const final override;
424 : virtual bool nonzero_p () const final override;
425 : virtual void set (tree, tree, value_range_kind = VR_RANGE) final override;
426 : virtual tree type () const final override;
427 : virtual bool union_ (const vrange &v) final override;
428 : virtual bool intersect (const vrange &v) final override;
429 : virtual tree lbound () const final override;
430 : virtual tree ubound () const final override;
431 :
432 : prange& operator= (const prange &);
433 : bool operator== (const prange &) const;
434 : void set (tree type, const wide_int &, const wide_int &,
435 : value_range_kind = VR_RANGE);
436 : void invert ();
437 : bool contains_p (const wide_int &) const;
438 : wide_int lower_bound () const;
439 : wide_int upper_bound () const;
440 : virtual void verify_range () const final override;
441 : irange_bitmask get_bitmask () const final override;
442 : void update_bitmask (const irange_bitmask &) final override;
443 :
444 : // prange interface to points to information.
445 : // It can point_to or point_away from an object. This represents both
446 : // sides of a conditional. ie:
447 : // if (p == &foo)
448 : // // p points to foo.
449 : // else
450 : // // p points away from foo.
451 : // pt_invariant () and pt_invariant_away () - Return pt if this is invariant.
452 : void set_pt (const prange &r);
453 : void set_pt (tree ptr, bool points_to_p = true);
454 :
455 : // unknown_p () is true if no object is pointed to.
456 : void set_pt_unknown ();
457 : bool pt_unknown_p () const;
458 :
459 : // Invariant points-to are is_gimple_min_invariant_p ().
460 : // Return expression or NULL_TREE for points-to or away
461 : tree pt_invariant () const;
462 : tree pt_invariant_away () const;
463 :
464 : // Return true if THIS and R both point to the same object.
465 : bool pt_invariant_p (const prange &r) const;
466 : // Return true if THIS and R both point away from the same object.
467 : bool pt_invariant_away_p (const prange &r) const;
468 : // Return true if THIS and R refer to the same object, and one is inverted
469 : // from the other, Ie, both to and away.
470 : bool pt_inverted_p (const prange &r) const;
471 :
472 : // Invert THIS if it points either to or away from an object.
473 : bool pt_invert ();
474 :
475 : // pt_base () - object/allocation the pointer refers into.
476 : tree pt_base () const;
477 : // pt_offset () - possible byte offset range from BASE.
478 : void pt_offset (irange &) const;
479 : // pt_size () - possible size range of the referenced object.
480 : void pt_size (irange &) const;
481 :
482 : protected:
483 : bool varying_compatible_p () const;
484 :
485 : tree m_type;
486 : wide_int m_min;
487 : wide_int m_max;
488 : irange_bitmask m_bitmask;
489 :
490 : // A prange can point to an object, or NOT point to an object.
491 : tree m_pt; // object points-to refers to.
492 : bool m_points_to_p; // Does it point to it (TRUE), or not (FALSE).
493 : // If P has the same points to fields as THIS.
494 : bool pt_equal_p (const class prange &p) const;
495 : };
496 :
497 : // Unsupported temporaries may be created by ranger before it's known
498 : // they're unsupported, or by vr_values::get_value_range.
499 :
500 0 : class unsupported_range : public vrange
501 : {
502 : public:
503 73394877 : unsupported_range ()
504 73394877 : : vrange (VR_UNKNOWN)
505 : {
506 73394877 : set_undefined ();
507 : }
508 632678 : unsupported_range (const unsupported_range &src)
509 632678 : : vrange (VR_UNKNOWN)
510 : {
511 632678 : unsupported_range::operator= (src);
512 : }
513 : void set (tree min, tree, value_range_kind = VR_RANGE) final override;
514 : tree type () const final override;
515 : bool supports_type_p (const_tree) const final override;
516 : void set_varying (tree) final override;
517 : void set_undefined () final override;
518 : void accept (const vrange_visitor &v) const final override;
519 : bool union_ (const vrange &r) final override;
520 : bool intersect (const vrange &r) final override;
521 : bool singleton_p (tree * = NULL) const final override;
522 : bool contains_p (tree) const final override;
523 : bool zero_p () const final override;
524 : bool nonzero_p () const final override;
525 : void set_nonzero (tree type) final override;
526 : void set_zero (tree type) final override;
527 : void set_nonnegative (tree type) final override;
528 : bool fits_p (const vrange &) const final override;
529 : unsupported_range& operator= (const unsupported_range &r);
530 : tree lbound () const final override;
531 : tree ubound () const final override;
532 : };
533 :
534 : // The possible NAN state of a floating point value as an opaque object.
535 : // This represents one of the four subsets of { -NaN, +NaN },
536 : // i.e. one of {}, { -NaN }, { +NaN}, or { -NaN, +NaN }.
537 :
538 : class nan_state
539 : {
540 : public:
541 : nan_state (bool);
542 : nan_state (bool pos_nan, bool neg_nan);
543 : bool neg_p () const;
544 : bool pos_p () const;
545 : private:
546 : bool m_pos_nan;
547 : bool m_neg_nan;
548 : };
549 :
550 : // Set NAN state to +-NAN if NAN_P is true. Otherwise set NAN state
551 : // to false.
552 :
553 : inline
554 64053533 : nan_state::nan_state (bool nan_p)
555 : {
556 64053533 : m_pos_nan = nan_p;
557 59969910 : m_neg_nan = nan_p;
558 : }
559 :
560 : // Constructor initializing the object to +NAN if POS_NAN is set, -NAN
561 : // if NEG_NAN is set, or +-NAN if both are set. Otherwise POS_NAN and
562 : // NEG_NAN are clear, and the object cannot be a NAN.
563 :
564 : inline
565 4114820 : nan_state::nan_state (bool pos_nan, bool neg_nan)
566 : {
567 4114820 : m_pos_nan = pos_nan;
568 4105634 : m_neg_nan = neg_nan;
569 : }
570 :
571 : // Return if +NAN is possible.
572 :
573 : inline bool
574 36121456 : nan_state::pos_p () const
575 : {
576 36022258 : return m_pos_nan;
577 : }
578 :
579 : // Return if -NAN is possible.
580 :
581 : inline bool
582 35873423 : nan_state::neg_p () const
583 : {
584 35823780 : return m_neg_nan;
585 : }
586 :
587 : // A sub-range in an frange.
588 :
589 : struct frange_pair
590 : {
591 : REAL_VALUE_TYPE min;
592 : REAL_VALUE_TYPE max;
593 : };
594 :
595 : // A subset of possible values for a floating point type.
596 : //
597 : // The representation is a single interval, unioned with a subset of
598 : // { -NaN, +NaN }.
599 :
600 58702660 : class frange final : public vrange
601 : {
602 : friend class frange_storage;
603 : friend class vrange_printer;
604 : public:
605 : frange ();
606 : frange (const frange &);
607 : frange (tree, tree, value_range_kind = VR_RANGE);
608 : frange (tree type);
609 : frange (tree type, const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max,
610 : value_range_kind = VR_RANGE);
611 495364119 : static bool supports_p (const_tree type)
612 : {
613 : // ?? Decimal floats can have multiple representations for the
614 : // same number. Supporting them may be as simple as just
615 : // disabling them in singleton_p. No clue.
616 495364119 : return SCALAR_FLOAT_TYPE_P (type) && !DECIMAL_FLOAT_TYPE_P (type);
617 : }
618 : virtual tree type () const override;
619 : void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
620 : value_range_kind = VR_RANGE);
621 : void set (tree type, const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
622 : const nan_state &, value_range_kind = VR_RANGE);
623 : void set_nan (tree type);
624 : void set_nan (tree type, bool sign);
625 : void set_nan (tree type, const nan_state &);
626 : virtual void set_varying (tree type) override;
627 : virtual void set_undefined () override;
628 : virtual bool union_ (const vrange &) override;
629 : virtual bool intersect (const vrange &) override;
630 : bool contains_p (const REAL_VALUE_TYPE &) const;
631 : virtual bool singleton_p (tree *result = NULL) const override;
632 : bool singleton_p (REAL_VALUE_TYPE &r) const;
633 : virtual bool supports_type_p (const_tree type) const override;
634 : virtual void accept (const vrange_visitor &v) const override;
635 : virtual bool zero_p () const override;
636 : virtual bool nonzero_p () const override;
637 : virtual void set_nonzero (tree type) override;
638 : virtual void set_zero (tree type) override;
639 : virtual void set_nonnegative (tree type) override;
640 : virtual bool fits_p (const vrange &) const override;
641 : frange& operator= (const frange &);
642 : bool operator== (const frange &) const;
643 8525979 : bool operator!= (const frange &r) const { return !(*this == r); }
644 : const REAL_VALUE_TYPE &lower_bound () const;
645 : const REAL_VALUE_TYPE &upper_bound () const;
646 : virtual tree lbound () const override;
647 : virtual tree ubound () const override;
648 : nan_state get_nan_state () const;
649 : void update_nan ();
650 : void update_nan (bool sign);
651 : void update_nan (tree) = delete; // Disallow silent conversion to bool.
652 : void update_nan (const nan_state &);
653 : void clear_nan ();
654 : void flush_denormals_to_zero ();
655 :
656 : // fpclassify like API
657 : bool known_isfinite () const;
658 : bool known_isnan () const;
659 : bool known_isinf () const;
660 : bool maybe_isnan () const;
661 : bool maybe_isnan (bool sign) const;
662 : bool maybe_isinf () const;
663 : bool signbit_p (bool &signbit) const;
664 : bool nan_signbit_p (bool &signbit) const;
665 : bool known_isnormal () const;
666 : bool known_isdenormal_or_zero () const;
667 : virtual void verify_range () const override;
668 :
669 : static const unsigned int MAX_PAIRS = 1;
670 12363331 : unsigned num_pairs () const { return m_num_ranges; }
671 : const REAL_VALUE_TYPE &lower_bound (unsigned pair) const;
672 : const REAL_VALUE_TYPE &upper_bound (unsigned pair) const;
673 : protected:
674 : virtual bool contains_p (tree cst) const override;
675 : virtual void set (tree, tree, value_range_kind = VR_RANGE) override;
676 :
677 : private:
678 : bool internal_singleton_p (REAL_VALUE_TYPE * = NULL) const;
679 : bool normalize_kind ();
680 : bool union_nans (const frange &);
681 : bool intersect_nans (const frange &);
682 : void set_pairs (frange_pair *, unsigned);
683 : void canonicalize_zeros (frange_pair &);
684 :
685 : tree m_type;
686 : frange_pair m_pairs[MAX_PAIRS];
687 : unsigned char m_num_ranges;
688 : bool m_pos_nan;
689 : bool m_neg_nan;
690 : };
691 :
692 : inline const REAL_VALUE_TYPE &
693 21424249 : frange::lower_bound () const
694 : {
695 21424249 : gcc_checking_assert (!undefined_p () && !known_isnan ());
696 21424249 : return m_pairs[0].min;
697 : }
698 :
699 : inline const REAL_VALUE_TYPE &
700 19895744 : frange::upper_bound () const
701 : {
702 19895744 : gcc_checking_assert (!undefined_p () && !known_isnan ());
703 19895744 : return m_pairs[m_num_ranges - 1].max;
704 : }
705 :
706 : inline const REAL_VALUE_TYPE &
707 134 : frange::lower_bound (unsigned pair) const
708 : {
709 134 : gcc_checking_assert (!undefined_p () && !known_isnan ());
710 134 : gcc_checking_assert (pair < m_num_ranges);
711 134 : return m_pairs[pair].min;
712 : }
713 :
714 : inline const REAL_VALUE_TYPE &
715 134 : frange::upper_bound (unsigned pair) const
716 : {
717 134 : gcc_checking_assert (!undefined_p () && !known_isnan ());
718 134 : gcc_checking_assert (pair < m_num_ranges);
719 134 : return m_pairs[pair].max;
720 : }
721 :
722 : // Return the NAN state.
723 :
724 : inline nan_state
725 1882625 : frange::get_nan_state () const
726 : {
727 1882625 : return nan_state (m_pos_nan, m_neg_nan);
728 : }
729 :
730 : // is_a<> and as_a<> implementation for vrange.
731 :
732 : // Anything we haven't specialized is a hard fail.
733 : template <typename T>
734 : inline bool
735 : is_a (vrange &)
736 : {
737 : gcc_unreachable ();
738 : return false;
739 : }
740 :
741 : template <typename T>
742 : inline bool
743 4346242661 : is_a (const vrange &v)
744 : {
745 : // Reuse is_a <vrange> to implement the const version.
746 4550596708 : const T &derived = static_cast<const T &> (v);
747 1959078737 : return is_a <T> (const_cast<T &> (derived));
748 : }
749 :
750 : template <typename T>
751 : inline T &
752 2558428347 : as_a (vrange &v)
753 : {
754 0 : gcc_checking_assert (is_a <T> (v));
755 2558428347 : return static_cast <T &> (v);
756 : }
757 :
758 : template <typename T>
759 : inline const T &
760 3722186980 : as_a (const vrange &v)
761 : {
762 0 : gcc_checking_assert (is_a <T> (v));
763 3722186980 : return static_cast <const T &> (v);
764 : }
765 :
766 : // Specializations for the different range types.
767 :
768 : template <>
769 : inline bool
770 7323447318 : is_a <irange> (vrange &v)
771 : {
772 7197118808 : return v.m_discriminator == VR_IRANGE;
773 : }
774 :
775 : template <>
776 : inline bool
777 1459181517 : is_a <prange> (vrange &v)
778 : {
779 1316447863 : return v.m_discriminator == VR_PRANGE;
780 : }
781 :
782 : template <>
783 : inline bool
784 233213017 : is_a <frange> (vrange &v)
785 : {
786 233213017 : return v.m_discriminator == VR_FRANGE;
787 : }
788 :
789 : template <>
790 : inline bool
791 632678 : is_a <unsupported_range> (vrange &v)
792 : {
793 632678 : return v.m_discriminator == VR_UNKNOWN;
794 : }
795 :
796 : // For resizable ranges, resize the range up to HARD_MAX_RANGES if the
797 : // NEEDED pairs is greater than the current capacity of the range.
798 :
799 : inline void
800 1329627553 : irange::maybe_resize (int needed)
801 : {
802 1329627553 : if (!m_resizable || m_max_ranges == HARD_MAX_RANGES)
803 : return;
804 :
805 862705607 : if (needed > m_max_ranges)
806 : {
807 63211261 : m_max_ranges = HARD_MAX_RANGES;
808 32300954371 : wide_int *newmem = new wide_int[m_max_ranges * 2];
809 63211261 : unsigned n = num_pairs () * 2;
810 362573643 : for (unsigned i = 0; i < n; ++i)
811 299362382 : newmem[i] = m_base[i];
812 63211261 : m_base = newmem;
813 : }
814 : }
815 :
816 : template<unsigned N, bool RESIZABLE>
817 : inline
818 5086810268 : int_range<N, RESIZABLE>::~int_range ()
819 : {
820 3788762776 : if (RESIZABLE && m_base != m_ranges)
821 32300954371 : delete[] m_base;
822 31581959277 : }
823 :
824 : // This is an "infinite" precision irange for use in temporary
825 : // calculations. It starts with a sensible default covering 99% of
826 : // uses, and goes up to HARD_MAX_RANGES when needed. Any allocated
827 : // storage is freed upon destruction.
828 : typedef int_range<3, /*RESIZABLE=*/true> int_range_max;
829 :
830 40565 : class vrange_visitor
831 : {
832 : public:
833 0 : virtual void visit (const irange &) const { }
834 0 : virtual void visit (const prange &) const { }
835 0 : virtual void visit (const frange &) const { }
836 0 : virtual void visit (const unsupported_range &) const { }
837 : };
838 :
839 : // This is an "infinite" precision range object for use in temporary
840 : // calculations for any of the handled types. The object can be
841 : // transparently used as a vrange.
842 : //
843 : // Using any of the various constructors initializes the object
844 : // appropriately, but the default constructor is uninitialized and
845 : // must be initialized either with set_range_class() or by assigning into it.
846 : //
847 : // Assigning between incompatible types is allowed. For example if a
848 : // temporary holds an irange, you can assign an frange into it, and
849 : // all the right things will happen. However, before passing this
850 : // object to a function accepting a vrange, the correct type must be
851 : // set. If it isn't, you can do so with set_range_class().
852 :
853 : class value_range
854 : {
855 : public:
856 : value_range ();
857 : value_range (const vrange &r);
858 : value_range (tree type);
859 : value_range (tree, tree, value_range_kind kind = VR_RANGE);
860 : value_range (const value_range &);
861 : ~value_range ();
862 : void set_range_class (tree type);
863 : vrange& operator= (const vrange &);
864 : value_range& operator= (const value_range &);
865 : bool operator== (const value_range &r) const;
866 : bool operator!= (const value_range &r) const;
867 : operator vrange &();
868 : operator const vrange &() const;
869 : void dump (FILE *) const;
870 : void print (pretty_printer *) const;
871 : static bool supports_type_p (const_tree type);
872 :
873 3436237 : tree type () { return m_vrange->type (); }
874 154705190 : bool varying_p () const { return m_vrange->varying_p (); }
875 126166737 : bool undefined_p () const { return m_vrange->undefined_p (); }
876 311415058 : void set_varying (tree type) { init (type); m_vrange->set_varying (type); }
877 23016159 : void set_undefined () { m_vrange->set_undefined (); }
878 18449570 : bool union_ (const vrange &r) { return m_vrange->union_ (r); }
879 98327417 : bool intersect (const vrange &r) { return m_vrange->intersect (r); }
880 1451842 : bool contains_p (tree cst) const { return m_vrange->contains_p (cst); }
881 340600046 : bool singleton_p (tree *result = NULL) const
882 340600046 : { return m_vrange->singleton_p (result); }
883 : void set_zero (tree type) { init (type); return m_vrange->set_zero (type); }
884 0 : void set_nonzero (tree type)
885 0 : { init (type); return m_vrange->set_nonzero (type); }
886 262154 : bool nonzero_p () const { return m_vrange->nonzero_p (); }
887 4358 : bool zero_p () const { return m_vrange->zero_p (); }
888 10953231 : tree lbound () const { return m_vrange->lbound (); }
889 350660 : tree ubound () const { return m_vrange->ubound (); }
890 512738 : irange_bitmask get_bitmask () const { return m_vrange->get_bitmask (); }
891 1413371 : void update_bitmask (const class irange_bitmask &bm)
892 1413371 : { return m_vrange->update_bitmask (bm); }
893 2813 : void accept (const vrange_visitor &v) const { m_vrange->accept (v); }
894 : void verify_range () const { m_vrange->verify_range (); }
895 : private:
896 : void init (tree type);
897 : void init (const vrange &);
898 :
899 : vrange *m_vrange;
900 : union buffer_type {
901 : int_range_max ints;
902 : frange floats;
903 : unsupported_range unsupported;
904 : prange pointers;
905 6792934952 : buffer_type () { }
906 6914283583 : ~buffer_type () { }
907 : } m_buffer;
908 : };
909 :
910 : // The default constructor is uninitialized and must be initialized
911 : // with either set_range_class() or with an assignment into it.
912 :
913 : inline
914 3887554162 : value_range::value_range ()
915 3887554162 : : m_buffer ()
916 : {
917 3887554162 : m_vrange = NULL;
918 : }
919 :
920 : // Copy constructor.
921 :
922 : inline
923 12102512 : value_range::value_range (const value_range &r)
924 : {
925 12102512 : init (*r.m_vrange);
926 : }
927 :
928 : // Copy constructor from a vrange.
929 :
930 : inline
931 78614612 : value_range::value_range (const vrange &r)
932 : {
933 79534847 : init (r);
934 309890 : }
935 :
936 : // Construct an UNDEFINED range that can hold ranges of TYPE. If TYPE
937 : // is not supported, default to unsupported_range.
938 :
939 : inline
940 2813690127 : value_range::value_range (tree type)
941 : {
942 2637008987 : init (type);
943 5905959 : }
944 :
945 : // Construct a range that can hold a range of [MIN, MAX], where MIN
946 : // and MAX are trees.
947 :
948 : inline
949 53304 : value_range::value_range (tree min, tree max, value_range_kind kind)
950 : {
951 53304 : init (TREE_TYPE (min));
952 53304 : m_vrange->set (min, max, kind);
953 53304 : }
954 :
955 : inline
956 6914283583 : value_range::~value_range ()
957 : {
958 6914283583 : if (m_vrange)
959 3170936071 : m_vrange->~vrange ();
960 6914283583 : }
961 :
962 : // Initialize object to an UNDEFINED range that can hold ranges of
963 : // TYPE. Clean-up memory if there was a previous object.
964 : // Note that this does *not* set the type of the underlying vrange.
965 :
966 : inline void
967 102828977 : value_range::set_range_class (tree type)
968 : {
969 102828977 : if (m_vrange)
970 8900684 : m_vrange->~vrange ();
971 102828977 : init (type);
972 102828977 : }
973 :
974 : // Initialize object to an UNDEFINED range that can hold ranges of
975 : // TYPE.
976 : // Note that this does *not* set the type of the underlying vrange.
977 :
978 : inline void
979 3227987466 : value_range::init (tree type)
980 : {
981 3227987466 : gcc_checking_assert (TYPE_P (type));
982 :
983 3227987466 : if (irange::supports_p (type))
984 2288828677 : m_vrange = new (&m_buffer.ints) int_range_max ();
985 939158789 : else if (prange::supports_p (type))
986 759900493 : m_vrange = new (&m_buffer.pointers) prange ();
987 179258296 : else if (frange::supports_p (type))
988 105863419 : m_vrange = new (&m_buffer.floats) frange ();
989 : else
990 73394877 : m_vrange = new (&m_buffer.unsupported) unsupported_range ();
991 3227987466 : }
992 :
993 : // Initialize object with a copy of R.
994 :
995 : inline void
996 125889960 : value_range::init (const vrange &r)
997 : {
998 125889960 : if (is_a <irange> (r))
999 74338213 : m_vrange = new (&m_buffer.ints) int_range_max (as_a <irange> (r));
1000 51551747 : else if (is_a <prange> (r))
1001 101417720 : m_vrange = new (&m_buffer.pointers) prange (as_a <prange> (r));
1002 842887 : else if (is_a <frange> (r))
1003 420418 : m_vrange = new (&m_buffer.floats) frange (as_a <frange> (r));
1004 : else
1005 1265356 : m_vrange = new (&m_buffer.unsupported)
1006 632678 : unsupported_range (as_a <unsupported_range> (r));
1007 125889960 : }
1008 :
1009 : // Assignment operator. Copying incompatible types is allowed. That
1010 : // is, assigning an frange to an object holding an irange does the
1011 : // right thing.
1012 :
1013 : inline vrange &
1014 34252601 : value_range::operator= (const vrange &r)
1015 : {
1016 34252601 : if (m_vrange)
1017 9828473 : m_vrange->~vrange ();
1018 34252601 : init (r);
1019 34252601 : return *m_vrange;
1020 : }
1021 :
1022 : inline value_range &
1023 9881749 : value_range::operator= (const value_range &r)
1024 : {
1025 : // No need to call the m_vrange destructor here, as we will do so in
1026 : // the assignment below.
1027 1445368 : *this = *r.m_vrange;
1028 9881749 : return *this;
1029 : }
1030 :
1031 : inline bool
1032 24320881 : value_range::operator== (const value_range &r) const
1033 : {
1034 24320881 : return *m_vrange == *r.m_vrange;
1035 : }
1036 :
1037 : inline bool
1038 13418518 : value_range::operator!= (const value_range &r) const
1039 : {
1040 13418518 : return *m_vrange != *r.m_vrange;
1041 : }
1042 :
1043 : inline
1044 4683846038 : value_range::operator vrange &()
1045 : {
1046 4388294340 : return *m_vrange;
1047 : }
1048 :
1049 : inline
1050 44896721 : value_range::operator const vrange &() const
1051 : {
1052 44896721 : return *m_vrange;
1053 : }
1054 :
1055 : // Return TRUE if TYPE is supported by the vrange infrastructure.
1056 :
1057 : inline bool
1058 5963097152 : value_range::supports_type_p (const_tree type)
1059 : {
1060 5963097152 : return irange::supports_p (type)
1061 1512144828 : || prange::supports_p (type)
1062 232397007 : || frange::supports_p (type);
1063 : }
1064 :
1065 : extern value_range_kind get_legacy_range (const vrange &, tree &min, tree &max);
1066 : extern void dump_value_range (FILE *, const vrange *);
1067 : extern bool vrp_operand_equal_p (const_tree, const_tree);
1068 : inline REAL_VALUE_TYPE frange_val_min (const_tree type);
1069 : inline REAL_VALUE_TYPE frange_val_max (const_tree type);
1070 :
1071 : // Number of sub-ranges in a range.
1072 :
1073 : inline unsigned
1074 33372247685 : irange::num_pairs () const
1075 : {
1076 10177990076 : return m_num_ranges;
1077 : }
1078 :
1079 : inline tree
1080 11722390873 : irange::type () const
1081 : {
1082 11722390873 : gcc_checking_assert (m_num_ranges > 0);
1083 11722390873 : return m_type;
1084 : }
1085 :
1086 : inline bool
1087 5017053950 : irange::varying_compatible_p () const
1088 : {
1089 5017053950 : if (m_num_ranges != 1)
1090 : return false;
1091 :
1092 3729466070 : const wide_int &l = m_base[0];
1093 3729466070 : const wide_int &u = m_base[1];
1094 3729466070 : tree t = m_type;
1095 :
1096 3729466070 : if (m_kind == VR_VARYING)
1097 : return true;
1098 :
1099 3478431225 : unsigned prec = TYPE_PRECISION (t);
1100 3478431225 : signop sign = TYPE_SIGN (t);
1101 3478431225 : if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t))
1102 6956862450 : return (l == wi::min_value (prec, sign)
1103 4541310886 : && u == wi::max_value (prec, sign)
1104 3485333753 : && m_bitmask.unknown_p ());
1105 : return true;
1106 : }
1107 :
1108 : inline bool
1109 1060090517 : vrange::varying_p () const
1110 : {
1111 1056373505 : return m_kind == VR_VARYING;
1112 : }
1113 :
1114 : inline bool
1115 20007619924 : vrange::undefined_p () const
1116 : {
1117 11544872501 : return m_kind == VR_UNDEFINED;
1118 : }
1119 :
1120 : inline bool
1121 212134877 : irange::zero_p () const
1122 : {
1123 200344690 : return (m_kind == VR_RANGE && m_num_ranges == 1
1124 389227486 : && lower_bound (0) == 0
1125 412479584 : && upper_bound (0) == 0);
1126 : }
1127 :
1128 : inline bool
1129 45649 : irange::nonzero_p () const
1130 : {
1131 45649 : if (undefined_p ())
1132 : return false;
1133 :
1134 45649 : wide_int zero = wi::zero (TYPE_PRECISION (type ()));
1135 45649 : return *this == int_range<2> (type (), zero, zero, VR_ANTI_RANGE);
1136 45649 : }
1137 :
1138 : inline bool
1139 15159983767 : irange::supports_p (const_tree type)
1140 : {
1141 14338730532 : return INTEGRAL_TYPE_P (type);
1142 : }
1143 :
1144 : inline bool
1145 68620516 : irange::contains_p (tree cst) const
1146 : {
1147 68620516 : return contains_p (wi::to_wide (cst));
1148 : }
1149 :
1150 : inline bool
1151 34806427 : range_includes_zero_p (const vrange &vr)
1152 : {
1153 34806427 : if (vr.undefined_p ())
1154 : return false;
1155 :
1156 34806427 : if (vr.varying_p ())
1157 : return true;
1158 :
1159 26246652 : return vr.contains_p (build_zero_cst (vr.type ()));
1160 : }
1161 :
1162 : // Constructors for irange
1163 :
1164 : inline
1165 5204282618 : irange::irange (wide_int *base, unsigned nranges, bool resizable)
1166 : : vrange (VR_IRANGE),
1167 5204282618 : m_resizable (resizable),
1168 5204282618 : m_max_ranges (nranges)
1169 : {
1170 5204282618 : m_base = base;
1171 5204282618 : set_undefined ();
1172 : }
1173 :
1174 : // Constructors for int_range<>.
1175 :
1176 : template<unsigned N, bool RESIZABLE>
1177 : inline
1178 3897524456 : int_range<N, RESIZABLE>::int_range ()
1179 26596256974 : : irange (m_ranges, N, RESIZABLE)
1180 : {
1181 3897524456 : }
1182 :
1183 : template<unsigned N, bool RESIZABLE>
1184 418197 : int_range<N, RESIZABLE>::int_range (const int_range &other)
1185 2927371 : : irange (m_ranges, N, RESIZABLE)
1186 : {
1187 418197 : irange::operator= (other);
1188 418197 : }
1189 :
1190 : template<unsigned N, bool RESIZABLE>
1191 : int_range<N, RESIZABLE>::int_range (tree min, tree max, value_range_kind kind)
1192 : : irange (m_ranges, N, RESIZABLE)
1193 : {
1194 : irange::set (min, max, kind);
1195 : }
1196 :
1197 : template<unsigned N, bool RESIZABLE>
1198 158679400 : int_range<N, RESIZABLE>::int_range (tree type)
1199 628938176 : : irange (m_ranges, N, RESIZABLE)
1200 : {
1201 158679400 : set_varying (type);
1202 158679400 : }
1203 :
1204 : template<unsigned N, bool RESIZABLE>
1205 766233716 : int_range<N, RESIZABLE>::int_range (tree type, const wide_int &wmin, const wide_int &wmax,
1206 : value_range_kind kind)
1207 2662081588 : : irange (m_ranges, N, RESIZABLE)
1208 : {
1209 766233716 : set (type, wmin, wmax, kind);
1210 766233716 : }
1211 :
1212 : template<unsigned N, bool RESIZABLE>
1213 381426849 : int_range<N, RESIZABLE>::int_range (const irange &other)
1214 2450850357 : : irange (m_ranges, N, RESIZABLE)
1215 : {
1216 381426849 : irange::operator= (other);
1217 381426849 : }
1218 :
1219 : template<unsigned N, bool RESIZABLE>
1220 : int_range<N, RESIZABLE>&
1221 65935710 : int_range<N, RESIZABLE>::operator= (const int_range &src)
1222 : {
1223 65928296 : irange::operator= (src);
1224 384 : return *this;
1225 : }
1226 :
1227 : inline void
1228 5573447160 : irange::set_undefined ()
1229 : {
1230 5573447160 : m_kind = VR_UNDEFINED;
1231 5209087459 : m_num_ranges = 0;
1232 369164538 : }
1233 :
1234 : inline void
1235 1202478217 : irange::set_varying (tree type)
1236 : {
1237 1202478217 : m_kind = VR_VARYING;
1238 1202478217 : m_num_ranges = 1;
1239 1202478217 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1240 :
1241 1202478217 : if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
1242 : {
1243 1202478217 : m_type = type;
1244 : // Strict enum's require varying to be not TYPE_MIN/MAX, but rather
1245 : // min_value and max_value.
1246 1202478217 : m_base[0] = wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1247 1202491859 : m_base[1] = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1248 : }
1249 : else
1250 0 : m_type = error_mark_node;
1251 1202478217 : }
1252 :
1253 : // Return the lower bound of a sub-range. PAIR is the sub-range in
1254 : // question.
1255 :
1256 : inline wide_int
1257 11486160440 : irange::lower_bound (unsigned pair) const
1258 : {
1259 11486160440 : gcc_checking_assert (m_num_ranges > 0);
1260 11486160440 : gcc_checking_assert (pair + 1 <= num_pairs ());
1261 11486160440 : return m_base[pair * 2];
1262 : }
1263 :
1264 : // Return the upper bound of a sub-range. PAIR is the sub-range in
1265 : // question.
1266 :
1267 : inline wide_int
1268 13144251297 : irange::upper_bound (unsigned pair) const
1269 : {
1270 13144251297 : gcc_checking_assert (m_num_ranges > 0);
1271 13144251297 : gcc_checking_assert (pair + 1 <= num_pairs ());
1272 13144251297 : return m_base[pair * 2 + 1];
1273 : }
1274 :
1275 : // Return the highest bound of a range.
1276 :
1277 : inline wide_int
1278 3542396332 : irange::upper_bound () const
1279 : {
1280 3542396332 : unsigned pairs = num_pairs ();
1281 3542396332 : gcc_checking_assert (pairs > 0);
1282 3542396332 : return upper_bound (pairs - 1);
1283 : }
1284 :
1285 : // Set value range VR to a nonzero range of type TYPE.
1286 :
1287 : inline void
1288 3638914 : irange::set_nonzero (tree type)
1289 : {
1290 3638914 : unsigned prec = TYPE_PRECISION (type);
1291 :
1292 3638914 : if (TYPE_UNSIGNED (type))
1293 : {
1294 3232097 : m_type = type;
1295 3232097 : m_kind = VR_RANGE;
1296 3232097 : m_base[0] = wi::one (prec);
1297 3232097 : m_base[1] = wi::minus_one (prec);
1298 3232097 : m_bitmask.set_unknown (prec);
1299 3232097 : m_num_ranges = 1;
1300 :
1301 3232097 : if (flag_checking)
1302 3232097 : verify_range ();
1303 : }
1304 : else
1305 : {
1306 406817 : wide_int zero = wi::zero (prec);
1307 406817 : set (type, zero, zero, VR_ANTI_RANGE);
1308 406817 : }
1309 3638914 : }
1310 :
1311 : // Set value range VR to a ZERO range of type TYPE.
1312 :
1313 : inline void
1314 3438493 : irange::set_zero (tree type)
1315 : {
1316 3438493 : wide_int zero = wi::zero (TYPE_PRECISION (type));
1317 3438493 : set (type, zero, zero);
1318 3438493 : }
1319 :
1320 : // Normalize a range to VARYING or UNDEFINED if possible.
1321 :
1322 : inline void
1323 562291917 : irange::normalize_kind ()
1324 : {
1325 562291917 : if (m_num_ranges == 0)
1326 18755 : set_undefined ();
1327 562273162 : else if (varying_compatible_p ())
1328 : {
1329 27478084 : if (m_kind == VR_RANGE)
1330 6750722 : m_kind = VR_VARYING;
1331 20727362 : else if (m_kind == VR_ANTI_RANGE)
1332 0 : set_undefined ();
1333 : }
1334 562291917 : if (flag_checking)
1335 562291126 : verify_range ();
1336 562291917 : }
1337 :
1338 : inline bool
1339 25975531 : contains_zero_p (const irange &r)
1340 : {
1341 25975531 : if (r.undefined_p ())
1342 : return false;
1343 :
1344 25975531 : wide_int zero = wi::zero (TYPE_PRECISION (r.type ()));
1345 25975531 : return r.contains_p (zero);
1346 25975531 : }
1347 :
1348 : inline wide_int
1349 91608409 : irange_val_min (const_tree type)
1350 : {
1351 91608409 : gcc_checking_assert (irange::supports_p (type));
1352 91608409 : return wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1353 : }
1354 :
1355 : inline wide_int
1356 89538633 : irange_val_max (const_tree type)
1357 : {
1358 89538633 : gcc_checking_assert (irange::supports_p (type));
1359 89538633 : return wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
1360 : }
1361 :
1362 : inline
1363 912155805 : prange::prange ()
1364 912155805 : : vrange (VR_PRANGE)
1365 : {
1366 912155805 : set_undefined ();
1367 : }
1368 :
1369 : inline
1370 122156756 : prange::prange (const prange &r)
1371 122156756 : : vrange (VR_PRANGE)
1372 : {
1373 122156756 : *this = r;
1374 : }
1375 :
1376 : inline
1377 13094440 : prange::prange (tree type)
1378 13094440 : : vrange (VR_PRANGE)
1379 : {
1380 13094440 : set_varying (type);
1381 : }
1382 :
1383 : inline
1384 3043255 : prange::prange (tree type, const wide_int &lb, const wide_int &ub,
1385 3043255 : value_range_kind kind)
1386 3043255 : : vrange (VR_PRANGE)
1387 : {
1388 3043255 : set (type, lb, ub, kind);
1389 : }
1390 :
1391 : inline bool
1392 3709760138 : prange::supports_p (const_tree type)
1393 : {
1394 3709760138 : return POINTER_TYPE_P (type);
1395 : }
1396 :
1397 : inline bool
1398 453242953 : prange::supports_type_p (const_tree type) const
1399 : {
1400 453242953 : return POINTER_TYPE_P (type);
1401 : }
1402 :
1403 : inline void
1404 1040981145 : prange::set_undefined ()
1405 : {
1406 1040981145 : m_kind = VR_UNDEFINED;
1407 1040981145 : set_pt_unknown ();
1408 128418278 : }
1409 :
1410 : inline void
1411 469205804 : prange::set_varying (tree type)
1412 : {
1413 469205804 : m_kind = VR_VARYING;
1414 469205804 : m_type = type;
1415 469205804 : m_min = wi::zero (TYPE_PRECISION (type));
1416 469205804 : m_max = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
1417 469205804 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1418 469205804 : set_pt_unknown ();
1419 :
1420 469205804 : if (flag_checking)
1421 469205780 : verify_range ();
1422 469205804 : }
1423 :
1424 : inline void
1425 221220977 : prange::set_nonzero (tree type)
1426 : {
1427 221220977 : m_kind = VR_RANGE;
1428 221220977 : m_type = type;
1429 221220977 : m_min = wi::one (TYPE_PRECISION (type));
1430 221220977 : m_max = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
1431 221220977 : m_bitmask.set_unknown (TYPE_PRECISION (type));
1432 221220977 : set_pt_unknown ();
1433 :
1434 221220977 : if (flag_checking)
1435 221220719 : verify_range ();
1436 221220977 : }
1437 :
1438 : inline void
1439 674856 : prange::set_zero (tree type)
1440 : {
1441 674856 : m_kind = VR_RANGE;
1442 674856 : m_type = type;
1443 674856 : wide_int zero = wi::zero (TYPE_PRECISION (type));
1444 674856 : m_min = m_max = zero;
1445 674856 : m_bitmask = irange_bitmask (zero, zero);
1446 674856 : set_pt_unknown ();
1447 :
1448 674856 : if (flag_checking)
1449 674856 : verify_range ();
1450 674856 : }
1451 :
1452 : inline bool
1453 574389 : prange::contains_p (tree cst) const
1454 : {
1455 574389 : return contains_p (wi::to_wide (cst));
1456 : }
1457 :
1458 : inline bool
1459 255363341 : prange::zero_p () const
1460 : {
1461 255363341 : bool ret = m_kind == VR_RANGE && m_min == 0 && m_max == 0;
1462 255363341 : return ret;
1463 : }
1464 :
1465 : inline bool
1466 190599920 : prange::nonzero_p () const
1467 : {
1468 190599920 : return m_kind == VR_RANGE && m_min == 1 && m_max == -1;
1469 : }
1470 :
1471 : inline tree
1472 2026154071 : prange::type () const
1473 : {
1474 2026154071 : gcc_checking_assert (!undefined_p ());
1475 2026154071 : return m_type;
1476 : }
1477 :
1478 : inline wide_int
1479 318670843 : prange::lower_bound () const
1480 : {
1481 318670843 : gcc_checking_assert (!undefined_p ());
1482 318670843 : return m_min;
1483 : }
1484 :
1485 : inline wide_int
1486 306257508 : prange::upper_bound () const
1487 : {
1488 306257508 : gcc_checking_assert (!undefined_p ());
1489 306257508 : return m_max;
1490 : }
1491 :
1492 : inline bool
1493 1479367166 : prange::varying_compatible_p () const
1494 : {
1495 1479367150 : return (!undefined_p () && m_min == 0 && m_max == -1
1496 2570291882 : && get_bitmask ().unknown_p () && pt_unknown_p ());
1497 : }
1498 :
1499 : inline irange_bitmask
1500 838592670 : prange::get_bitmask () const
1501 : {
1502 838592670 : return m_bitmask;
1503 : }
1504 :
1505 : inline bool
1506 0 : prange::fits_p (const vrange &) const
1507 : {
1508 0 : return true;
1509 : }
1510 :
1511 : // Set this range's point-to object to PTR, and POINTS_TO_P is TRUE if it
1512 : // does point to it, and FALSE if it does not point to it.
1513 :
1514 : inline void
1515 204575950 : prange::set_pt (const prange &r)
1516 : {
1517 : // Do not set points-to info if this is zero or undefined.
1518 13880917 : if (!r.pt_unknown_p () && (undefined_p () || zero_p()))
1519 : return;
1520 :
1521 204575948 : m_pt = r.m_pt;
1522 204575948 : m_points_to_p = r.m_points_to_p;
1523 :
1524 204575948 : if (r.undefined_p ())
1525 : return;
1526 : // Check whether this is now VARYING or not.
1527 204511422 : if (varying_compatible_p ())
1528 26522359 : set_varying (type ());
1529 : else
1530 177989063 : m_kind = VR_RANGE;
1531 : }
1532 :
1533 : // prange_pt methods.
1534 : // ------------------------------------------------------------------
1535 :
1536 : inline void
1537 1775153053 : prange::set_pt_unknown ()
1538 : {
1539 1775153053 : m_pt = NULL_TREE;
1540 1647678832 : m_points_to_p = false;
1541 5909 : }
1542 :
1543 : inline bool
1544 1550897587 : prange::pt_unknown_p () const
1545 : {
1546 1494450644 : return (m_pt == NULL_TREE);
1547 : }
1548 :
1549 : inline bool
1550 65509402 : prange::pt_equal_p (const prange &p) const
1551 : {
1552 : // A prange object invokes vrp_operand_equal_p as we want ranges to compare
1553 : // equal to each other if they refer to the same object, even if the
1554 : // tree has become unshared.
1555 65509402 : return (m_points_to_p == p.m_points_to_p
1556 65509402 : && vrp_operand_equal_p (m_pt, p.m_pt));
1557 : }
1558 :
1559 : inline bool
1560 71855563 : prange::pt_inverted_p (const prange &r) const
1561 : {
1562 428918 : return m_pt && vrp_operand_equal_p (m_pt, r.m_pt)
1563 71956695 : && m_points_to_p != r.m_points_to_p;
1564 : }
1565 :
1566 : inline bool
1567 2649890 : prange::pt_invert ()
1568 : {
1569 2649890 : if (m_pt)
1570 : {
1571 0 : m_points_to_p = !m_points_to_p;
1572 0 : return true;
1573 : }
1574 : return false;
1575 : }
1576 :
1577 : inline tree
1578 82100284 : prange::pt_invariant () const
1579 : {
1580 82100284 : if (m_pt && m_points_to_p)
1581 7057 : return m_pt;
1582 : return NULL_TREE;
1583 : }
1584 :
1585 : inline tree
1586 1628771 : prange::pt_invariant_away () const
1587 : {
1588 1628771 : if (m_pt && !m_points_to_p)
1589 0 : return m_pt;
1590 : return NULL_TREE;
1591 : }
1592 :
1593 : inline bool
1594 17621028 : prange::pt_invariant_p (const prange &r) const
1595 : {
1596 187086 : if (m_pt && m_points_to_p && vrp_operand_equal_p (r.m_pt, m_pt)
1597 17635817 : && m_points_to_p == r.m_points_to_p)
1598 : return true;
1599 : return false;
1600 : }
1601 :
1602 : inline bool
1603 : prange::pt_invariant_away_p (const prange &r) const
1604 : {
1605 : if (m_pt && !m_points_to_p && vrp_operand_equal_p (r.m_pt, m_pt)
1606 : && m_points_to_p == r.m_points_to_p)
1607 : return true;
1608 : return false;
1609 : }
1610 :
1611 :
1612 : // -----------------------------------------------------------------------
1613 :
1614 : inline
1615 108407794 : frange::frange ()
1616 108407794 : : vrange (VR_FRANGE)
1617 : {
1618 108407758 : set_undefined ();
1619 : }
1620 :
1621 : inline
1622 11515976 : frange::frange (const frange &src)
1623 11515976 : : vrange (VR_FRANGE)
1624 : {
1625 11095566 : *this = src;
1626 : }
1627 :
1628 : inline
1629 782057 : frange::frange (tree type)
1630 782057 : : vrange (VR_FRANGE)
1631 : {
1632 782057 : set_varying (type);
1633 : }
1634 :
1635 : // frange constructor from REAL_VALUE_TYPE endpoints.
1636 :
1637 : inline
1638 46568820 : frange::frange (tree type,
1639 : const REAL_VALUE_TYPE &min, const REAL_VALUE_TYPE &max,
1640 46568296 : value_range_kind kind)
1641 46568820 : : vrange (VR_FRANGE)
1642 : {
1643 46568820 : set (type, min, max, kind);
1644 : }
1645 :
1646 : // frange constructor from trees.
1647 :
1648 : inline
1649 : frange::frange (tree min, tree max, value_range_kind kind)
1650 : : vrange (VR_FRANGE)
1651 : {
1652 : set (min, max, kind);
1653 : }
1654 :
1655 : inline tree
1656 70471831 : frange::type () const
1657 : {
1658 70471831 : gcc_checking_assert (!undefined_p ());
1659 70471831 : return m_type;
1660 : }
1661 :
1662 : inline void
1663 72457623 : frange::set_varying (tree type)
1664 : {
1665 72457623 : m_kind = VR_VARYING;
1666 72457623 : m_type = type;
1667 72457623 : m_num_ranges = 1;
1668 72457623 : m_pairs[0].min = frange_val_min (type);
1669 72457623 : m_pairs[0].max = frange_val_max (type);
1670 72457623 : if (HONOR_NANS (m_type))
1671 : {
1672 68331719 : m_pos_nan = true;
1673 68331719 : m_neg_nan = true;
1674 : }
1675 : else
1676 : {
1677 4125904 : m_pos_nan = false;
1678 4125904 : m_neg_nan = false;
1679 : }
1680 72457623 : }
1681 :
1682 : inline void
1683 170226083 : frange::set_undefined ()
1684 : {
1685 170226083 : m_kind = VR_UNDEFINED;
1686 170226083 : m_type = NULL;
1687 170226083 : m_num_ranges = 1;
1688 170226083 : m_pos_nan = false;
1689 170226083 : m_neg_nan = false;
1690 : // Leave the rest undefined; as it speeds up initializing undefined ranges.
1691 170226083 : if (flag_checking)
1692 170226083 : verify_range ();
1693 170226083 : }
1694 :
1695 : // Set the NAN bits to NAN and adjust the range.
1696 :
1697 : inline void
1698 6085601 : frange::update_nan (const nan_state &nan)
1699 : {
1700 6085601 : gcc_checking_assert (!undefined_p ());
1701 6085601 : if (HONOR_NANS (m_type))
1702 : {
1703 6085099 : m_pos_nan = nan.pos_p ();
1704 6085099 : m_neg_nan = nan.neg_p ();
1705 6085099 : normalize_kind ();
1706 6085099 : if (flag_checking)
1707 6085099 : verify_range ();
1708 : }
1709 6085601 : }
1710 :
1711 : // Set the NAN bit to +-NAN.
1712 :
1713 : inline void
1714 4036488 : frange::update_nan ()
1715 : {
1716 4036488 : gcc_checking_assert (!undefined_p ());
1717 4036488 : nan_state nan (true);
1718 4036488 : update_nan (nan);
1719 4036488 : }
1720 :
1721 : // Like above, but set the sign of the NAN.
1722 :
1723 : inline void
1724 2049113 : frange::update_nan (bool sign)
1725 : {
1726 2049113 : gcc_checking_assert (!undefined_p ());
1727 2049113 : nan_state nan (/*pos=*/!sign, /*neg=*/sign);
1728 2049113 : update_nan (nan);
1729 2049113 : }
1730 :
1731 : inline bool
1732 0 : frange::contains_p (tree cst) const
1733 : {
1734 0 : return contains_p (*TREE_REAL_CST_PTR (cst));
1735 : }
1736 :
1737 : // Clear the NAN bit and adjust the range.
1738 :
1739 : inline void
1740 14485451 : frange::clear_nan ()
1741 : {
1742 14485451 : gcc_checking_assert (!undefined_p ());
1743 14485451 : m_pos_nan = false;
1744 14485451 : m_neg_nan = false;
1745 14485451 : normalize_kind ();
1746 14485451 : if (flag_checking)
1747 14485451 : verify_range ();
1748 14485451 : }
1749 :
1750 : // Set R to maximum representable value for TYPE.
1751 :
1752 : inline REAL_VALUE_TYPE
1753 24420126 : real_max_representable (const_tree type)
1754 : {
1755 24420126 : REAL_VALUE_TYPE r;
1756 24420126 : char buf[128];
1757 24420126 : get_max_float (REAL_MODE_FORMAT (TYPE_MODE (type)),
1758 : buf, sizeof (buf), false);
1759 24420126 : int res = real_from_string (&r, buf);
1760 24420126 : gcc_checking_assert (!res);
1761 24420126 : return r;
1762 : }
1763 :
1764 : // Return the minimum representable value for TYPE.
1765 :
1766 : inline REAL_VALUE_TYPE
1767 12613815 : real_min_representable (const_tree type)
1768 : {
1769 12613815 : REAL_VALUE_TYPE r = real_max_representable (type);
1770 12613815 : r = real_value_negate (&r);
1771 12613815 : return r;
1772 : }
1773 :
1774 : // Return the minimum value for TYPE.
1775 :
1776 : inline REAL_VALUE_TYPE
1777 195162000 : frange_val_min (const_tree type)
1778 : {
1779 195162000 : if (HONOR_INFINITIES (type))
1780 183954101 : return dconstninf;
1781 : else
1782 11207899 : return real_min_representable (type);
1783 : }
1784 :
1785 : // Return the maximum value for TYPE.
1786 :
1787 : inline REAL_VALUE_TYPE
1788 138899778 : frange_val_max (const_tree type)
1789 : {
1790 138899778 : if (HONOR_INFINITIES (type))
1791 128584130 : return dconstinf;
1792 : else
1793 10315648 : return real_max_representable (type);
1794 : }
1795 :
1796 : // Return TRUE if R is the minimum value for TYPE.
1797 :
1798 : inline bool
1799 119294115 : frange_val_is_min (const REAL_VALUE_TYPE &r, const_tree type)
1800 : {
1801 119294115 : REAL_VALUE_TYPE min = frange_val_min (type);
1802 119294115 : return real_identical (&min, &r);
1803 : }
1804 :
1805 : // Return TRUE if R is the max value for TYPE.
1806 :
1807 : inline bool
1808 62645875 : frange_val_is_max (const REAL_VALUE_TYPE &r, const_tree type)
1809 : {
1810 62645875 : REAL_VALUE_TYPE max = frange_val_max (type);
1811 62645875 : return real_identical (&max, &r);
1812 : }
1813 :
1814 : // Build a NAN with a state of NAN.
1815 :
1816 : inline void
1817 407682 : frange::set_nan (tree type, const nan_state &nan)
1818 : {
1819 407682 : gcc_checking_assert (nan.pos_p () || nan.neg_p ());
1820 407682 : if (HONOR_NANS (type))
1821 : {
1822 407681 : m_kind = VR_NAN;
1823 407681 : m_type = type;
1824 407681 : m_num_ranges = 1;
1825 407681 : m_neg_nan = nan.neg_p ();
1826 407681 : m_pos_nan = nan.pos_p ();
1827 407681 : if (flag_checking)
1828 407681 : verify_range ();
1829 : }
1830 : else
1831 1 : set_undefined ();
1832 407682 : }
1833 :
1834 : // Build a signless NAN of type TYPE.
1835 :
1836 : inline void
1837 147678 : frange::set_nan (tree type)
1838 : {
1839 147678 : nan_state nan (true);
1840 147666 : set_nan (type, nan);
1841 126937 : }
1842 :
1843 : // Build a NAN of type TYPE with SIGN.
1844 :
1845 : inline void
1846 181295 : frange::set_nan (tree type, bool sign)
1847 : {
1848 181295 : nan_state nan (/*pos=*/!sign, /*neg=*/sign);
1849 181291 : set_nan (type, nan);
1850 21709 : }
1851 :
1852 : // Return TRUE if range is known to be finite.
1853 :
1854 : inline bool
1855 0 : frange::known_isfinite () const
1856 : {
1857 0 : if (undefined_p () || varying_p () || m_kind == VR_ANTI_RANGE)
1858 : return false;
1859 0 : return (!maybe_isnan ()
1860 0 : && !real_isinf (&lower_bound ())
1861 0 : && !real_isinf (&upper_bound ()));
1862 : }
1863 :
1864 : // Return TRUE if range is known to be normal.
1865 :
1866 : inline bool
1867 0 : frange::known_isnormal () const
1868 : {
1869 0 : if (!known_isfinite ())
1870 : return false;
1871 :
1872 0 : machine_mode mode = TYPE_MODE (type ());
1873 0 : const REAL_VALUE_TYPE &min = lower_bound ();
1874 0 : const REAL_VALUE_TYPE &max = upper_bound ();
1875 0 : return (!real_isdenormal (&min, mode) && !real_isdenormal (&max, mode)
1876 0 : && !real_iszero (&min) && !real_iszero (&max)
1877 0 : && (!real_isneg (&min) || real_isneg (&max)));
1878 : }
1879 :
1880 : // Return TRUE if range is known to be denormal.
1881 :
1882 : inline bool
1883 0 : frange::known_isdenormal_or_zero () const
1884 : {
1885 0 : if (!known_isfinite ())
1886 : return false;
1887 :
1888 0 : machine_mode mode = TYPE_MODE (type ());
1889 0 : const REAL_VALUE_TYPE &min = lower_bound ();
1890 0 : const REAL_VALUE_TYPE &max = upper_bound ();
1891 0 : return ((real_isdenormal (&min, mode) || real_iszero (&min))
1892 0 : && (real_isdenormal (&max, mode) || real_iszero (&max)));
1893 : }
1894 :
1895 : // Return TRUE if range may be infinite.
1896 :
1897 : inline bool
1898 34121 : frange::maybe_isinf () const
1899 : {
1900 34121 : if (undefined_p () || m_kind == VR_ANTI_RANGE || m_kind == VR_NAN)
1901 : return false;
1902 34121 : if (varying_p ())
1903 : return true;
1904 32083 : return real_isinf (&lower_bound ()) || real_isinf (&upper_bound ());
1905 : }
1906 :
1907 : // Return TRUE if range is known to be the [-INF,-INF] or [+INF,+INF].
1908 :
1909 : inline bool
1910 5766638 : frange::known_isinf () const
1911 : {
1912 5766638 : return (m_kind == VR_RANGE
1913 1481820 : && m_num_ranges == 1
1914 8243396 : && !maybe_isnan ()
1915 1238370 : && real_identical (&m_pairs[0].min, &m_pairs[0].max)
1916 5784966 : && real_isinf (&m_pairs[0].min));
1917 : }
1918 :
1919 : // Return TRUE if range is possibly a NAN.
1920 :
1921 : inline bool
1922 23345064 : frange::maybe_isnan () const
1923 : {
1924 21649948 : if (undefined_p ())
1925 : return false;
1926 23340562 : return m_pos_nan || m_neg_nan;
1927 : }
1928 :
1929 : // Return TRUE if range is possibly a NAN with SIGN.
1930 :
1931 : inline bool
1932 157293 : frange::maybe_isnan (bool sign) const
1933 : {
1934 157293 : if (undefined_p ())
1935 : return false;
1936 157293 : if (sign)
1937 157293 : return m_neg_nan;
1938 : return m_pos_nan;
1939 : }
1940 :
1941 : // Return TRUE if range is a +NAN or -NAN.
1942 :
1943 : inline bool
1944 25458993 : frange::known_isnan () const
1945 : {
1946 21386835 : return m_kind == VR_NAN;
1947 : }
1948 :
1949 : // If the signbit for the range is known, set it in SIGNBIT and return
1950 : // TRUE.
1951 :
1952 : inline bool
1953 1707145 : frange::signbit_p (bool &signbit) const
1954 : {
1955 1707145 : if (undefined_p ())
1956 : return false;
1957 :
1958 : // NAN with unknown sign.
1959 1707127 : if (m_pos_nan && m_neg_nan)
1960 : return false;
1961 : // No NAN.
1962 106428 : if (!m_pos_nan && !m_neg_nan)
1963 : {
1964 86157 : if (lower_bound ().sign == upper_bound ().sign)
1965 : {
1966 11457 : signbit = lower_bound ().sign;
1967 11457 : return true;
1968 : }
1969 : return false;
1970 : }
1971 : // NAN with known sign.
1972 20271 : bool nan_sign = m_neg_nan;
1973 20271 : if (known_isnan ()
1974 20271 : || (nan_sign == lower_bound ().sign
1975 18824 : && nan_sign == upper_bound ().sign))
1976 : {
1977 18945 : signbit = nan_sign;
1978 18945 : return true;
1979 : }
1980 : return false;
1981 : }
1982 :
1983 : // If range has a NAN with a known sign, set it in SIGNBIT and return
1984 : // TRUE.
1985 :
1986 : inline bool
1987 53662 : frange::nan_signbit_p (bool &signbit) const
1988 : {
1989 53662 : if (undefined_p ())
1990 : return false;
1991 :
1992 53662 : if (m_pos_nan == m_neg_nan)
1993 : return false;
1994 :
1995 2528 : signbit = m_neg_nan;
1996 2528 : return true;
1997 : }
1998 :
1999 : void frange_nextafter (enum machine_mode, REAL_VALUE_TYPE &,
2000 : const REAL_VALUE_TYPE &);
2001 : void frange_arithmetic (enum tree_code, tree, REAL_VALUE_TYPE &,
2002 : const REAL_VALUE_TYPE &, const REAL_VALUE_TYPE &,
2003 : const REAL_VALUE_TYPE &);
2004 :
2005 : // Return true if TYPE1 and TYPE2 are compatible range types.
2006 :
2007 : inline bool
2008 1600924876 : range_compatible_p (tree type1, tree type2)
2009 : {
2010 : // types_compatible_p requires conversion in both directions to be useless.
2011 : // GIMPLE only requires a cast one way in order to be compatible.
2012 : // Ranges really only need the sign and precision to be the same.
2013 1600924876 : return (TYPE_PRECISION (type1) == TYPE_PRECISION (type2)
2014 1600924876 : && TYPE_SIGN (type1) == TYPE_SIGN (type2));
2015 : }
2016 : #endif // GCC_VALUE_RANGE_H
|