https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100499
--- Comment #20 from Aldy Hernandez <aldyh at redhat dot com> --- On Wed, May 19, 2021 at 8:31 AM rguenth at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org> wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100499 > > --- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> --- > (In reply to Andrew Macleod from comment #16) > > We could add an expression evaluator that can walk that expression, invoking > > range-ops on each expression, and calling a ranger instance to evaluate a > > range for any ssa_name it finds. > > > > It would bail if there are unknown tree-codes to range-ops. > > Yeah, it would be similar to the existing determine_value_range () function > which does exactly do this (but not using ranger). determine_value_range() has been calling range-ops under the covers for quite a while, so it's half-way there. It would require some minor tweaks: a) Use irange instead of value_range so as to not throw away the higher precision range-ops calculates. b) If we want context-aware ranges, pass it a gimple statement / edge / etc, and a range_query/ranger. Oh yeah, and return a proper range, not this value_range_kind + wide_int + wide_int business (determine_value_range_1 does this already).