[gimple-classes, committed 74/92] Concretize gimple_cond_{lhs|rhs}_ptr

David Malcolm dmalcolm@redhat.com
Mon Oct 27 20:38:00 GMT 2014


This corresponds to:
  [PATCH 76/89] Concretize gimple_cond_{lhs|rhs}_ptr
  https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01170.html
from the original 89-patch kit

That earlier patch was approved by Jeff:
> OK when prereqs go in.
in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00851.html

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/ChangeLog.gimple-classes | 19 +++++++++++++++++++
 gcc/gimple.h                 |  6 ++----
 gcc/gimplify-me.c            | 11 +++++++----
 gcc/omp-low.c                | 30 ++++++++++++++++++------------
 gcc/tree-ssa-loop-ivopts.c   |  5 +++--
 5 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index ece5b80..a5fd662 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,24 @@
 2014-10-24  David Malcolm  <dmalcolm@redhat.com>
 
+	Concretize gimple_cond_{lhs|rhs}_ptr
+
+	* 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.
+
+2014-10-24  David Malcolm  <dmalcolm@redhat.com>
+
 	Concretize gimple_cond_set_{lhs|rhs}
 
 	* gimple.h (gimple_cond_set_lhs): Require a gimple_cond.
diff --git a/gcc/gimple.h b/gcc/gimple.h
index eae7b60..4afb86f 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -3027,9 +3027,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);
 }
 
@@ -3056,9 +3055,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 5ecd169..7326f2e 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 = as_a <gimple_cond> (stmt);
+	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 (as_a <gimple_switch> (stmt)),
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 2ab49c3..cd0869f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -7073,6 +7073,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;
@@ -7232,15 +7233,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.  */
@@ -10473,12 +10474,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 = as_a <gimple_cond> (stmt);
+	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 (as_a <gimple_catch> (stmt)), ctx);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 76dc7d8..0b47a21 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -1379,8 +1379,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 = as_a <gimple_cond> (stmt);
+      op0 = gimple_cond_lhs_ptr (cond_stmt);
+      op1 = gimple_cond_rhs_ptr (cond_stmt);
     }
   else
     {
-- 
1.8.5.3



More information about the Gcc-patches mailing list