https://gcc.gnu.org/g:02b7c73a331a09ab32c269b3b9bdb4d4a2a83b54

commit r17-1829-g02b7c73a331a09ab32c269b3b9bdb4d4a2a83b54
Author: Richard Biener <[email protected]>
Date:   Wed Jun 24 10:43:38 2026 +0200

    Improve vect_recog_divmod_pattern use of ranger
    
    As we now have a ranger active during vectorization there's no need
    to create a new one.  And the stmt argument of range_of_expr is for
    the context of the  range.  Passing the def stmt of expr is equal
    to asking for global ranges only (passing NULL as stmt).
    
            * tree-vect-patterns.cc (vect_recog_divmod_pattern): Pass
            the division stmt as context for the range query on op0.
            Use the active ranger.

Diff:
---
 gcc/tree-vect-patterns.cc | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index ab7892b6c7ba..e0fbe2521635 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -5438,15 +5438,12 @@ vect_recog_divmod_pattern (vec_info *vinfo,
       int pow = wi::exact_log2 (wcst + 1);
       if (pow == prec / 2)
        {
-         gimple *stmt = SSA_NAME_DEF_STMT (oprnd0);
-
-         gimple_ranger ranger;
-         int_range_max r;
-
          /* Check that no overflow will occur.  If we don't have range
             information we can't perform the optimization.  */
 
-         if (ranger.range_of_expr (r, oprnd0, stmt) && !r.undefined_p ())
+         int_range_max r;
+         if (get_range_query (cfun)->range_of_expr (r, oprnd0, last_stmt)
+             && !r.undefined_p ())
            {
              wide_int max = r.upper_bound ();
              wide_int one = wi::shwi (1, prec);

Reply via email to