]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Also pre-process PHIs in range-of-stmt.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 29 Nov 2021 17:00:26 +0000 (12:00 -0500)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 1 Dec 2021 14:10:41 +0000 (09:10 -0500)
PR tree-optimization/103464
* gimple-range.cc (gimple_ranger::prefill_name): Process phis also.
(gimple_ranger::prefill_stmt_dependencies): Ditto.

gcc/gimple-range.cc

index 178a470a419bf508b22df885e311290ef96bc494..c8431a7180bd307b1f982d3e9e1eff3515d32bfc 100644 (file)
@@ -333,7 +333,7 @@ gimple_ranger::prefill_name (irange &r, tree name)
   if (!gimple_range_ssa_p (name))
     return;
   gimple *stmt = SSA_NAME_DEF_STMT (name);
-  if (!gimple_range_handler (stmt))
+  if (!gimple_range_handler (stmt) && !is_a<gphi *> (stmt))
     return;
 
   bool current;
@@ -356,8 +356,8 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
   gimple *stmt = SSA_NAME_DEF_STMT (ssa);
   gcc_checking_assert (stmt && gimple_bb (stmt));
 
-  // Only pre-process range-ops.
-  if (!gimple_range_handler (stmt))
+  // Only pre-process range-ops and phis.
+  if (!gimple_range_handler (stmt) && !is_a<gphi *> (stmt))
     return;
 
   // Mark where on the stack we are starting.
@@ -401,13 +401,22 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
          print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
        }
 
-      gcc_checking_assert (gimple_range_handler (stmt));
-      tree op = gimple_range_operand2 (stmt);
-      if (op)
-       prefill_name (r, op);
-      op = gimple_range_operand1 (stmt);
-      if (op)
-       prefill_name (r, op);
+      gphi *phi = dyn_cast <gphi *> (stmt);
+      if (phi)
+       {
+         for (unsigned x = 0; x < gimple_phi_num_args (phi); x++)
+           prefill_name (r, gimple_phi_arg_def (phi, x));
+       }
+      else
+       {
+         gcc_checking_assert (gimple_range_handler (stmt));
+         tree op = gimple_range_operand2 (stmt);
+         if (op)
+           prefill_name (r, op);
+         op = gimple_range_operand1 (stmt);
+         if (op)
+           prefill_name (r, op);
+       }
     }
   if (idx)
     tracer.trailer (idx, "ROS ", false, ssa, r);