From 1f6d9179440390affdf5193b99ca8ffd86ab68fb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 16 Dec 2013 14:29:19 -0500
Subject: [PATCH 31/89] Use subclasses of gimple in various places

gcc/
	* asan.c (insert_if_then_before_iter): Require a gimple cond
	rathern than a plain gimple.
	(instrument_mem_region_access): Strengthen local from gimple to
	gimple_cond.

	* cfgloopmanip.c (create_empty_if_region_on_edge): Likewise.

	* omp-low.c (simd_clone_adjust): Strengthen local from gimple
	to gimple_phi.

	* sese.c (set_ifsese_condition): Strengthen local from gimple to
	gimple_cond.

	* tree-call-cdce.c (gen_one_condition): Strengthen locals from
	gimple to gimple_assign and gimple_cond.

	* tree-ssa-phiopt.c (minmax_replacement): Likewise.
	(cond_store_replacement): Strengthen locals from gimple to
	gimple_phi and gimple_assign.
	(cond_if_else_store_replacement_1): Likewise.

	* tree-ssa-pre.c (do_regular_insertion): Strengthen local from
	gimple to gimple_assign.

	* tree-switch-conversion.c (hoist_edge_and_branch_if_true):
	Strengthen local from gimple to gimple_cond.
	(gen_def_assigns): Return a gimple_assign rather than a plain
	gimple.
	(gen_inbound_check): Strengthen locals from gimple to gimple_cond
	and gimple_assign.

	* tree-vect-loop-manip.c (slpeel_add_loop_guard): Strengthen local
	from gimple to gimple_cond.
	(set_prologue_iterations): Strengthen locals from gimple to
	gimple_phi and gimple_cond.

	* value-prof.c (gimple_ic): Strengthen local from gimple to
	gimple_phi.
	(gimple_stringop_fixed_value): Strengthen locals from gimple to
	gimple_assign, gimple_cond, gimple_call, and gimple_phi.
---
 gcc/asan.c                   | 10 +++++-----
 gcc/cfgloopmanip.c           |  2 +-
 gcc/omp-low.c                |  2 +-
 gcc/sese.c                   |  2 +-
 gcc/tree-call-cdce.c         |  4 +++-
 gcc/tree-ssa-phiopt.c        | 11 +++++++----
 gcc/tree-ssa-pre.c           |  7 +++++--
 gcc/tree-switch-conversion.c | 10 +++++-----
 gcc/tree-vect-loop-manip.c   |  6 +++---
 gcc/value-prof.c             | 10 ++++++----
 10 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/gcc/asan.c b/gcc/asan.c
index cab4d44..773d845 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1420,7 +1420,7 @@ create_cond_insert_point (gimple_stmt_iterator *iter,
    pointing to initially.  */
 
 static void
-insert_if_then_before_iter (gimple cond,
+insert_if_then_before_iter (gimple_cond cond,
 			    gimple_stmt_iterator *iter,
 			    bool then_more_likely_p,
 			    basic_block *then_bb,
@@ -1706,10 +1706,10 @@ instrument_mem_region_access (tree base, tree len,
 	   }
 	   // falltrough instructions, starting with *ITER.  */
 
-      gimple g = gimple_build_cond (NE_EXPR,
-				    len,
-				    build_int_cst (TREE_TYPE (len), 0),
-				    NULL_TREE, NULL_TREE);
+      gimple_cond g = gimple_build_cond (NE_EXPR,
+					 len,
+					 build_int_cst (TREE_TYPE (len), 0),
+					 NULL_TREE, NULL_TREE);
       gimple_set_location (g, location);
       insert_if_then_before_iter (g, iter, /*then_more_likely_p=*/true,
 				  &then_bb, &fallthrough_bb);
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 3fa2535..b0255a0 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -690,7 +690,7 @@ create_empty_if_region_on_edge (edge entry_edge, tree condition)
 
   basic_block cond_bb, true_bb, false_bb, join_bb;
   edge e_true, e_false, exit_edge;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   tree simple_cond;
   gimple_stmt_iterator gsi;
 
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 8407f0e..5054164 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11557,7 +11557,7 @@ simd_clone_adjust (struct cgraph_node *node)
      make_edge (incr_bb, latch_bb, EDGE_TRUE_VALUE);  */
   FALLTHRU_EDGE (incr_bb)->flags = EDGE_TRUE_VALUE;
 
-  gimple phi = create_phi_node (iter1, body_bb);
+  gimple_phi phi = create_phi_node (iter1, body_bb);
   edge preheader_edge = find_edge (entry_bb, body_bb);
   edge latch_edge = single_succ_edge (latch_bb);
   add_phi_arg (phi, build_zero_cst (unsigned_type_node), preheader_edge,
diff --git a/gcc/sese.c b/gcc/sese.c
index eb34c41..f146238 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -783,7 +783,7 @@ set_ifsese_condition (ifsese if_region, tree condition)
   basic_block bb = entry->dest;
   gimple last = last_stmt (bb);
   gimple_stmt_iterator gsi = gsi_last_bb (bb);
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
 
   gcc_assert (gimple_code (last) == GIMPLE_COND);
 
diff --git a/gcc/tree-call-cdce.c b/gcc/tree-call-cdce.c
index d7941e3..d1f18f8 100644
--- a/gcc/tree-call-cdce.c
+++ b/gcc/tree-call-cdce.c
@@ -332,7 +332,9 @@ gen_one_condition (tree arg, int lbub,
 {
   tree lbub_real_cst, lbub_cst, float_type;
   tree temp, tempn, tempc, tempcn;
-  gimple stmt1, stmt2, stmt3;
+  gimple_assign stmt1;
+  gimple_assign stmt2;
+  gimple_cond stmt3;
 
   float_type = TREE_TYPE (arg);
   lbub_cst = build_int_cst (integer_type_node, lbub);
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index da1cd37..9828f18 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -953,7 +953,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
 		    tree arg0, tree arg1)
 {
   tree result, type;
-  gimple cond, new_stmt;
+  gimple_cond cond;
+  gimple_assign new_stmt;
   edge true_edge, false_edge;
   enum tree_code cmp, minmax, ass_code;
   tree smaller, larger, arg_true, arg_false;
@@ -965,7 +966,7 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
   if (HONOR_NANS (TYPE_MODE (type)))
     return false;
 
-  cond = last_stmt (cond_bb);
+  cond = last_stmt (cond_bb)->as_a_gimple_cond ();
   cmp = gimple_cond_code (cond);
 
   /* This transformation is only valid for order comparisons.  Record which
@@ -1677,7 +1678,8 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb,
 {
   gimple assign = last_and_only_stmt (middle_bb);
   tree lhs, rhs, name, name2;
-  gimple newphi, new_stmt;
+  gimple_phi newphi;
+  gimple_assign new_stmt;
   gimple_stmt_iterator gsi;
   source_location locus;
 
@@ -1750,7 +1752,8 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb,
   tree lhs_base, lhs, then_rhs, else_rhs, name;
   source_location then_locus, else_locus;
   gimple_stmt_iterator gsi;
-  gimple newphi, new_stmt;
+  gimple_phi newphi;
+  gimple_assign new_stmt;
 
   if (then_assign == NULL
       || !gimple_assign_single_p (then_assign)
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 044d59d..e7b3ca2 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3443,8 +3443,11 @@ do_regular_insertion (basic_block block, basic_block dom)
 
 	      tree temp = make_temp_ssa_name (get_expr_type (expr),
 					      NULL, "pretmp");
-	      gimple assign = gimple_build_assign (temp,
-						   edoubleprime->kind == CONSTANT ? PRE_EXPR_CONSTANT (edoubleprime) : PRE_EXPR_NAME (edoubleprime));
+	      gimple_assign assign =
+		gimple_build_assign (temp,
+				     edoubleprime->kind == CONSTANT ?
+				       PRE_EXPR_CONSTANT (edoubleprime) :
+				       PRE_EXPR_NAME (edoubleprime));
 	      gimple_stmt_iterator gsi = gsi_after_labels (block);
 	      gsi_insert_before (&gsi, assign, GSI_NEW_STMT);
 
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 86e7840..de3045a 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -85,7 +85,7 @@ hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip,
 			       bool update_dominators)
 {
   tree tmp;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   edge e_false;
   basic_block new_bb, split_bb = gsi_bb (*gsip);
   bool dominated_e_true = false;
@@ -1130,11 +1130,11 @@ build_arrays (gimple_switch swtch, struct switch_conv_info *info)
 /* Generates and appropriately inserts loads of default values at the position
    given by BSI.  Returns the last inserted statement.  */
 
-static gimple
+static gimple_assign
 gen_def_assigns (gimple_stmt_iterator *gsi, struct switch_conv_info *info)
 {
   int i;
-  gimple assign = NULL;
+  gimple_assign assign = NULL;
 
   for (i = 0; i < info->phi_count; i++)
     {
@@ -1221,9 +1221,9 @@ gen_inbound_check (gimple_switch swtch, struct switch_conv_info *info)
   tree utype, tidx;
   tree bound;
 
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
 
-  gimple last_assign;
+  gimple_assign last_assign;
   gimple_stmt_iterator gsi;
   basic_block bb0, bb1, bb2, bbf, bbd;
   edge e01, e02, e21, e1d, e1f, e2f;
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index b0b6bbe..b14bf01 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -929,7 +929,7 @@ slpeel_add_loop_guard (basic_block guard_bb, tree cond,
 {
   gimple_stmt_iterator gsi;
   edge new_e, enter_e;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   gimple_seq gimplify_stmt_list = NULL;
 
   enter_e = EDGE_SUCC (guard_bb, 0);
@@ -1042,9 +1042,9 @@ set_prologue_iterations (basic_block bb_before_first_loop,
   basic_block cond_bb, then_bb;
   tree var, prologue_after_cost_adjust_name;
   gimple_stmt_iterator gsi;
-  gimple newphi;
+  gimple_phi newphi;
   edge e_true, e_false, e_fallthru;
-  gimple cond_stmt;
+  gimple_cond cond_stmt;
   gimple_seq stmts = NULL;
   tree cost_pre_condition = NULL_TREE;
   tree scalar_loop_iters =
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index a635bf7..eabd84c 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -1418,7 +1418,7 @@ gimple_ic (gimple icall_stmt, struct cgraph_node *direct_call,
       && (dflags & ECF_NORETURN) == 0)
     {
       tree result = gimple_call_lhs (icall_stmt);
-      gimple phi = create_phi_node (result, join_bb);
+      gimple_phi phi = create_phi_node (result, join_bb);
       gimple_call_set_lhs (icall_stmt,
 			   duplicate_ssa_name (result, icall_stmt));
       add_phi_arg (phi, gimple_call_lhs (icall_stmt), e_ij, UNKNOWN_LOCATION);
@@ -1586,7 +1586,9 @@ static void
 gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
 			     gcov_type count, gcov_type all)
 {
-  gimple tmp_stmt, cond_stmt, icall_stmt;
+  gimple_assign tmp_stmt;
+  gimple_cond cond_stmt;
+  gimple_call icall_stmt;
   tree tmp0, tmp1, vcall_size, optype;
   basic_block cond_bb, icall_bb, vcall_bb, join_bb;
   edge e_ci, e_cv, e_iv, e_ij, e_vj;
@@ -1618,7 +1620,7 @@ gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
   gimple_set_vdef (vcall_stmt, NULL);
   gimple_set_vuse (vcall_stmt, NULL);
   update_stmt (vcall_stmt);
-  icall_stmt = gimple_copy (vcall_stmt);
+  icall_stmt = gimple_copy (vcall_stmt)->as_a_gimple_call ();
   gimple_call_set_arg (icall_stmt, size_arg, icall_size);
   gsi_insert_before (&gsi, icall_stmt, GSI_SAME_STMT);
 
@@ -1658,7 +1660,7 @@ gimple_stringop_fixed_value (gimple_call vcall_stmt, tree icall_size, int prob,
       && TREE_CODE (gimple_call_lhs (vcall_stmt)) == SSA_NAME)
     {
       tree result = gimple_call_lhs (vcall_stmt);
-      gimple phi = create_phi_node (result, join_bb);
+      gimple_phi phi = create_phi_node (result, join_bb);
       gimple_call_set_lhs (vcall_stmt,
 			   duplicate_ssa_name (result, vcall_stmt));
       add_phi_arg (phi, gimple_call_lhs (vcall_stmt), e_vj, UNKNOWN_LOCATION);
-- 
1.8.5.3

