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]

[PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr


gcc/
	* gimple.h (gimple_cond_lhs_ptr): Require a const_gimple_cond
	rather than just a const_gimple_cond.
	(gimple_cond_rhs_ptr): Likewise.

	* gimplify-me.c (gimple_regimplify_operands): Add a checked cast
	to gimple_cond within "case GIMPLE_COND".
	* omp-low.c (lower_omp_1): Likewise.

	* omp-low.c (expand_omp_simd): Introduce a new local cond_stmt
	to express that the conditional is indeed a gimple_cond.

	* tree-ssa-loop-ivopts.c (extract_cond_operands): Add a checked
	cast to gimple_cond within a region where the code is known to
	be GIMPLE_COND.
---
 gcc/gimple.h               |  6 ++----
 gcc/gimplify-me.c          | 11 +++++++----
 gcc/omp-low.c              | 30 ++++++++++++++++++------------
 gcc/tree-ssa-loop-ivopts.c |  5 +++--
 4 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index a8da0c4..accd4e9 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3305,9 +3305,8 @@ gimple_cond_lhs (const_gimple gs)
    statement GS.  */
 
 static inline tree *
-gimple_cond_lhs_ptr (const_gimple gs)
+gimple_cond_lhs_ptr (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op_ptr (gs, 0);
 }
 
@@ -3334,9 +3333,8 @@ gimple_cond_rhs (const_gimple gs)
    conditional GS.  */
 
 static inline tree *
-gimple_cond_rhs_ptr (const_gimple gs)
+gimple_cond_rhs_ptr (const_gimple_cond gs)
 {
-  GIMPLE_CHECK (gs, GIMPLE_COND);
   return gimple_op_ptr (gs, 1);
 }
 
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 5008fff..9cf0cc4 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -168,10 +168,13 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      gimplify_expr (gimple_cond_lhs_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
-      gimplify_expr (gimple_cond_rhs_ptr (stmt), &pre, NULL,
-		     is_gimple_val, fb_rvalue);
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	gimplify_expr (gimple_cond_lhs_ptr (cond_stmt), &pre, NULL,
+		       is_gimple_val, fb_rvalue);
+	gimplify_expr (gimple_cond_rhs_ptr (cond_stmt), &pre, NULL,
+		       is_gimple_val, fb_rvalue);
+      }
       break;
     case GIMPLE_SWITCH:
       gimplify_expr (gimple_switch_index_ptr (stmt->as_a_gimple_switch ()),
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b6d5674..5ae014c 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6621,6 +6621,7 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
   basic_block entry_bb, cont_bb, exit_bb, l0_bb, l1_bb, l2_bb, l2_dom_bb;
   gimple_stmt_iterator gsi;
   gimple stmt;
+  gimple_cond cond_stmt;
   bool broken_loop = region->cont == NULL;
   edge e, ne;
   tree *counts = NULL;
@@ -6780,15 +6781,15 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
   t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
 				false, GSI_CONTINUE_LINKING);
   t = build2 (fd->loop.cond_code, boolean_type_node, fd->loop.v, t);
-  stmt = gimple_build_cond_empty (t);
-  gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
-  if (walk_tree (gimple_cond_lhs_ptr (stmt), expand_omp_regimplify_p,
+  cond_stmt = gimple_build_cond_empty (t);
+  gsi_insert_after (&gsi, cond_stmt, GSI_CONTINUE_LINKING);
+  if (walk_tree (gimple_cond_lhs_ptr (cond_stmt), expand_omp_regimplify_p,
 		 NULL, NULL)
-      || walk_tree (gimple_cond_rhs_ptr (stmt), expand_omp_regimplify_p,
+      || walk_tree (gimple_cond_rhs_ptr (cond_stmt), expand_omp_regimplify_p,
 		    NULL, NULL))
     {
-      gsi = gsi_for_stmt (stmt);
-      gimple_regimplify_operands (stmt, &gsi);
+      gsi = gsi_for_stmt (cond_stmt);
+      gimple_regimplify_operands (cond_stmt, &gsi);
     }
 
   /* Remove GIMPLE_OMP_RETURN.  */
@@ -10016,12 +10017,17 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   switch (gimple_code (stmt))
     {
     case GIMPLE_COND:
-      if ((ctx || task_shared_vars)
-	  && (walk_tree (gimple_cond_lhs_ptr (stmt), lower_omp_regimplify_p,
-	      		 ctx ? NULL : &wi, NULL)
-	      || walk_tree (gimple_cond_rhs_ptr (stmt), lower_omp_regimplify_p,
-			    ctx ? NULL : &wi, NULL)))
-	gimple_regimplify_operands (stmt, gsi_p);
+      {
+	gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+	if ((ctx || task_shared_vars)
+	    && (walk_tree (gimple_cond_lhs_ptr (cond_stmt),
+			   lower_omp_regimplify_p,
+			   ctx ? NULL : &wi, NULL)
+		|| walk_tree (gimple_cond_rhs_ptr (cond_stmt),
+			      lower_omp_regimplify_p,
+			      ctx ? NULL : &wi, NULL)))
+	  gimple_regimplify_operands (cond_stmt, gsi_p);
+      }
       break;
     case GIMPLE_CATCH:
       lower_omp (gimple_catch_handler_ptr (stmt->as_a_gimple_catch ()), ctx);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 2be1a6d..ea4dca9 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1351,8 +1351,9 @@ extract_cond_operands (struct ivopts_data *data, gimple stmt,
 
   if (gimple_code (stmt) == GIMPLE_COND)
     {
-      op0 = gimple_cond_lhs_ptr (stmt);
-      op1 = gimple_cond_rhs_ptr (stmt);
+      gimple_cond cond_stmt = stmt->as_a_gimple_cond ();
+      op0 = gimple_cond_lhs_ptr (cond_stmt);
+      op1 = gimple_cond_rhs_ptr (cond_stmt);
     }
   else
     {
-- 
1.8.5.3


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