public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [gomp4.1] Handle linear clause modifiers in declare simd
Date: Wed, 01 Jul 2015 10:55:00 -0000	[thread overview]
Message-ID: <20150701105538.GT10247@tucnak.redhat.com> (raw)

Hi!

I've committed following patch, which per the new ABI additions
mangles and handles the various new linear clause modifiers in
declare simd functions.  The vectorizer side is not done yet,
for now we'll never use SIMD_CLONE_ARG_TYPE_LINEAR_*_CONSTANT_STEP
in vectorized routines, that waits first for resolution of
PR66718.

2015-07-01  Jakub Jelinek  <jakub@redhat.com>

	* cgraph.h (enum cgraph_simd_clone_arg_type): Add
	SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
	SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
	and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP.
	(struct cgraph_simd_clone_arg): Adjust comment.
	* omp-low.c (simd_clone_clauses_extract): Honor
	OMP_CLAUSE_LINEAR_KIND.
	(simd_clone_mangle): Mangle the various linear kinds
	per the new ABI.
	(simd_clone_adjust_argument_types): Handle
	SIMD_CLONE_ARG_TYPE_LINEAR_*_CONSTANT_STEP.
	(simd_clone_init_simd_arrays): Don't do anything
	for uval.
	(simd_clone_adjust): Handle
	SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like
	SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP.
	Handle SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP.
c/
	* c-tree.h (c_finish_omp_clauses): Add declare_simd argument.
	* c-parser.c (c_parser_omp_clause_linear): Don't handle uval
	modifier in C.
	(c_parser_omp_all_clauses): If mask includes uniform clause,
	pass true to c_finish_omp_clauses' declare_simd.
	* c-typeck.c (c_finish_omp_clauses): Add declare_simd argument,
	don't set need_implicitly_determined if it is true.
cp/
	* cp-tree.h (finish_omp_clauses): Add declare_simd argument.
	* parser.c (cp_parser_omp_all_clauses): If mask includes uniform
	clause, pass true to finish_omp_clauses' declare_simd.
	* pt.c (apply_late_template_attributes): Pass true to
	finish_omp_clauses' declare_simd.
	* semantics.c (finish_omp_clauses): Add declare_simd argument,
	don't set need_implicitly_determined if it is true.
testsuite/
	* gcc.dg/gomp/clause-1.c (foo): Add some linear clause tests.
	* g++.dg/gomp/clause-3.C (foo): Likewise.
	* g++.dg/gomp/declare-simd-3.C: New test.

--- gcc/cgraph.h.jj	2015-06-30 14:24:39.515064819 +0200
+++ gcc/cgraph.h	2015-06-30 15:12:25.534761008 +0200
@@ -645,8 +645,14 @@ enum cgraph_simd_clone_arg_type
 {
   SIMD_CLONE_ARG_TYPE_VECTOR,
   SIMD_CLONE_ARG_TYPE_UNIFORM,
+  /* These are only for integer/pointer arguments passed by value.  */
   SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
   SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
+  /* These 3 are only for reference type arguments or arguments passed
+     by reference.  */
+  SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
+  SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
+  SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP,
   SIMD_CLONE_ARG_TYPE_MASK
 };
 
@@ -686,7 +692,7 @@ struct GTY(()) cgraph_simd_clone_arg {
      variable), uniform, or vector.  */
   enum cgraph_simd_clone_arg_type arg_type;
 
-  /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP this is
+  /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_*CONSTANT_STEP this is
      the constant linear step, if arg_type is
      SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP, this is index of
      the uniform argument holding the step, otherwise 0.  */
--- gcc/omp-low.c.jj	2015-06-30 14:24:56.618812148 +0200
+++ gcc/omp-low.c	2015-06-30 17:35:21.700736990 +0200
@@ -14092,8 +14092,29 @@ simd_clone_clauses_extract (struct cgrap
 		  }
 		else
 		  {
-		    clone_info->args[argno].arg_type
-		      = SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP;
+		    enum cgraph_simd_clone_arg_type arg_type;
+		    if (TREE_CODE (args[argno]) == REFERENCE_TYPE)
+		      switch (OMP_CLAUSE_LINEAR_KIND (t))
+			{
+			case OMP_CLAUSE_LINEAR_REF:
+			  arg_type
+			    = SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP;
+			  break;
+			case OMP_CLAUSE_LINEAR_UVAL:
+			  arg_type
+			    = SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP;
+			  break;
+			case OMP_CLAUSE_LINEAR_VAL:
+			case OMP_CLAUSE_LINEAR_DEFAULT:
+			  arg_type
+			    = SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP;
+			  break;
+			default:
+			  gcc_unreachable ();
+			}
+		    else
+		      arg_type = SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP;
+		    clone_info->args[argno].arg_type = arg_type;
 		    clone_info->args[argno].linear_step = tree_to_shwi (step);
 		  }
 	      }
@@ -14195,12 +14216,25 @@ simd_clone_mangle (struct cgraph_node *n
     {
       struct cgraph_simd_clone_arg arg = clone_info->args[n];
 
-      if (arg.arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
-	pp_character (&pp, 'u');
-      else if (arg.arg_type == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP)
+      switch (arg.arg_type)
 	{
-	  gcc_assert (arg.linear_step != 0);
+	case SIMD_CLONE_ARG_TYPE_UNIFORM:
+	  pp_character (&pp, 'u');
+	  break;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP:
 	  pp_character (&pp, 'l');
+	  goto mangle_linear;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP:
+	  pp_character (&pp, 'R');
+	  goto mangle_linear;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP:
+	  pp_character (&pp, 'L');
+	  goto mangle_linear;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP:
+	  pp_character (&pp, 'U');
+	  goto mangle_linear;
+	mangle_linear:
+	  gcc_assert (arg.linear_step != 0);
 	  if (arg.linear_step > 1)
 	    pp_unsigned_wide_integer (&pp, arg.linear_step);
 	  else if (arg.linear_step < 0)
@@ -14209,14 +14243,14 @@ simd_clone_mangle (struct cgraph_node *n
 	      pp_unsigned_wide_integer (&pp, (-(unsigned HOST_WIDE_INT)
 					      arg.linear_step));
 	    }
-	}
-      else if (arg.arg_type == SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP)
-	{
+	  break;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP:
 	  pp_character (&pp, 's');
 	  pp_unsigned_wide_integer (&pp, arg.linear_step);
+	  break;
+	default:
+	  pp_character (&pp, 'v');
 	}
-      else
-	pp_character (&pp, 'v');
       if (arg.alignment)
 	{
 	  pp_character (&pp, 'a');
@@ -14394,13 +14428,22 @@ simd_clone_adjust_argument_types (struct
       node->simdclone->args[i].orig_arg = node->definition ? parm : NULL_TREE;
       node->simdclone->args[i].orig_type = parm_type;
 
-      if (node->simdclone->args[i].arg_type != SIMD_CLONE_ARG_TYPE_VECTOR)
+      switch (node->simdclone->args[i].arg_type)
 	{
+	default:
 	  /* No adjustment necessary for scalar arguments.  */
 	  adj.op = IPA_PARM_OP_COPY;
-	}
-      else
-	{
+	  break;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP:
+	  if (node->definition)
+	    node->simdclone->args[i].simd_array
+	      = create_tmp_simd_array (IDENTIFIER_POINTER (DECL_NAME (parm)),
+				       TREE_TYPE (parm_type),
+				       node->simdclone->simdlen);
+	  adj.op = IPA_PARM_OP_COPY;
+	  break;
+	case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP:
+	case SIMD_CLONE_ARG_TYPE_VECTOR:
 	  if (INTEGRAL_TYPE_P (parm_type) || POINTER_TYPE_P (parm_type))
 	    veclen = node->simdclone->vecsize_int;
 	  else
@@ -14532,7 +14575,8 @@ simd_clone_init_simd_arrays (struct cgra
        arg;
        arg = DECL_CHAIN (arg), i++, j++)
     {
-      if (adjustments[j].op == IPA_PARM_OP_COPY)
+      if (adjustments[j].op == IPA_PARM_OP_COPY
+	  || POINTER_TYPE_P (TREE_TYPE (arg)))
 	continue;
 
       node->simdclone->args[i].vector_arg = arg;
@@ -15022,8 +15066,10 @@ simd_clone_adjust (struct cgraph_node *n
 		  SET_USE (use_p, repl);
 	  }
       }
-    else if (node->simdclone->args[i].arg_type
-	     == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP)
+    else if ((node->simdclone->args[i].arg_type
+	      == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP)
+	     || (node->simdclone->args[i].arg_type
+		 == SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP))
       {
 	tree orig_arg = node->simdclone->args[i].orig_arg;
 	gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (orig_arg))
@@ -15082,6 +15128,78 @@ simd_clone_adjust (struct cgraph_node *n
 		    SET_USE (use_p, iter1);
 	  }
       }
+    else if (node->simdclone->args[i].arg_type
+	     == SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP)
+      {
+	tree orig_arg = node->simdclone->args[i].orig_arg;
+	tree def = ssa_default_def (cfun, orig_arg);
+	gcc_assert (!TREE_ADDRESSABLE (orig_arg)
+		    && TREE_CODE (TREE_TYPE (orig_arg)) == REFERENCE_TYPE);
+	if (def && !has_zero_uses (def))
+	  {
+	    tree rtype = TREE_TYPE (TREE_TYPE (orig_arg));
+	    iter1 = make_ssa_name (orig_arg);
+	    iter2 = make_ssa_name (orig_arg);
+	    tree iter3 = make_ssa_name (rtype);
+	    tree iter4 = make_ssa_name (rtype);
+	    tree iter5 = make_ssa_name (rtype);
+	    gsi = gsi_after_labels (entry_bb);
+	    gimple load
+	      = gimple_build_assign (iter3, build_simple_mem_ref (def));
+	    gsi_insert_before (&gsi, load, GSI_NEW_STMT);
+
+	    tree array = node->simdclone->args[i].simd_array;
+	    TREE_ADDRESSABLE (array) = 1;
+	    tree ptr = build_fold_addr_expr (array);
+	    phi = create_phi_node (iter1, body_bb);
+	    add_phi_arg (phi, ptr, preheader_edge, UNKNOWN_LOCATION);
+	    add_phi_arg (phi, iter2, latch_edge, UNKNOWN_LOCATION);
+	    g = gimple_build_assign (iter2, POINTER_PLUS_EXPR, iter1,
+				     TYPE_SIZE_UNIT (TREE_TYPE (iter3)));
+	    gsi = gsi_last_bb (incr_bb);
+	    gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+
+	    phi = create_phi_node (iter4, body_bb);
+	    add_phi_arg (phi, iter3, preheader_edge, UNKNOWN_LOCATION);
+	    add_phi_arg (phi, iter5, latch_edge, UNKNOWN_LOCATION);
+	    enum tree_code code = INTEGRAL_TYPE_P (TREE_TYPE (iter3))
+				  ? PLUS_EXPR : POINTER_PLUS_EXPR;
+	    tree addtype = INTEGRAL_TYPE_P (TREE_TYPE (iter3))
+			   ? TREE_TYPE (iter3) : sizetype;
+	    tree addcst
+	      = build_int_cst (addtype, node->simdclone->args[i].linear_step);
+	    g = gimple_build_assign (iter5, code, iter4, addcst);
+	    gsi = gsi_last_bb (incr_bb);
+	    gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+
+	    g = gimple_build_assign (build_simple_mem_ref (iter1), iter4);
+	    gsi = gsi_after_labels (body_bb);
+	    gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+
+	    imm_use_iterator iter;
+	    use_operand_p use_p;
+	    gimple use_stmt;
+	    FOR_EACH_IMM_USE_STMT (use_stmt, iter, def)
+	      if (use_stmt == load)
+		continue;
+	      else
+		FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+		  SET_USE (use_p, iter1);
+
+	    if (!TYPE_READONLY (rtype))
+	      {
+		tree v = make_ssa_name (rtype);
+		tree aref = build4 (ARRAY_REF, rtype, array,
+				    size_zero_node, NULL_TREE,
+				    NULL_TREE);
+		gsi = gsi_after_labels (new_exit_bb);
+		g = gimple_build_assign (v, aref);
+		gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+		g = gimple_build_assign (build_simple_mem_ref (def), v);
+		gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+	      }
+	  }
+      }
 
   calculate_dominance_info (CDI_DOMINATORS);
   add_loop (loop, loop->header->loop_father);
--- gcc/c/c-tree.h.jj	2015-06-17 21:01:53.000000000 +0200
+++ gcc/c/c-tree.h	2015-06-30 16:36:04.400102700 +0200
@@ -649,7 +649,7 @@ extern tree c_begin_omp_task (void);
 extern tree c_finish_omp_task (location_t, tree, tree);
 extern void c_finish_omp_cancel (location_t, tree);
 extern void c_finish_omp_cancellation_point (location_t, tree);
-extern tree c_finish_omp_clauses (tree);
+extern tree c_finish_omp_clauses (tree, bool = false);
 extern tree c_build_va_arg (location_t, tree, tree);
 extern tree c_finish_transaction (location_t, tree, int);
 extern bool c_tree_equal (tree, tree);
--- gcc/c/c-parser.c.jj	2015-06-30 14:24:37.319097260 +0200
+++ gcc/c/c-parser.c	2015-06-30 16:37:12.193109783 +0200
@@ -11532,8 +11532,6 @@ c_parser_omp_clause_linear (c_parser *pa
       const char *p = IDENTIFIER_POINTER (tok->value);
       if (strcmp ("val", p) == 0)
 	kind = OMP_CLAUSE_LINEAR_VAL;
-      else if (strcmp ("uval", p) == 0)
-	kind = OMP_CLAUSE_LINEAR_UVAL;
       if (c_parser_peek_2nd_token (parser)->type != CPP_OPEN_PAREN)
 	kind = OMP_CLAUSE_LINEAR_DEFAULT;
       if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
@@ -12411,7 +12409,11 @@ c_parser_omp_all_clauses (c_parser *pars
   c_parser_skip_to_pragma_eol (parser);
 
   if (finish_p)
-    return c_finish_omp_clauses (clauses);
+    {
+      if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0)
+	return c_finish_omp_clauses (clauses, true);
+      return c_finish_omp_clauses (clauses);
+    }
 
   return clauses;
 }
--- gcc/c/c-typeck.c.jj	2015-06-30 14:27:47.000000000 +0200
+++ gcc/c/c-typeck.c	2015-06-30 16:35:38.402483469 +0200
@@ -12098,7 +12098,7 @@ c_find_omp_placeholder_r (tree *tp, int
    Remove any elements from the list that are invalid.  */
 
 tree
-c_finish_omp_clauses (tree clauses)
+c_finish_omp_clauses (tree clauses, bool declare_simd)
 {
   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   bitmap_head aligned_head;
@@ -12362,6 +12362,8 @@ c_finish_omp_clauses (tree clauses)
 	  goto check_dup_generic;
 
 	case OMP_CLAUSE_LINEAR:
+	  if (!declare_simd)
+	    need_implicitly_determined = true;
 	  t = OMP_CLAUSE_DECL (c);
 	  if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
 	      && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
--- gcc/cp/cp-tree.h.jj	2015-06-30 14:25:24.000000000 +0200
+++ gcc/cp/cp-tree.h	2015-06-30 16:23:12.616408072 +0200
@@ -5998,7 +5998,7 @@ extern void note_decl_for_pch			(tree);
 extern tree omp_reduction_id			(enum tree_code, tree, tree);
 extern tree cp_remove_omp_priv_cleanup_stmt	(tree *, int *, void *);
 extern void cp_check_omp_declare_reduction	(tree);
-extern tree finish_omp_clauses			(tree, bool);
+extern tree finish_omp_clauses			(tree, bool, bool = false);
 extern tree push_omp_privatization_clauses	(bool);
 extern void pop_omp_privatization_clauses	(tree);
 extern void save_omp_privatization_clauses	(vec<tree> &);
--- gcc/cp/parser.c.jj	2015-06-30 14:25:22.000000000 +0200
+++ gcc/cp/parser.c	2015-06-30 16:28:58.552339799 +0200
@@ -29969,7 +29969,12 @@ cp_parser_omp_all_clauses (cp_parser *pa
   if (!(flag_cilkplus && pragma_tok == NULL))
     cp_parser_skip_to_pragma_eol (parser, pragma_tok);
   if (finish_p)
-    return finish_omp_clauses (clauses, true);
+    {
+      if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0)
+	return finish_omp_clauses (clauses, false, true);
+      else
+	return finish_omp_clauses (clauses, true);
+    }
   return clauses;
 }
 
--- gcc/cp/pt.c.jj	2015-06-30 14:25:18.000000000 +0200
+++ gcc/cp/pt.c	2015-06-30 16:29:58.532461311 +0200
@@ -9074,7 +9074,7 @@ apply_late_template_attributes (tree *de
 		  clauses = tsubst_omp_clauses (clauses, true, false, args,
 						complain, in_decl);
 		  c_omp_declare_simd_clauses_to_decls (*decl_p, clauses);
-		  clauses = finish_omp_clauses (clauses, false);
+		  clauses = finish_omp_clauses (clauses, false, true);
 		  tree parms = DECL_ARGUMENTS (*decl_p);
 		  clauses
 		    = c_omp_declare_simd_clauses_to_numbers (parms, clauses);
--- gcc/cp/semantics.c.jj	2015-06-30 14:25:19.621472332 +0200
+++ gcc/cp/semantics.c	2015-06-30 16:25:23.769485575 +0200
@@ -5495,7 +5495,7 @@ finish_omp_reduction_clause (tree c, boo
    Remove any elements from the list that are invalid.  */
 
 tree
-finish_omp_clauses (tree clauses, bool allow_fields)
+finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
 {
   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   bitmap_head aligned_head;
@@ -5563,12 +5563,14 @@ finish_omp_clauses (tree clauses, bool a
 	  if (!type_dependent_expression_p (t))
 	    {
 	      tree type = TREE_TYPE (t);
-	      if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
+	      if ((OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
+		   || OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL)
 		  && TREE_CODE (type) != REFERENCE_TYPE)
 		{
-		  error ("linear clause with %<ref%> modifier applied to "
+		  error ("linear clause with %qs modifier applied to "
 			 "non-reference variable with %qT type",
-			 TREE_TYPE (t));
+			 OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF
+			 ? "ref" : "uval", TREE_TYPE (t));
 		  remove = true;
 		  break;
 		}
@@ -5611,12 +5613,17 @@ finish_omp_clauses (tree clauses, bool a
 		    type = TREE_TYPE (type);
 		  if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF)
 		    {
-		      type = TREE_TYPE (OMP_CLAUSE_DECL (c));
-		      t = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
-					    sizetype, t);
+		      type = build_pointer_type (type);
+		      tree d = fold_convert (type, OMP_CLAUSE_DECL (c));
+		      t = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
+					   d, t);
 		      t = fold_build2_loc (OMP_CLAUSE_LOCATION (c),
-					   MULT_EXPR, sizetype, t,
-					   TYPE_SIZE_UNIT (type));
+					   MINUS_EXPR, sizetype, t, d);
+		      if (t == error_mark_node)
+			{
+			  remove = true;
+			  break;
+			}
 		    }
 		  else if (TREE_CODE (type) == POINTER_TYPE)
 		    {
@@ -6357,9 +6364,12 @@ finish_omp_clauses (tree clauses, bool a
 	  need_implicitly_determined = true;
 	  break;
 	case OMP_CLAUSE_REDUCTION:
-	case OMP_CLAUSE_LINEAR:
 	  need_implicitly_determined = true;
 	  break;
+	case OMP_CLAUSE_LINEAR:
+	  if (!declare_simd)
+	    need_implicitly_determined = true;
+	  break;
 	case OMP_CLAUSE_COPYPRIVATE:
 	  need_copy_assignment = true;
 	  break;
--- gcc/testsuite/gcc.dg/gomp/clause-1.c.jj	2015-06-09 20:00:25.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/clause-1.c	2015-06-30 17:21:45.253018384 +0200
@@ -34,6 +34,9 @@ foo (int x)
 #pragma omp p for lastprivate (x, x) /* { dg-error "more than once" } */
   for (i = 0; i < 10; i++)
     ;
+#pragma omp p for linear (x, x) /* { dg-error "more than once" } */
+  for (i = 0; i < 10; i++)
+    ;
 #pragma omp single private (x) copyprivate (x) /* { dg-error "more than" } */
     ;
 #pragma omp p shared (bar) /* { dg-error "is not a variable" } */
@@ -80,6 +83,9 @@ foo (int x)
     ;
 #pragma omp p reduction (*:t) /* { dg-error "predetermined 'threadprivate" } */
     ;
+#pragma omp p for linear (t) /* { dg-error "predetermined 'threadprivate" } */
+  for (i = 0; i < 10; i++)
+    ;
 #pragma omp p shared (c) /* { dg-error "predetermined 'shared'" } */
     ;
 #pragma omp p private (c) /* { dg-error "predetermined 'shared'" } */
@@ -91,4 +97,7 @@ foo (int x)
     ;
 #pragma omp p reduction (*:c) /* { dg-error "predetermined 'shared'" } */
     ;
+#pragma omp p for linear (c) /* { dg-error "predetermined 'shared'" } */
+  for (i = 0; i < 10; i++)
+    ;
 }
--- gcc/testsuite/g++.dg/gomp/clause-3.C.jj	2015-06-09 20:01:12.000000000 +0200
+++ gcc/testsuite/g++.dg/gomp/clause-3.C	2015-06-30 17:18:16.537087095 +0200
@@ -34,6 +34,9 @@ foo (int x)
 #pragma omp p for lastprivate (x, x) // { dg-error "more than once" }
   for (i = 0; i < 10; i++)
     ;
+#pragma omp p for linear (x, x) // { dg-error "more than once" }
+  for (i = 0; i < 10; i++)
+    ;
 #pragma omp single private (x) copyprivate (x) // { dg-error "more than once" }
     ;
 #pragma omp p shared (bar) // { dg-error "is not a variable" }
@@ -80,6 +83,9 @@ foo (int x)
     ;
 #pragma omp p reduction (*:t) // { dg-error "predetermined 'threadprivate'" }
     ;
+#pragma omp p for linear (t) // { dg-error "predetermined 'threadprivate'" }
+  for (i = 0; i < 10; i++)
+    ;
 #pragma omp p shared (c) // { dg-error "predetermined 'shared'" }
     ;
 #pragma omp p private (c) // { dg-error "predetermined 'shared'" }
@@ -91,4 +97,7 @@ foo (int x)
     ;
 #pragma omp p reduction (*:c) // { dg-error "predetermined 'shared'" }
     ;
+#pragma omp p for linear (c:2) // { dg-error "predetermined 'shared'" }
+  for (i = 0; i < 10; i++)
+    ;
 }
--- gcc/testsuite/g++.dg/gomp/declare-simd-3.C.jj	2015-06-30 16:43:03.736964530 +0200
+++ gcc/testsuite/g++.dg/gomp/declare-simd-3.C	2015-06-30 16:43:25.035654085 +0200
@@ -0,0 +1,49 @@
+// { dg-do compile }
+
+#pragma omp declare simd uniform(b) linear(c, d) linear(uval(e)) linear(ref(f))
+int f1 (int a, int b, int c, int &d, int &e, int &f)
+{
+  a++;
+  b++;
+  c++;
+  d++;
+  e++;
+  f++;
+  return a + b + c + d + e + f;
+}
+
+#pragma omp declare simd uniform(b) linear(c, d) linear(uval(e)) linear(ref(f))
+int f2 (int a, int b, int c, int &d, int &e, int &f)
+{
+  asm volatile ("" : : "r" (&a));
+  asm volatile ("" : : "r" (&b));
+  asm volatile ("" : : "r" (&c));
+  asm volatile ("" : : "r" (&d));
+  asm volatile ("" : : "r" (&e));
+  asm volatile ("" : : "r" (&f));
+  a++;
+  b++;
+  c++;
+  d++;
+  e++;
+  f++;
+  return a + b + c + d + e + f;
+}
+
+#pragma omp declare simd uniform(b) linear(c, d) linear(uval(e)) linear(ref(f))
+int f3 (const int a, const int b, const int c, const int &d, const int &e, const int &f)
+{
+  return a + b + c + d + e + f;
+}
+
+#pragma omp declare simd uniform(b) linear(c, d) linear(uval(e)) linear(ref(f))
+int f4 (const int a, const int b, const int c, const int &d, const int &e, const int &f)
+{
+  asm volatile ("" : : "r" (&a));
+  asm volatile ("" : : "r" (&b));
+  asm volatile ("" : : "r" (&c));
+  asm volatile ("" : : "r" (&d));
+  asm volatile ("" : : "r" (&e));
+  asm volatile ("" : : "r" (&f));
+  return a + b + c + d + e + f;
+}

	Jakub

             reply	other threads:[~2015-07-01 10:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 10:55 Jakub Jelinek [this message]
2015-07-14 11:41 ` Ilya Verbin
2015-07-14 12:48   ` Jakub Jelinek
2015-11-18 17:31 ` Ilya Verbin
2015-11-18 17:40   ` Jakub Jelinek
2015-11-18 19:28     ` Tian, Xinmin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150701105538.GT10247@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).