]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove some uses of deprecated irange API.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 17 Jan 2023 18:56:36 +0000 (19:56 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 26 Apr 2023 09:46:06 +0000 (11:46 +0200)
gcc/ChangeLog:

* builtins.cc (expand_builtin_strnlen): Rewrite deprecated irange
API uses to new API.
* gimple-predicate-analysis.cc (find_var_cmp_const): Same.
* internal-fn.cc (get_min_precision): Same.
* match.pd: Same.
* tree-affine.cc (expr_to_aff_combination): Same.
* tree-data-ref.cc (dr_step_indicator): Same.
* tree-dfa.cc (get_ref_base_and_extent): Same.
* tree-scalar-evolution.cc (iv_can_overflow_p): Same.
* tree-ssa-phiopt.cc (two_value_replacement): Same.
* tree-ssa-pre.cc (insert_into_preds_of_block): Same.
* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): Same.
* tree-ssa-strlen.cc (compare_nonzero_chars): Same.
* tree-switch-conversion.cc (bit_test_cluster::emit): Same.
* tree-vect-patterns.cc (vect_recog_divmod_pattern): Same.
* tree.cc (get_range_pos_neg): Same.

15 files changed:
gcc/builtins.cc
gcc/gimple-predicate-analysis.cc
gcc/internal-fn.cc
gcc/match.pd
gcc/tree-affine.cc
gcc/tree-data-ref.cc
gcc/tree-dfa.cc
gcc/tree-scalar-evolution.cc
gcc/tree-ssa-phiopt.cc
gcc/tree-ssa-pre.cc
gcc/tree-ssa-reassoc.cc
gcc/tree-ssa-strlen.cc
gcc/tree-switch-conversion.cc
gcc/tree-vect-patterns.cc
gcc/tree.cc

index bb931242c9c927c1ca1097dd8def20470b499bd5..878596c240a9e43a0d823178534beddbec694dfe 100644 (file)
@@ -3494,7 +3494,7 @@ expand_builtin_strnlen (tree exp, rtx target, machine_mode target_mode)
   wide_int min, max;
   value_range r;
   get_global_range_query ()->range_of_expr (r, bound);
-  if (r.kind () != VR_RANGE)
+  if (r.varying_p () || r.undefined_p ())
     return NULL_RTX;
   min = r.lower_bound ();
   max = r.upper_bound ();
index c89a5b1653a5288cafca0ba57ca90b40a2c26715..7f20f81ad863e087c905bca756ce455cc1efef9a 100644 (file)
@@ -307,7 +307,8 @@ find_var_cmp_const (pred_chain_union preds, gphi *phi, gimple **flag_def,
          value_range r;
          if (!INTEGRAL_TYPE_P (type)
              || !get_range_query (cfun)->range_of_expr (r, cond_rhs)
-             || r.kind () != VR_RANGE)
+             || r.undefined_p ()
+             || r.varying_p ())
            continue;
 
          wide_int min = r.lower_bound ();
index 6e81dc05e0e0714256759b0594816df451415a2d..5c9da73ea11f8060b18dcf513599c9694fa4f2ad 100644 (file)
@@ -775,7 +775,8 @@ get_min_precision (tree arg, signop sign)
     return prec + (orig_sign != sign);
   value_range r;
   while (!get_global_range_query ()->range_of_expr (r, arg)
-        || r.kind () != VR_RANGE)
+        || r.varying_p ()
+        || r.undefined_p ())
     {
       gimple *g = SSA_NAME_DEF_STMT (arg);
       if (is_gimple_assign (g)
index e89ba57e30b7cbabbb7d14b0cf0e5417fafd4b56..34e1a5c1b46ca1f075b3d0df15ccf529ba8419ae 100644 (file)
@@ -525,7 +525,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       value_range vr0;
       if (ovf1 == wi::OVF_NONE && ovf2 == wi::OVF_NONE
          && get_global_range_query ()->range_of_expr (vr0, @4)
-         && vr0.kind () == VR_RANGE)
+         && !vr0.varying_p () && !vr0.undefined_p ())
        {
          wide_int wmin0 = vr0.lower_bound ();
          wide_int wmax0 = vr0.upper_bound ();
@@ -566,7 +566,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       value_range vr0;
       if (ovf1 == wi::OVF_NONE && ovf2 == wi::OVF_NONE
          && get_global_range_query ()->range_of_expr (vr0, @0)
-         && vr0.kind () == VR_RANGE)
+         && !vr0.varying_p () && !vr0.undefined_p ())
        {
          wide_int wmin0 = vr0.lower_bound ();
          wide_int wmax0 = vr0.upper_bound ();
@@ -853,8 +853,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        if (INTEGRAL_TYPE_P (type)
           && get_global_range_query ()->range_of_expr (vr0, @0)
           && get_global_range_query ()->range_of_expr (vr1, @1)
-          && vr0.kind () == VR_RANGE
-          && vr1.kind () == VR_RANGE)
+          && !vr0.varying_p () && !vr0.undefined_p ()
+          && !vr1.varying_p () && !vr1.undefined_p ())
         {
           wide_int wmin0 = vr0.lower_bound ();
           wide_int wmax0 = vr0.upper_bound ();
@@ -3010,7 +3010,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
        value_range vr;
        if (get_global_range_query ()->range_of_expr (vr, @0)
-           && vr.kind () == VR_RANGE)
+           && !vr.varying_p () && !vr.undefined_p ())
           {
            wide_int wmin0 = vr.lower_bound ();
            wide_int wmax0 = vr.upper_bound ();
index 5d0632f09b8be1d01879bb24f81cc45405adf4d5..ee327e63a236effd95b9de77dbeb8d28f08df824 100644 (file)
@@ -351,7 +351,8 @@ expr_to_aff_combination (aff_tree *comb, tree_code code, tree type,
                && TYPE_OVERFLOW_WRAPS (itype)
                && TREE_CODE (op1) == INTEGER_CST
                && get_range_query (cfun)->range_of_expr (vr, op0)
-               && vr.kind () == VR_RANGE)
+               && !vr.varying_p ()
+               && !vr.undefined_p ())
              {
                wide_int minv = vr.lower_bound ();
                wide_int maxv = vr.upper_bound ();
index 4ebd839db156e1095fc31589457cc8bd828d1541..6a4112b9fdedaf970c2ab5abec88e6984abd0c55 100644 (file)
@@ -6351,7 +6351,7 @@ dr_step_indicator (struct data_reference *dr, int useful_min)
       value_range vr;
       if (TREE_CODE (step) != SSA_NAME
          || !get_range_query (cfun)->range_of_expr (vr, step)
-         || vr.kind () != VR_RANGE)
+         || vr.undefined_p ())
        {
          step_min = wi::to_wide (TYPE_MIN_VALUE (type));
          step_max = wi::to_wide (TYPE_MAX_VALUE (type));
index 82803a8ccb1d3e4151def9be5d5d2694e29a96f3..ad8cfedec8ce884626a884ef96394d761a2c5bd4 100644 (file)
@@ -542,7 +542,8 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset,
                    && (unit_size = array_ref_element_size (exp),
                        TREE_CODE (unit_size) == INTEGER_CST)
                    && query->range_of_expr (vr, index)
-                   && vr.kind () == VR_RANGE)
+                   && !vr.varying_p ()
+                   && !vr.undefined_p ())
                  {
                    wide_int min = vr.lower_bound ();
                    wide_int max = vr.upper_bound ();
index 672cf9fab62fb432790a3551fd52295bd683041c..ba47a684f4b373fb4f2dc16ddb8edb0ef39da6ed 100644 (file)
@@ -3032,7 +3032,8 @@ iv_can_overflow_p (class loop *loop, tree type, tree base, tree step)
 
   if (!INTEGRAL_TYPE_P (TREE_TYPE (base))
       || !get_range_query (cfun)->range_of_expr (r, base)
-      || r.kind () != VR_RANGE)
+      || r.varying_p ()
+      || r.undefined_p ())
     return true;
 
   base_min = r.lower_bound ();
@@ -3040,7 +3041,8 @@ iv_can_overflow_p (class loop *loop, tree type, tree base, tree step)
 
   if (!INTEGRAL_TYPE_P (TREE_TYPE (step))
       || !get_range_query (cfun)->range_of_expr (r, step)
-      || r.kind () != VR_RANGE)
+      || r.varying_p ()
+      || r.undefined_p ())
     return true;
 
   step_min = r.lower_bound ();
index 4a3ab8efb712700057b3caf1d1ebe51bb1b6cfa8..3b15ffcb0fc0bb423a02c628837b1d0b8e4b0902 100644 (file)
@@ -687,22 +687,13 @@ two_value_replacement (basic_block cond_bb, basic_block middle_bb,
              <= TYPE_PRECISION (TREE_TYPE (lhs)))))
     return false;
 
-  wide_int min, max;
   value_range r;
   get_range_query (cfun)->range_of_expr (r, lhs);
+  if (r.undefined_p ())
+    r.set_varying (TREE_TYPE (lhs));
+  wide_int min = r.lower_bound ();
+  wide_int max = r.upper_bound ();
 
-  if (r.kind () == VR_RANGE)
-    {
-      min = r.lower_bound ();
-      max = r.upper_bound ();
-    }
-  else
-    {
-      int prec = TYPE_PRECISION (TREE_TYPE (lhs));
-      signop sgn = TYPE_SIGN (TREE_TYPE (lhs));
-      min = wi::min_value (prec, sgn);
-      max = wi::max_value (prec, sgn);
-    }
   if (min + 1 != max
       || (wi::to_wide (rhs) != min
          && wi::to_wide (rhs) != max))
index 943936df8080b047a26f27a77dab115ac9976b27..1f7eea93c16c8ff940d33d875682591aff8bbb43 100644 (file)
@@ -3247,7 +3247,8 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum,
     {
       value_range r;
       if (get_range_query (cfun)->range_of_expr (r, expr->u.nary->op[0])
-         && r.kind () == VR_RANGE
+         && !r.undefined_p ()
+         && !r.varying_p ()
          && !wi::neg_p (r.lower_bound (), SIGNED)
          && !wi::neg_p (r.upper_bound (), SIGNED))
        {
index e795bdc0db4f353253f28a93daf53f53e4619456..aeaca2f76cccbb12fac9b6a8839b96be59b9de60 100644 (file)
@@ -3372,7 +3372,8 @@ optimize_range_tests_to_bit_test (enum tree_code opcode, int first, int length,
       value_range r;
       if (TREE_CODE (exp) == SSA_NAME
          && get_range_query (cfun)->range_of_expr (r, exp)
-         && r.kind () == VR_RANGE
+         && !r.undefined_p ()
+         && !r.varying_p ()
          && wi::leu_p (r.upper_bound () - r.lower_bound (), prec - 1))
        {
          wide_int min = r.lower_bound ();
index dcc9e9e14abd0ba920e7490580ff227e8436e176..0bbcb04834ff9a28e1bc89a3d5f6c73610ed41e0 100644 (file)
@@ -350,18 +350,19 @@ compare_nonzero_chars (strinfo *si, gimple *stmt,
     return -1;
 
   value_range vr;
-  if (!rvals->range_of_expr (vr, si->nonzero_chars, stmt))
-    return -1;
-  value_range_kind rng = vr.kind ();
-  if (rng != VR_RANGE)
+  if (!rvals->range_of_expr (vr, si->nonzero_chars, stmt)
+      || vr.varying_p ()
+      || vr.undefined_p ())
     return -1;
 
   /* If the offset is less than the minimum length or if the bounds
      of the length range are equal return the result of the comparison
      same as in the constant case.  Otherwise return a conservative
      result.  */
-  int cmpmin = compare_tree_int (vr.min (), off);
-  if (cmpmin > 0 || tree_int_cst_equal (vr.min (), vr.max ()))
+  tree lower = wide_int_to_tree (vr.type (), vr.lower_bound ());
+  tree upper = wide_int_to_tree (vr.type (), vr.upper_bound ());
+  int cmpmin = compare_tree_int (lower, off);
+  if (cmpmin > 0 || tree_int_cst_equal (lower, upper))
     return cmpmin;
 
   return -1;
index dfdcd79bb40bedc78df484dbc921f9b7fc643b79..44934d2560d2696567912e82e4b13babf4c01c77 100644 (file)
@@ -1590,7 +1590,8 @@ bit_test_cluster::emit (tree index_expr, tree index_type,
   value_range r;
   if (TREE_CODE (index_expr) == SSA_NAME
       && get_range_query (cfun)->range_of_expr (r, index_expr)
-      && r.kind () == VR_RANGE
+      && !r.undefined_p ()
+      && !r.varying_p ()
       && wi::leu_p (r.upper_bound () - r.lower_bound (), prec - 1))
     {
       wide_int min = r.lower_bound ();
index b964dcb8ad9e9c37c6baf29315ccbb6945618ed0..33a8b2bb60601dc1a67de62a56bbf3c355e12dbd 100644 (file)
@@ -4598,7 +4598,7 @@ vect_recog_divmod_pattern (vec_info *vinfo,
       int msb = 1;
       value_range r;
       get_range_query (cfun)->range_of_expr (r, oprnd0);
-      if (r.kind () == VR_RANGE)
+      if (!r.varying_p () && !r.undefined_p ())
        {
          if (!wi::neg_p (r.lower_bound (), TYPE_SIGN (itype)))
            msb = 0;
index 8394ff0f8378581d4803c5abec8e20246a397ad4..ead4248b8e5c449185922273ebf8c9db3aa35076 100644 (file)
@@ -14296,7 +14296,8 @@ get_range_pos_neg (tree arg)
   if (TREE_CODE (arg) != SSA_NAME)
     return 3;
   value_range r;
-  while (!get_global_range_query ()->range_of_expr (r, arg) || r.kind () != VR_RANGE)
+  while (!get_global_range_query ()->range_of_expr (r, arg)
+        || r.undefined_p () || r.varying_p ())
     {
       gimple *g = SSA_NAME_DEF_STMT (arg);
       if (is_gimple_assign (g)