GNU Compiler Collection (GCC) Internals: Comparing ordered poly_ints

Next: Checking for a `poly_int` marker value, Previous: Comparing potentially-unordered `poly_int`s, Up: Comparisons involving `poly_int` [Contents][Index]

#### 10.3.4 Comparing ordered `poly_int`s

In cases where there is a definite link between two `poly_int`s, such as the outer and inner sizes of subregs, we usually require the sizes to be ordered by the `known_le` partial order. `poly_int` provides the following utility functions for ordered values:

‘`ordered_p (a, b)`’

  Return true if a and b are ordered by the `known_le` partial order.

‘`ordered_min (a, b)`’

  Assert that a and b are ordered by `known_le` and return the minimum of the two. When using this function, please add a comment explaining why the values are known to be ordered.

‘`ordered_max (a, b)`’

  Assert that a and b are ordered by `known_le` and return the maximum of the two. When using this function, please add a comment explaining why the values are known to be ordered.

For example, if a subreg has an outer mode of size outer and an inner mode of size inner:

- the subreg is complete if known_eq (inner, outer)
- otherwise, the subreg is paradoxical if known_le (inner, outer)
- otherwise, the subreg is partial if known_le (outer, inner)
- otherwise, the subreg is ill-formed

Thus the subreg is only valid if ‘`ordered_p (outer, inner)`’ is true. If this condition is already known to be true then:

- the subreg is complete if known_eq (inner, outer)
- the subreg is paradoxical if maybe_lt (inner, outer)
- the subreg is partial if maybe_lt (outer, inner)

with the three conditions being mutually exclusive.

Code that checks whether a subreg is valid would therefore generally check whether `ordered_p` holds (in addition to whatever other checks are required for subreg validity). Code that is dealing with existing subregs can assert that `ordered_p` holds and use either of the classifications above.

Next: Checking for a `poly_int` marker value, Previous: Comparing potentially-unordered `poly_int`s, Up: Comparisons involving `poly_int` [Contents][Index]