This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tuples] add omp_sections_control


OMP_SECTIONS_CONTROL was added after the tuples design document.  The
following patch adds the equivalent tuples functionality and updates
everything accordingly.

In doing this, I saw that gimplify_omp_workshare was adjusting the OMP
clauses after the tuple was created, and was ignoring the created tuple
altogether.  I've fixed the former, but commented out the latter because
it causes OMP regressions since we are not lowering OMP yet.

Tested on Fedora Core 8 on an x86-64 with no regressions.

Committed to branch.

	* omp-low.c (expand_omp_sections): Use
	gimple_omp_sections_control.
	(lower_omp_sections): Same.
	* gimplify.c (gimplify_omp_workshare): Adjust OMP clauses before
	creating gimple tuple.
	Add gimple tuple to sequence.
	Set OMP_SECTIONS_CONTROL in newly created tuple.
	* gimple.h (gimple_statement_omp_sections): Add control.
	(gimple_omp_sections_control): New.
	(gimple_omp_sections_control_ptr): New.
	(gimple_omp_sections_set_control): New.

Index: omp-low.c
===================================================================
--- omp-low.c	(revision 133867)
+++ omp-low.c	(working copy)
@@ -3555,9 +3555,7 @@ expand_omp_sections (struct omp_region *
   si = gsi_last_bb (entry_bb);
   sections_stmt = gsi_stmt (si);
   gcc_assert (gimple_code (sections_stmt) == GIMPLE_OMP_SECTIONS);
-  /* FIXME tuples
-  vin = OMP_SECTIONS_CONTROL (sections_stmt);
-  */
+  vin = gimple_omp_sections_control (sections_stmt);
   if (!is_combined_parallel (region))
     {
       /* If we are not inside a combined parallel+sections region,
@@ -4430,7 +4428,7 @@ lower_omp_sections (tree *stmt_p, omp_co
 
   control = create_tmp_var (unsigned_type_node, ".section");
   t = build2 (GIMPLE_OMP_CONTINUE, void_type_node, control, control);
-  OMP_SECTIONS_CONTROL (stmt) = control;
+  gimple_omp_sections_set_control (stmt, control);
   append_to_statement_list (t, &new_body);
 
   append_to_statement_list (olist, &new_body);
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 133867)
+++ gimplify.c	(working copy)
@@ -5550,20 +5550,31 @@ gimplify_omp_for (tree *expr_p, gimple_s
 static void
 gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p)
 {
-  tree stmt = *expr_p;
+  tree expr = *expr_p;
+  gimple stmt;
   gimple_seq body = NULL;
 
-  gimplify_scan_omp_clauses (&OMP_CLAUSES (stmt), pre_p, false, false);
-
-  gimplify_and_add (OMP_BODY (stmt), &body);
-  if (TREE_CODE (stmt) == OMP_SECTIONS)
-    gimple_build_omp_sections (body, OMP_CLAUSES (stmt));
-  else if (TREE_CODE (stmt) == OMP_SINGLE)
-    gimple_build_omp_single (body, OMP_CLAUSES (stmt));
+  gimplify_scan_omp_clauses (&OMP_CLAUSES (expr), pre_p, false, false);
+  gimplify_and_add (OMP_BODY (expr), &body);
+  gimplify_adjust_omp_clauses (&OMP_CLAUSES (expr));
+
+  if (TREE_CODE (expr) == OMP_SECTIONS)
+    {
+      stmt = gimple_build_omp_sections (body, OMP_CLAUSES (expr));
+      if (OMP_SECTIONS_CONTROL (expr))
+	gimple_omp_sections_set_control (stmt, OMP_SECTIONS_CONTROL (expr));
+    }
+  else if (TREE_CODE (expr) == OMP_SINGLE)
+    stmt = gimple_build_omp_single (body, OMP_CLAUSES (expr));
   else
     gcc_unreachable ();
 
-  gimplify_adjust_omp_clauses (&OMP_CLAUSES (stmt));
+  /* FIXME tuples: Adding the GIMPLE_OMP_{SECTIONS,SINGLE} construct
+     to the sequence causes all sorts of problems because we have
+     disabled omp lowering is still disabled.  Disable this for now
+     until we enable omp_low() and friends.
+  gimplify_seq_add_stmt (pre_p, stmt);
+  */
 }
 
 /* A subroutine of gimplify_omp_atomic.  The front end is supposed to have
Index: gimple.c
===================================================================
--- gimple.c	(revision 133867)
+++ gimple.c	(working copy)
@@ -1426,6 +1426,12 @@ walk_gimple_op (gimple stmt, walk_tree_f
 		       wi, pset);
       if (ret)
 	return ret;
+
+      ret = walk_tree (gimple_omp_sections_control_ptr (stmt), callback_op,
+		       wi, pset);
+      if (ret)
+	return ret;
+
       break;
 
     case GIMPLE_OMP_SINGLE:
Index: gimple.h
===================================================================
--- gimple.h	(revision 133867)
+++ gimple.h	(working copy)
@@ -445,7 +445,12 @@ struct gimple_statement_omp_parallel GTY
 struct gimple_statement_omp_sections GTY(())
 {
   struct gimple_statement_omp omp;
+
   tree clauses;
+
+  /* The control variable used for deciding which of the sections to
+     execute.  */
+  tree control;
 };
 
 /* GIMPLE_OMP_CONTINUE.
@@ -2691,6 +2696,39 @@ gimple_omp_sections_set_clauses (gimple 
 }
 
 
+/* Return the control variable associated with the GIMPLE_OMP_SECTIONS
+   in GS.  */
+
+static inline tree
+gimple_omp_sections_control (const_gimple gs)
+{
+  GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
+  return gs->gimple_omp_sections.control;
+}
+
+
+/* Return a pointer to the clauses associated with the GIMPLE_OMP_SECTIONS
+   GS.  */
+
+static inline tree *
+gimple_omp_sections_control_ptr (gimple gs)
+{
+  GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
+  return &gs->gimple_omp_sections.control;
+}
+
+
+/* Set CONTROL to be the set of clauses associated with the
+   GIMPLE_OMP_SECTIONS in GS.  */
+
+static inline void
+gimple_omp_sections_set_control (gimple gs, tree control)
+{
+  GIMPLE_CHECK (gs, GIMPLE_OMP_SECTIONS);
+  gs->gimple_omp_sections.control = control;
+}
+
+
 /* Set COND to be the condition code for OMP_FOR GS.  */
 
 static inline void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]