pr60092.c: Remove default dg-skip-if arguments.
[gcc.git] / gcc / omp-low.c
index 97092dd089479993de65b535ec9a404c894430da..7cc398ea5c099d975ac366de46fd6cde3021f0b5 100644 (file)
@@ -3,7 +3,7 @@
    marshalling to implement data sharing and copying clauses.
    Contributed by Diego Novillo <dnovillo@redhat.com>
 
-   Copyright (C) 2005-2013 Free Software Foundation, Inc.
+   Copyright (C) 2005-2014 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -1220,8 +1220,6 @@ omp_copy_decl (tree var, copy_body_data *cb)
 }
 
 
-/* Return the parallel region associated with STMT.  */
-
 /* Debugging dumps for parallel regions.  */
 void dump_omp_region (FILE *, struct omp_region *, int);
 void debug_omp_region (struct omp_region *);
@@ -1822,8 +1820,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 
 /* Create a new name for omp child function.  Returns an identifier.  */
 
-static GTY(()) unsigned int tmp_ompfn_id_num;
-
 static tree
 create_omp_child_function_name (bool task_copy)
 {
@@ -2933,6 +2929,7 @@ omp_max_vf (void)
 {
   if (!optimize
       || optimize_debug
+      || !flag_tree_loop_optimize
       || (!flag_tree_loop_vectorize
          && (global_options_set.x_flag_tree_loop_vectorize
               || global_options_set.x_flag_tree_vectorize)))
@@ -3675,7 +3672,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
       /* Don't add any barrier for #pragma omp simd or
         #pragma omp distribute.  */
       if (gimple_code (ctx->stmt) != GIMPLE_OMP_FOR
-         || gimple_omp_for_kind (ctx->stmt) & GF_OMP_FOR_KIND_FOR)
+         || gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_FOR)
        gimple_seq_add_stmt (ilist, build_omp_barrier (NULL_TREE));
     }
 
@@ -6843,6 +6840,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
       if ((flag_tree_loop_vectorize
           || (!global_options_set.x_flag_tree_loop_vectorize
                && !global_options_set.x_flag_tree_vectorize))
+         && flag_tree_loop_optimize
          && loop->safelen > 1)
        {
          loop->force_vect = true;
@@ -7540,12 +7538,21 @@ expand_omp_atomic_pipeline (basic_block load_bb, basic_block store_bb,
       loadedi = loaded_val;
     }
 
+  fncode = (enum built_in_function) (BUILT_IN_ATOMIC_LOAD_N + index + 1);
+  tree loaddecl = builtin_decl_explicit (fncode);
+  if (loaddecl)
+    initial
+      = fold_convert (TREE_TYPE (TREE_TYPE (iaddr)),
+                     build_call_expr (loaddecl, 2, iaddr,
+                                      build_int_cst (NULL_TREE,
+                                                     MEMMODEL_RELAXED)));
+  else
+    initial = build2 (MEM_REF, TREE_TYPE (TREE_TYPE (iaddr)), iaddr,
+                     build_int_cst (TREE_TYPE (iaddr), 0));
+
   initial
-    = force_gimple_operand_gsi (&si,
-                               build2 (MEM_REF, TREE_TYPE (TREE_TYPE (iaddr)),
-                                       iaddr,
-                                       build_int_cst (TREE_TYPE (iaddr), 0)),
-                               true, NULL_TREE, true, GSI_SAME_STMT);
+    = force_gimple_operand_gsi (&si, initial, true, NULL_TREE, true,
+                               GSI_SAME_STMT);
 
   /* Move the value to the LOADEDI temporary.  */
   if (gimple_in_ssa_p (cfun))
@@ -8323,7 +8330,7 @@ static bool
 gate_expand_omp (void)
 {
   return ((flag_openmp != 0 || flag_openmp_simd != 0
-          || flag_enable_cilkplus != 0) && !seen_error ());
+          || flag_cilkplus != 0) && !seen_error ());
 }
 
 namespace {
@@ -8941,8 +8948,14 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   if (!gimple_seq_empty_p (omp_for_body)
       && gimple_code (gimple_seq_first_stmt (omp_for_body)) == GIMPLE_BIND)
     {
-      tree vars = gimple_bind_vars (gimple_seq_first_stmt (omp_for_body));
+      gimple inner_bind = gimple_seq_first_stmt (omp_for_body);
+      tree vars = gimple_bind_vars (inner_bind);
       gimple_bind_append_vars (new_stmt, vars);
+      /* bind_vars/BLOCK_VARS are being moved to new_stmt/block, don't
+        keep them on the inner_bind and it's block.  */
+      gimple_bind_set_vars (inner_bind, NULL_TREE);
+      if (gimple_bind_block (inner_bind))
+       BLOCK_VARS (gimple_bind_block (inner_bind)) = NULL_TREE;
     }
 
   if (gimple_omp_for_combined_into_p (stmt))
@@ -9052,7 +9065,7 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 }
 
 /* Callback for walk_stmts.  Check if the current statement only contains
-   GIMPLE_OMP_FOR or GIMPLE_OMP_PARALLEL.  */
+   GIMPLE_OMP_FOR or GIMPLE_OMP_SECTIONS.  */
 
 static tree
 check_combined_parallel (gimple_stmt_iterator *gsi_p,
@@ -9801,6 +9814,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
                                        TREE_VEC_ELT (t, 1)),
                                &initlist, true, NULL_TREE);
          gimple_seq_add_seq (&ilist, initlist);
+
+         tree clobber = build_constructor (TREE_TYPE (TREE_VEC_ELT (t, 1)),
+                                           NULL);
+         TREE_THIS_VOLATILE (clobber) = 1;
+         gimple_seq_add_stmt (&olist,
+                              gimple_build_assign (TREE_VEC_ELT (t, 1),
+                                                   clobber));
        }
 
       tree clobber = build_constructor (ctx->record_type, NULL);
@@ -10116,9 +10136,8 @@ lower_omp (gimple_seq *body, omp_context *ctx)
   gimple_stmt_iterator gsi;
   for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi))
     lower_omp_1 (&gsi, ctx);
-  /* Inside target region we haven't called fold_stmt during gimplification,
-     because it can break code by adding decl references that weren't in the
-     source.  Call fold_stmt now.  */
+  /* During gimplification, we have not always invoked fold_stmt
+     (gimplify.c:maybe_fold_stmt); call it now.  */
   if (target_nesting_level)
     for (gsi = gsi_start (*body); !gsi_end_p (gsi); gsi_next (&gsi))
       fold_stmt (&gsi);
@@ -10134,7 +10153,7 @@ execute_lower_omp (void)
 
   /* This pass always runs, to provide PROP_gimple_lomp.
      But there is nothing to do unless -fopenmp is given.  */
-  if (flag_openmp == 0 && flag_openmp_simd == 0 && flag_enable_cilkplus == 0)
+  if (flag_openmp == 0 && flag_openmp_simd == 0 && flag_cilkplus == 0)
     return 0;
 
   all_contexts = splay_tree_new (splay_tree_compare_pointers, 0,
@@ -10253,12 +10272,13 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p,
 #endif
 
   bool cilkplus_block = false;
-  if (flag_enable_cilkplus)
+  if (flag_cilkplus)
     {
       if ((branch_ctx
           && gimple_code (branch_ctx) == GIMPLE_OMP_FOR
           && gimple_omp_for_kind (branch_ctx) == GF_OMP_FOR_KIND_CILKSIMD)
-         || (gimple_code (label_ctx) == GIMPLE_OMP_FOR
+         || (label_ctx
+             && gimple_code (label_ctx) == GIMPLE_OMP_FOR
              && gimple_omp_for_kind (label_ctx) == GF_OMP_FOR_KIND_CILKSIMD))
        cilkplus_block = true;
     }
@@ -10444,7 +10464,8 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 /* Called from tree-cfg.c::make_edges to create cfg edges for all GIMPLE_OMP
    codes.  */
 bool
-make_gimple_omp_edges (basic_block bb, struct omp_region **region)
+make_gimple_omp_edges (basic_block bb, struct omp_region **region,
+                      int *region_idx)
 {
   gimple last = last_stmt (bb);
   enum gimple_code code = gimple_code (last);
@@ -10551,7 +10572,13 @@ make_gimple_omp_edges (basic_block bb, struct omp_region **region)
     }
 
   if (*region != cur_region)
-    *region = cur_region;
+    {
+      *region = cur_region;
+      if (cur_region)
+       *region_idx = cur_region->entry->index;
+      else
+       *region_idx = 0;
+    }
 
   return fallthru;
 }
@@ -10582,7 +10609,7 @@ diagnose_omp_structured_block_errors (void)
 static bool
 gate_diagnose_omp_blocks (void)
 {
-  return flag_openmp || flag_enable_cilkplus;
+  return flag_openmp || flag_cilkplus;
 }
 
 namespace {
@@ -10637,7 +10664,7 @@ simd_clone_struct_alloc (int nargs)
   size_t len = (sizeof (struct cgraph_simd_clone)
                + nargs * sizeof (struct cgraph_simd_clone_arg));
   clone_info = (struct cgraph_simd_clone *)
-              ggc_internal_cleared_alloc_stat (len PASS_MEM_STAT);
+              ggc_internal_cleared_alloc (len);
   return clone_info;
 }
 
@@ -10648,7 +10675,8 @@ simd_clone_struct_copy (struct cgraph_simd_clone *to,
                        struct cgraph_simd_clone *from)
 {
   memcpy (to, from, (sizeof (struct cgraph_simd_clone)
-                    + from->nargs * sizeof (struct cgraph_simd_clone_arg)));
+                    + ((from->nargs - from->inbranch)
+                       * sizeof (struct cgraph_simd_clone_arg))));
 }
 
 /* Return vector of parameter types of function FNDECL.  This uses
@@ -10691,8 +10719,8 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses,
      be cloned have a distinctive artificial label in addition to "omp
      declare simd".  */
   bool cilk_clone
-    = (flag_enable_cilkplus
-       && lookup_attribute ("cilk plus elemental",
+    = (flag_cilkplus
+       && lookup_attribute ("cilk simd function",
                            DECL_ATTRIBUTES (node->decl)));
 
   /* Allocate one more than needed just in case this is an in-branch
@@ -11541,7 +11569,7 @@ simd_clone_adjust (struct cgraph_node *node)
        unsigned int alignment = node->simdclone->args[i].alignment;
        tree orig_arg = node->simdclone->args[i].orig_arg;
        tree def = ssa_default_def (cfun, orig_arg);
-       if (!has_zero_uses (def))
+       if (def && !has_zero_uses (def))
          {
            tree fn = builtin_decl_explicit (BUILT_IN_ASSUME_ALIGNED);
            gimple_seq seq = NULL;
@@ -11591,7 +11619,7 @@ simd_clone_adjust (struct cgraph_node *node)
        tree def = ssa_default_def (cfun, orig_arg);
        gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (orig_arg))
                    || POINTER_TYPE_P (TREE_TYPE (orig_arg)));
-       if (!has_zero_uses (def))
+       if (def && !has_zero_uses (def))
          {
            iter1 = make_ssa_name (orig_arg, NULL);
            iter2 = make_ssa_name (orig_arg, NULL);
@@ -11681,7 +11709,6 @@ expand_simd_clones (struct cgraph_node *node)
          if (i != 0)
            {
              clone = simd_clone_struct_alloc (clone_info->nargs
-                                              - clone_info->inbranch
                                               + ((i & 1) != 0));
              simd_clone_struct_copy (clone, clone_info);
              /* Undo changes targetm.simd_clone.compute_vecsize_and_simdlen
@@ -11776,7 +11803,7 @@ public:
 
   /* opt_pass methods: */
   bool gate () { return ((flag_openmp || flag_openmp_simd
-                         || flag_enable_cilkplus || (in_lto_p && !flag_wpa))
+                         || flag_cilkplus || (in_lto_p && !flag_wpa))
                         && (targetm.simd_clone.compute_vecsize_and_simdlen
                             != NULL)); }
   unsigned int execute () { return ipa_omp_simd_clone (); }