On 1/17/23 10:47, Jakub Jelinek wrote:
Aldy/Andrew, is the ranger query ok or should I use something different when check_range_stmt is non-NULL and I know on which statement to ask?
<snip>
+ int_range_max r; + if (!get_global_range_query ()->range_of_expr (r, rotcnt, + check_range_stmt)) + return false;
range_of_expr will work with and without a statement. If no statement is provided, it will return the global range. So you can use the same range_of_expr call with a statement or without one if you don't know it.
Note that get_global_range_query () will always return a global query object (think SSA_NAME_RANGE_INFO). It will never use an existing ranger (for example, if called within VRP or another pass that has an active ranger enabled). If simplify_rotate() may be used from some of these passes you *may* want to use get_range_query() which will pick up the active ranger, or a global query object if no ranger is active.
For that matter, since get_global_range_query() uses a global query, it really doesn't matter if you pass a statement or not, since our global range store has no context (SSA_NAME_RANGE_INFO). Although, I personally always pass the statement if known, because it's good form, and if things ever change to an active ranger, everything will just work.
Aldy