[26/46] Make more use of dyn_cast in tree-vect*
[gcc.git] / gcc / tree-parloops.c
index c49f032b65515c42c7f39569ab333d7323dff866..513305490c805abb6d283f293b2887a30bad8387 100644 (file)
@@ -2570,15 +2570,14 @@ set_reduc_phi_uids (reduction_info **slot, void *data ATTRIBUTE_UNUSED)
   return 1;
 }
 
-/* Return true if the type of reduction performed by STMT is suitable
+/* Return true if the type of reduction performed by STMT_INFO is suitable
    for this pass.  */
 
 static bool
-valid_reduction_p (gimple *stmt)
+valid_reduction_p (stmt_vec_info stmt_info)
 {
   /* Parallelization would reassociate the operation, which isn't
      allowed for in-order reductions.  */
-  stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   vect_reduction_type reduc_type = STMT_VINFO_REDUC_TYPE (stmt_info);
   return reduc_type != FOLD_LEFT_REDUCTION;
 }
@@ -2615,10 +2614,11 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
       if (simple_iv (loop, loop, res, &iv, true))
        continue;
 
-      gimple *reduc_stmt
-       = vect_force_simple_reduction (simple_loop_info, phi,
+      stmt_vec_info reduc_stmt_info
+       = vect_force_simple_reduction (simple_loop_info,
+                                      simple_loop_info->lookup_stmt (phi),
                                       &double_reduc, true);
-      if (!reduc_stmt || !valid_reduction_p (reduc_stmt))
+      if (!reduc_stmt_info || !valid_reduction_p (reduc_stmt_info))
        continue;
 
       if (double_reduc)
@@ -2627,11 +2627,11 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
            continue;
 
          double_reduc_phis.safe_push (phi);
-         double_reduc_stmts.safe_push (reduc_stmt);
+         double_reduc_stmts.safe_push (reduc_stmt_info->stmt);
          continue;
        }
 
-      build_new_reduction (reduction_list, reduc_stmt, phi);
+      build_new_reduction (reduction_list, reduc_stmt_info->stmt, phi);
     }
   delete simple_loop_info;
 
@@ -2661,12 +2661,15 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
                             &iv, true))
                continue;
 
-             gimple *inner_reduc_stmt
-               = vect_force_simple_reduction (simple_loop_info, inner_phi,
+             stmt_vec_info inner_phi_info
+               = simple_loop_info->lookup_stmt (inner_phi);
+             stmt_vec_info inner_reduc_stmt_info
+               = vect_force_simple_reduction (simple_loop_info,
+                                              inner_phi_info,
                                               &double_reduc, true);
              gcc_assert (!double_reduc);
-             if (inner_reduc_stmt == NULL
-                 || !valid_reduction_p (inner_reduc_stmt))
+             if (!inner_reduc_stmt_info
+                 || !valid_reduction_p (inner_reduc_stmt_info))
                continue;
 
              build_new_reduction (reduction_list, double_reduc_stmts[i], phi);
@@ -3286,7 +3289,6 @@ parallelize_loops (bool oacc_kernels_p)
   struct tree_niter_desc niter_desc;
   struct obstack parloop_obstack;
   HOST_WIDE_INT estimated;
-  source_location loop_loc;
 
   /* Do not parallelize loops in the functions created by parallelization.  */
   if (!oacc_kernels_p
@@ -3411,7 +3413,7 @@ parallelize_loops (bool oacc_kernels_p)
       changed = true;
       skip_loop = loop->inner;
 
-      loop_loc = find_loop_location (loop);
+      dump_user_location_t loop_loc = find_loop_location (loop);
       if (loop->inner)
        dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
                         "parallelizing outer loop %d\n", loop->num);