Next: , Previous: , Up: Comparisons involving poly_int   [Contents][Index]


10.3.6 Range checks on poly_ints

As well as the core comparisons (see Comparison functions for poly_int), poly_int provides utilities for various kinds of range check. In each case the range is represented by a start position and a size rather than a start position and an end position; this is because the former is used much more often than the latter in GCC. Also, the sizes can be -1 (or all ones for unsigned sizes) to indicate a range with a known start position but an unknown size. All other sizes must be nonnegative. A range of size 0 does not contain anything or overlap anything.

known_size_p (size)

Return true if size represents a known range size, false if it is -1 or all ones (for signed and unsigned types respectively).

ranges_maybe_overlap_p (pos1, size1, pos2, size2)

Return true if the range described by pos1 and size1 might overlap the range described by pos2 and size2 (in other words, return true if we cannot prove that the ranges are disjoint).

ranges_known_overlap_p (pos1, size1, pos2, size2)

Return true if the range described by pos1 and size1 is known to overlap the range described by pos2 and size2.

known_subrange_p (pos1, size1, pos2, size2)

Return true if the range described by pos1 and size1 is known to be contained in the range described by pos2 and size2.

maybe_in_range_p (value, pos, size)

Return true if value might be in the range described by pos and size (in other words, return true if we cannot prove that value is outside that range).

known_in_range_p (value, pos, size)

Return true if value is known to be in the range described by pos and size.

endpoint_representable_p (pos, size)

Return true if the range described by pos and size is open-ended or if the endpoint (pos + size) is representable in the same type as pos and size. The function returns false if adding size to pos makes conceptual sense but could overflow.

There is also a poly_int version of the IN_RANGE_P macro:

coeffs_in_range_p (x, lower, upper)

Return true if every coefficient of x is in the inclusive range [lower, upper]. This function can be useful when testing whether an operation would cause the values of coefficients to overflow.

Note that the function does not indicate whether x itself is in the given range. x can be either a constant or a poly_int.


Next: , Previous: , Up: Comparisons involving poly_int   [Contents][Index]