]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/tree-parloops.c
* doc/extend.texi (Common Function Attributes): Clarify
[thirdparty/gcc.git] / gcc / tree-parloops.c
index 513305490c805abb6d283f293b2887a30bad8387..9de154e722f9542ebbe5abaad6da0c63d706ceaf 100644 (file)
@@ -1,5 +1,5 @@
 /* Loop autoparallelization.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Contributed by Sebastian Pop <pop@cri.ensmp.fr> 
    Zdenek Dvorak <dvorakz@suse.cz> and Razya Ladelsky <razya@il.ibm.com>.
 
@@ -238,7 +238,7 @@ reduction_phi (reduction_info_table_type *reduction_list, gimple *phi)
 {
   struct reduction_info tmpred, *red;
 
-  if (reduction_list->elements () == 0 || phi == NULL)
+  if (reduction_list->is_empty () || phi == NULL)
     return NULL;
 
   if (gimple_uid (phi) == (unsigned int)-1
@@ -1041,7 +1041,7 @@ create_phi_for_local_result (reduction_info **slot, struct loop *loop)
   gphi *new_phi;
   basic_block store_bb, continue_bb;
   tree local_res;
-  source_location locus;
+  location_t locus;
 
   /* STORE_BB is the block where the phi
      should be stored.  It is the destination of the loop exit.
@@ -1130,7 +1130,8 @@ create_call_for_reduction_1 (reduction_info **slot, struct clsn_data *clsn_data)
 
   tmp_load = create_tmp_var (TREE_TYPE (TREE_TYPE (addr)));
   tmp_load = make_ssa_name (tmp_load);
-  load = gimple_build_omp_atomic_load (tmp_load, addr);
+  load = gimple_build_omp_atomic_load (tmp_load, addr,
+                                      OMP_MEMORY_ORDER_RELAXED);
   SSA_NAME_DEF_STMT (tmp_load) = load;
   gsi = gsi_start_bb (new_bb);
   gsi_insert_after (&gsi, load, GSI_NEW_STMT);
@@ -1146,7 +1147,9 @@ create_call_for_reduction_1 (reduction_info **slot, struct clsn_data *clsn_data)
   name = force_gimple_operand_gsi (&gsi, x, true, NULL_TREE, true,
                                   GSI_CONTINUE_LINKING);
 
-  gsi_insert_after (&gsi, gimple_build_omp_atomic_store (name), GSI_NEW_STMT);
+  gimple *store = gimple_build_omp_atomic_store (name,
+                                                OMP_MEMORY_ORDER_RELAXED);
+  gsi_insert_after (&gsi, store, GSI_NEW_STMT);
   return 1;
 }
 
@@ -1387,7 +1390,7 @@ separate_decls_in_region (edge entry, edge exit,
            }
        }
 
-  if (name_copies.elements () == 0 && reduction_list->elements () == 0)
+  if (name_copies.is_empty () && reduction_list->is_empty ())
     {
       /* It may happen that there is nothing to copy (if there are only
          loop carried and external variables in the loop).  */
@@ -1404,7 +1407,7 @@ separate_decls_in_region (edge entry, edge exit,
       TYPE_NAME (type) = type_name;
 
       name_copies.traverse <tree, add_field_for_name> (type);
-      if (reduction_list && reduction_list->elements () > 0)
+      if (reduction_list && !reduction_list->is_empty ())
        {
          /* Create the fields for reductions.  */
          reduction_list->traverse <tree, add_field_for_reduction> (type);
@@ -1427,7 +1430,7 @@ separate_decls_in_region (edge entry, edge exit,
 
       /* Load the calculation from memory (after the join of the threads).  */
 
-      if (reduction_list && reduction_list->elements () > 0)
+      if (reduction_list && !reduction_list->is_empty ())
        {
          reduction_list
            ->traverse <struct clsn_data *, create_stores_for_reduction>
@@ -1495,6 +1498,7 @@ create_loop_fn (location_t loc)
   DECL_ARGUMENTS (decl) = t;
 
   allocate_struct_function (decl, false);
+  DECL_STRUCT_FUNCTION (decl)->last_clique = act_cfun->last_clique;
 
   /* The call to allocate_struct_function clobbers CFUN, so we need to restore
      it.  */
@@ -1987,7 +1991,7 @@ transform_to_exit_first_loop (struct loop *loop,
          PHI_RESULT of this phi is the resulting value of the reduction
          variable when exiting the loop.  */
 
-      if (reduction_list->elements () > 0)
+      if (!reduction_list->is_empty ())
        {
          struct reduction_info *red;
 
@@ -2128,7 +2132,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
   for (gphi_iterator gpi = gsi_start_phis (ex_bb);
        !gsi_end_p (gpi); gsi_next (&gpi))
     {
-      source_location locus;
+      location_t locus;
       gphi *phi = gpi.phi ();
       tree def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
       gimple *def_stmt = SSA_NAME_DEF_STMT (def);
@@ -2436,7 +2440,7 @@ gen_parallel_loop (struct loop *loop,
     }
 
   /* Generate initializations for reductions.  */
-  if (reduction_list->elements () > 0)
+  if (!reduction_list->is_empty ())
     reduction_list->traverse <struct loop *, initialize_reductions> (loop);
 
   /* Eliminate the references to local variables from the loop.  */
@@ -2472,7 +2476,7 @@ gen_parallel_loop (struct loop *loop,
     loc = gimple_location (cond_stmt);
   create_parallel_loop (loop, create_loop_fn (loc), arg_struct, new_arg_struct,
                        n_threads, loc, oacc_kernels_p);
-  if (reduction_list->elements () > 0)
+  if (!reduction_list->is_empty ())
     create_call_for_reduction (loop, reduction_list, &clsn_data);
 
   scev_reset ();
@@ -2592,10 +2596,6 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
   auto_vec<gphi *, 4> double_reduc_phis;
   auto_vec<gimple *, 4> double_reduc_stmts;
 
-  vec<stmt_vec_info> stmt_vec_infos;
-  stmt_vec_infos.create (50);
-  set_stmt_vec_info_vec (&stmt_vec_infos);
-
   vec_info_shared shared;
   simple_loop_info = vect_analyze_loop_form (loop, &shared);
   if (simple_loop_info == NULL)
@@ -2679,14 +2679,11 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
     }
 
  gather_done:
-  /* Release the claim on gimple_uid.  */
-  free_stmt_vec_infos (&stmt_vec_infos);
-
-  if (reduction_list->elements () == 0)
+  if (reduction_list->is_empty ())
     return;
 
   /* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
-     and free_stmt_vec_info_vec, we can set gimple_uid of reduc_phi stmts only
+     and delete simple_loop_info, we can set gimple_uid of reduc_phi stmts only
      now.  */
   basic_block bb;
   FOR_EACH_BB_FN (bb, cfun)
@@ -2799,6 +2796,14 @@ try_create_reduction_list (loop_p loop,
 
       if (!virtual_operand_p (val))
        {
+         if (TREE_CODE (val) != SSA_NAME)
+           {
+             if (dump_file && (dump_flags & TDF_DETAILS))
+               fprintf (dump_file,
+                        "  FAILED: exit PHI argument invariant.\n");
+             return false;
+           }
+
          if (dump_file && (dump_flags & TDF_DETAILS))
            {
              fprintf (dump_file, "phi is ");
@@ -2809,7 +2814,7 @@ try_create_reduction_list (loop_p loop,
              fprintf (dump_file,
                       "  checking if it is part of reduction pattern:\n");
            }
-         if (reduction_list->elements () == 0)
+         if (reduction_list->is_empty ())
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                fprintf (dump_file,
@@ -3083,7 +3088,7 @@ oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec<basic_block> region_bbs,
            continue;
          else if (!gimple_has_side_effects (stmt)
                   && !gimple_could_trap_p (stmt)
-                  && !stmt_could_throw_p (stmt)
+                  && !stmt_could_throw_p (cfun, stmt)
                   && !gimple_vdef (stmt)
                   && !gimple_vuse (stmt))
            continue;
@@ -3413,13 +3418,16 @@ parallelize_loops (bool oacc_kernels_p)
       changed = true;
       skip_loop = loop->inner;
 
-      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);
-      else
-       dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
-                        "parallelizing inner loop %d\n", loop->num);
+      if (dump_enabled_p ())
+       {
+         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);
+         else
+           dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
+                            "parallelizing inner loop %d\n", loop->num);
+       }
 
       gen_parallel_loop (loop, &reduction_list,
                         n_threads, &niter_desc, oacc_kernels_p);