]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Misc conversions to vrange.
authorAldy Hernandez <aldyh@redhat.com>
Mon, 4 Jul 2022 15:32:07 +0000 (17:32 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 4 Jul 2022 18:43:14 +0000 (20:43 +0200)
The following converts a handful of places that were irange centric.

Tested on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-fold.cc
(fold_using_range::range_of_ssa_name_with_loop_info): Restrict the
call to SCEV for irange supported types.
(fold_using_range::range_of_builtin_int_call): Convert to vrange.
* gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Same.
* tree-ssa-dom.cc (cprop_operand): Same.

gcc/gimple-range-fold.cc
gcc/gimple-range.cc
gcc/tree-ssa-dom.cc

index 0f815b50b9ace569c302e8f37b6616f8511bb503..6f907df5bf55f6073cd7e1ef5d0a2003a3c639f6 100644 (file)
@@ -1006,19 +1006,21 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call,
   switch (func)
     {
     case CFN_BUILT_IN_CONSTANT_P:
-      arg = gimple_call_arg (call, 0);
-      if (src.get_operand (r, arg) && r.singleton_p ())
-       {
-         r.set (build_one_cst (type), build_one_cst (type));
-         return true;
-       }
-      if (cfun->after_inlining)
-       {
-         r.set_zero (type);
-         // r.equiv_clear ();
-         return true;
-       }
-      break;
+      {
+       arg = gimple_call_arg (call, 0);
+       Value_Range tmp (TREE_TYPE (arg));
+       if (src.get_operand (tmp, arg) && tmp.singleton_p ())
+         {
+           r.set (build_one_cst (type), build_one_cst (type));
+           return true;
+         }
+       if (cfun->after_inlining)
+         {
+           r.set_zero (type);
+           return true;
+         }
+       break;
+      }
 
     case CFN_BUILT_IN_TOUPPER:
       {
@@ -1335,7 +1337,9 @@ fold_using_range::range_of_ssa_name_with_loop_info (irange &r, tree name,
 {
   gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
   tree min, max, type = TREE_TYPE (name);
-  if (bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
+  // FIXME: Remove the supports_p() once all this can handle floats, etc.
+  if (irange::supports_p (type)
+      && bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
     {
       if (TREE_CODE (min) != INTEGER_CST)
        {
index f3a46555f91cb21ef79e721a9c97f5e9e18b9484..3a9f0b07e79e9eb57554696c9a54b2143b0bef97 100644 (file)
@@ -422,12 +422,17 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
        {
          gcc_checking_assert (range_op_handler (stmt));
          tree op = gimple_range_operand2 (stmt);
-         Value_Range r (TREE_TYPE (name));
          if (op)
-           prefill_name (r, op);
+           {
+             Value_Range r (TREE_TYPE (op));
+             prefill_name (r, op);
+           }
          op = gimple_range_operand1 (stmt);
          if (op)
-           prefill_name (r, op);
+           {
+             Value_Range r (TREE_TYPE (op));
+             prefill_name (r, op);
+           }
        }
     }
   if (idx)
index 9b6520fd2dd0d3fc40b261d452c2581883e49709..2bc2c3db7d72fa7f7f6e39a8231552df8280351e 100644 (file)
@@ -1837,7 +1837,7 @@ cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query)
   val = SSA_NAME_VALUE (op);
   if (!val)
     {
-      int_range<2> r;
+      Value_Range r (TREE_TYPE (op));
       tree single;
       if (query->range_of_expr (r, op, stmt) && r.singleton_p (&single))
        val = single;