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]

Re: [tuples] code checking for tree expressions


> Keeping them separate as you are doing in the patch looks fine to me.

Richard pretty much said the same thing.  He also mentioned that the
EXPR_P references in both function.c and dwarf2out.c probably didn't need
to check for GIMPLE_STMT_P but wouldn't hurt, so I submitted them to the
same treatment.

Below is the patch I am committing.

Aldy

        * tree-vrp.c (simplify_div_or_mod_using_ranges): Use
        GIMPLE_STMT_OPERAND.
        (simplify_abs_using_ranges): Same.
        * tree-complex.c (expand_complex_operations_1): Use
        PROTECTED_TREE_OPERAND.
        * tree-ssa-loop-niter.c (simplify_replace_tree): Check for gimple
        stmt.
        (get_val_for): Use GIMPLE_STMT_OPERAND.
        * tree-tailcall.c (adjust_accumulator_values): Same.
        (adjust_return_value): Same.
        * tree.c (walk_tree): Use IS_GIMPLE_STMT_CODE_CLASS on default
        case.  Remove special case for tcc_gimple_stmt.
        * tree.h (CAN_HAVE_LOCATION_P): New.
        * tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Check for
        GIMPLE_STMT_P.
        * tree-stdarg.c (va_list_counter_bump): Use GIMPLE_STMT_OPERAND.
        * tree-ssa-dom.c (propagate_rhs_into_lhs): Same.
        * tree-nrv.c (execute_return_slot_opt): Same.
        * tree-ssa-alias.c (count_uses_and_derefs): Check for GIMPLE_STMT_P.
        * tree-vn.c (set_value_handle): Same.
        (get_value_handle): Same.
        * c-decl.c (add_stmt): Use CAN_HAVE_LOCATION_P.
        * tree-vectorizer.c (find_loop_location): Same.
        * c-typeck.c (c_process_expr_stmt): Same.
        (c_finish_stmt_expr): Same.
        * gimplify.c (should_carry_locus_p): Same.
        (tree_to_gimple_tuple): Delete definition and use of unecessary
        variable save_tree_block.
        * tree-ssa-pre.c (phi_translate): Check for GIMPLE_STMT_P.
        (create_expression_by_pieces): Use GIMPLE_STMT_OPERAND.
        (realify_fake_stores): Same.
        * tree-ssa-forwprop.c (forward_propagate_addr_into_variable_arr):
        Use TREE_OPERAND.
        * tree-inline.c (copy_body_r): Check for EXPR_P and GIMPLE_STMT_P.
        (copy_tree_r): Check for IS_GIMPLE_STMT_CODE_CLASS.
        * tree-cfg.c (move_stmt_r): Use EXPR_P.  Check for GIMPLE_STMT_P.
        * c-parser.c (c_parser_typeof_specifier): Use CAN_HAVE_LOCATION_P.
        (c_parser_statement_after_labels): Same.
        (c_parser_paren_condition): Same.
        (c_parser_for_statement): Same.
        (c_parser_omp_for_loop): Same.
        * tree-ssa-reassoc.c (linearize_expr): Use GIMPLE_STMT_OPERAND.
        (linearize_expr_tree): Same.
	* dwarf2out.c (reference_to_unused): Check for GIMPLE_STMT_P.
	* function.c (instantiate_expr): Same.

Index: tree-vrp.c
===================================================================
--- tree-vrp.c	(revision 116725)
+++ tree-vrp.c	(working copy)
@@ -4206,7 +4206,7 @@ simplify_div_or_mod_using_ranges (tree s
 	  t = build2 (BIT_AND_EXPR, TREE_TYPE (op0), op0, t);
 	}
 
-      TREE_OPERAND (stmt, 1) = t;
+      GIMPLE_STMT_OPERAND (stmt, 1) = t;
       update_stmt (stmt);
     }
 }
@@ -4253,7 +4253,7 @@ simplify_abs_using_ranges (tree stmt, tr
 	  else
 	    t = op;
 
-	  TREE_OPERAND (stmt, 1) = t;
+	  GIMPLE_STMT_OPERAND (stmt, 1) = t;
 	  update_stmt (stmt);
 	}
     }
Index: tree-complex.c
===================================================================
--- tree-complex.c	(revision 116725)
+++ tree-complex.c	(working copy)
@@ -1392,7 +1392,7 @@ expand_complex_operations_1 (block_stmt_
 		  || TREE_CODE (rhs) == IMAGPART_EXPR)
 		 && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME)
 	  {
-	    TREE_OPERAND (stmt, 1)
+	    PROTECTED_TREE_OPERAND (stmt, 1)
 	      = extract_component (bsi, TREE_OPERAND (rhs, 0),
 				   TREE_CODE (rhs) == IMAGPART_EXPR, false);
 	    update_stmt (stmt);
Index: tree-ssa-loop-niter.c
===================================================================
--- tree-ssa-loop-niter.c	(revision 116725)
+++ tree-ssa-loop-niter.c	(working copy)
@@ -684,7 +684,7 @@ simplify_replace_tree (tree expr, tree o
       || operand_equal_p (expr, old, 0))
     return unshare_expr (new);
 
-  if (!EXPR_P (expr))
+  if (!EXPR_P (expr) && !GIMPLE_STMT_P (expr))
     return expr;
 
   n = TREE_CODE_LENGTH (TREE_CODE (expr));
@@ -1338,7 +1338,7 @@ get_val_for (tree x, tree base)
       nx = USE_FROM_PTR (op);
       val = get_val_for (nx, base);
       SET_USE (op, val);
-      val = fold (TREE_OPERAND (stmt, 1));
+      val = fold (GIMPLE_STMT_OPERAND (stmt, 1));
       SET_USE (op, nx);
       /* only iterate loop once.  */
       return val;
Index: tree-tailcall.c
===================================================================
--- tree-tailcall.c	(revision 117112)
+++ tree-tailcall.c	(working copy)
@@ -565,7 +565,7 @@ adjust_accumulator_values (block_stmt_it
 	      add_referenced_var (tmp);
 
 	      var = make_ssa_name (tmp, stmt);
-	      TREE_OPERAND (stmt, 0) = var;
+	      GIMPLE_STMT_OPERAND (stmt, 0) = var;
 	      bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
 	    }
 	}
@@ -575,7 +575,7 @@ adjust_accumulator_values (block_stmt_it
       stmt = build2 (GIMPLE_MODIFY_STMT, ret_type, NULL_TREE,
 		     build2 (PLUS_EXPR, ret_type, a_acc, var));
       var = make_ssa_name (SSA_NAME_VAR (a_acc), stmt);
-      TREE_OPERAND (stmt, 0) = var;
+      GIMPLE_STMT_OPERAND (stmt, 0) = var;
       bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
       a_acc_arg = var;
     }
@@ -585,7 +585,7 @@ adjust_accumulator_values (block_stmt_it
       stmt = build2 (GIMPLE_MODIFY_STMT, ret_type, NULL_TREE,
 		     build2 (MULT_EXPR, ret_type, m_acc, m));
       var = make_ssa_name (SSA_NAME_VAR (m_acc), stmt);
-      TREE_OPERAND (stmt, 0) = var;
+      GIMPLE_STMT_OPERAND (stmt, 0) = var;
       bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
       m_acc_arg = var;
     }
@@ -629,8 +629,8 @@ adjust_return_value (basic_block bb, tre
     {
       ret_var->base.ann = (tree_ann_t) stmt_ann (ret_stmt);
       bsi_replace (&bsi, ret_var, true);
-      SSA_NAME_DEF_STMT (TREE_OPERAND (ret_var, 0)) = ret_var;
-      ret_var = TREE_OPERAND (ret_var, 0);
+      SSA_NAME_DEF_STMT (GIMPLE_STMT_OPERAND (ret_var, 0)) = ret_var;
+      ret_var = GIMPLE_STMT_OPERAND (ret_var, 0);
       ret_stmt = build1 (RETURN_EXPR, TREE_TYPE (ret_stmt), ret_var);
       bsi_insert_after (&bsi, ret_stmt, BSI_NEW_STMT);
     }
@@ -644,7 +644,7 @@ adjust_return_value (basic_block bb, tre
       add_referenced_var (tmp);
 
       var = make_ssa_name (tmp, stmt);
-      TREE_OPERAND (stmt, 0) = var;
+      GIMPLE_STMT_OPERAND (stmt, 0) = var;
       bsi_insert_before (&bsi, stmt, BSI_SAME_STMT);
     }
   else
@@ -659,7 +659,7 @@ adjust_return_value (basic_block bb, tre
       add_referenced_var (tmp);
 
       var = make_ssa_name (tmp, stmt);
-      TREE_OPERAND (stmt, 0) = var;
+      GIMPLE_STMT_OPERAND (stmt, 0) = var;
       bsi_insert_before (&bsi, stmt, BSI_SAME_STMT);
     }
 
Index: tree.c
===================================================================
--- tree.c	(revision 117154)
+++ tree.c	(working copy)
@@ -7838,7 +7838,8 @@ walk_tree (tree *tp, walk_tree_fn func, 
       /* FALLTHRU */
 
     default:
-      if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
+      if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
+	  || IS_GIMPLE_STMT_CODE_CLASS (TREE_CODE_CLASS (code)))
 	{
 	  int i, len;
 
@@ -7850,27 +7851,10 @@ walk_tree (tree *tp, walk_tree_fn func, 
 	  if (len)
 	    {
 	      for (i = 0; i < len - 1; ++i)
-		WALK_SUBTREE (TREE_OPERAND (*tp, i));
-	      WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, len - 1));
+		WALK_SUBTREE (PROTECTED_TREE_OPERAND (*tp, i));
+	      WALK_SUBTREE_TAIL (PROTECTED_TREE_OPERAND (*tp, len - 1));
 	    }
 	}
-      else if (TREE_CODE_CLASS (code) == tcc_gimple_stmt)
-	{
-	  int i, len;
-
-	  /* Walk over all the sub-trees of this operand.  */
-	  len = TREE_CODE_LENGTH (code);
-
-	  /* Go through the subtrees.  We need to do this in forward order so
-	     that the scope of a FOR_EXPR is handled properly.  */
-	  if (len)
-	    {
-	      for (i = 0; i < len - 1; ++i)
-		WALK_SUBTREE (GIMPLE_STMT_OPERAND (*tp, i));
-	      WALK_SUBTREE_TAIL (GIMPLE_STMT_OPERAND (*tp, len - 1));
-	    }
-	}
-
       /* If this is a type, walk the needed fields in the type.  */
       else if (TYPE_P (*tp))
 	return walk_type_fields (*tp, func, data, pset);
Index: tree.h
===================================================================
--- tree.h	(revision 117154)
+++ tree.h	(working copy)
@@ -1520,6 +1520,10 @@ struct tree_constructor GTY(())
 #define EXPR_FILENAME(NODE) *(expr_filename ((NODE)))
 #define EXPR_LINENO(NODE) *(expr_lineno ((NODE)))
 
+/* True if a tree is an expression or statement that can have a
+   location.  */
+#define CAN_HAVE_LOCATION_P(NODE) (EXPR_P (NODE) || GIMPLE_STMT_P (NODE))
+
 /* In a TARGET_EXPR node.  */
 #define TARGET_EXPR_SLOT(NODE) TREE_OPERAND_CHECK_CODE (NODE, TARGET_EXPR, 0)
 #define TARGET_EXPR_INITIAL(NODE) TREE_OPERAND_CHECK_CODE (NODE, TARGET_EXPR, 1)
Index: tree-ssa-loop-ivopts.c
===================================================================
--- tree-ssa-loop-ivopts.c	(revision 116725)
+++ tree-ssa-loop-ivopts.c	(working copy)
@@ -1311,7 +1311,7 @@ expr_invariant_in_loop_p (struct loop *l
       return true;
     }
 
-  if (!EXPR_P (expr))
+  if (!EXPR_P (expr) && !GIMPLE_STMT_P (expr))
     return false;
 
   len = TREE_CODE_LENGTH (TREE_CODE (expr));
Index: tree-stdarg.c
===================================================================
--- tree-stdarg.c	(revision 116725)
+++ tree-stdarg.c	(working copy)
@@ -153,7 +153,7 @@ va_list_counter_bump (struct stdarg_info
 	  || GIMPLE_STMT_OPERAND (stmt, 0) != lhs)
 	return (unsigned HOST_WIDE_INT) -1;
 
-      rhs = TREE_OPERAND (stmt, 1);
+      rhs = GIMPLE_STMT_OPERAND (stmt, 1);
       if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
 	rhs = TREE_OPERAND (rhs, 0);
 
@@ -211,7 +211,7 @@ va_list_counter_bump (struct stdarg_info
 
       stmt = SSA_NAME_DEF_STMT (lhs);
 
-      rhs = TREE_OPERAND (stmt, 1);
+      rhs = GIMPLE_STMT_OPERAND (stmt, 1);
       if (TREE_CODE (rhs) == WITH_SIZE_EXPR)
 	rhs = TREE_OPERAND (rhs, 0);
 
Index: tree-ssa-dom.c
===================================================================
--- tree-ssa-dom.c	(revision 116725)
+++ tree-ssa-dom.c	(working copy)
@@ -2243,7 +2243,8 @@ propagate_rhs_into_lhs (tree stmt, tree 
 	     we would need to update the invariant flag for ADDR_EXPRs.  */
 	  if (TREE_CODE (use_stmt) == GIMPLE_MODIFY_STMT
 	      && TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == ADDR_EXPR)
-	    recompute_tree_invariant_for_addr_expr (TREE_OPERAND (use_stmt, 1));
+	    recompute_tree_invariant_for_addr_expr
+	      (GIMPLE_STMT_OPERAND (use_stmt, 1));
 
 	  /* If we cleaned up EH information from the statement,
 	     mark its containing block as needing EH cleanups.  */
Index: tree-nrv.c
===================================================================
--- tree-nrv.c	(revision 116725)
+++ tree-nrv.c	(working copy)
@@ -297,7 +297,7 @@ execute_return_slot_opt (void)
 	    /* Check if the location being assigned to is
 	       call-clobbered.  */
 	    CALL_EXPR_RETURN_SLOT_OPT (call) =
-	      dest_safe_for_nrv_p (TREE_OPERAND (stmt, 0)) ? 1 : 0;
+	      dest_safe_for_nrv_p (GIMPLE_STMT_OPERAND (stmt, 0)) ? 1 : 0;
 	}
     }
   return 0;
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c	(revision 116725)
+++ tree-ssa-alias.c	(working copy)
@@ -841,7 +841,8 @@ count_uses_and_derefs (tree ptr, tree st
 	  rhs = stmt;
 	}
 
-      if (lhs && (TREE_CODE (lhs) == TREE_LIST || EXPR_P (lhs)))
+      if (lhs && (TREE_CODE (lhs) == TREE_LIST
+		  || EXPR_P (lhs) || GIMPLE_STMT_P (lhs)))
 	{
 	  struct count_ptr_d count;
 	  count.ptr = ptr;
@@ -851,7 +852,8 @@ count_uses_and_derefs (tree ptr, tree st
 	  *num_derefs_p = count.count;
 	}
 
-      if (rhs && (TREE_CODE (rhs) == TREE_LIST || EXPR_P (rhs)))
+      if (rhs && (TREE_CODE (rhs) == TREE_LIST
+		  || EXPR_P (rhs) || GIMPLE_STMT_P (rhs)))
 	{
 	  struct count_ptr_d count;
 	  count.ptr = ptr;
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 116725)
+++ dwarf2out.c	(working copy)
@@ -9918,7 +9918,7 @@ static tree
 reference_to_unused (tree * tp, int * walk_subtrees,
 		     void * data ATTRIBUTE_UNUSED)
 {
-  if (! EXPR_P (*tp) && ! CONSTANT_CLASS_P (*tp))
+  if (! EXPR_P (*tp) && ! GIMPLE_STMT_P (*tp) && ! CONSTANT_CLASS_P (*tp))
     *walk_subtrees = 0;
   
   if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
Index: tree-vn.c
===================================================================
--- tree-vn.c	(revision 117112)
+++ tree-vn.c	(working copy)
@@ -180,8 +180,8 @@ set_value_handle (tree e, tree v)
 {
   if (TREE_CODE (e) == SSA_NAME)
     SSA_NAME_VALUE (e) = v;
-  else if (EXPR_P (e) || DECL_P (e) || TREE_CODE (e) == TREE_LIST
-	   || TREE_CODE (e) == CONSTRUCTOR)
+  else if (EXPR_P (e) || GIMPLE_STMT_P (e) || DECL_P (e)
+	   || TREE_CODE (e) == TREE_LIST || TREE_CODE (e) == CONSTRUCTOR)
     get_tree_ann (e)->common.value_handle = v;
   else
     /* Do nothing.  Constants are their own value handles.  */
@@ -435,7 +435,8 @@ get_value_handle (tree expr)
 
   if (TREE_CODE (expr) == SSA_NAME)
     return SSA_NAME_VALUE (expr);
-  else if (EXPR_P (expr) || DECL_P (expr) || TREE_CODE (expr) == TREE_LIST
+  else if (EXPR_P (expr) || GIMPLE_STMT_P (expr) || DECL_P (expr)
+	   || TREE_CODE (expr) == TREE_LIST
 	   || TREE_CODE (expr) == CONSTRUCTOR)
     {
       tree_ann_t ann = tree_ann (expr);
Index: c-decl.c
===================================================================
--- c-decl.c	(revision 116725)
+++ c-decl.c	(working copy)
@@ -432,7 +432,7 @@ add_stmt (tree t)
 {
   enum tree_code code = TREE_CODE (t);
 
-  if (EXPR_P (t) && code != LABEL_EXPR)
+  if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR)
     {
       if (!EXPR_HAS_LOCATION (t))
 	SET_EXPR_LOCATION (t, input_location);
Index: function.c
===================================================================
--- function.c	(revision 116725)
+++ function.c	(working copy)
@@ -1602,7 +1602,7 @@ static tree
 instantiate_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
 {
   tree t = *tp;
-  if (! EXPR_P (t))
+  if (! EXPR_P (t) && ! GIMPLE_STMT_P (t))
     {
       *walk_subtrees = 0;
       if (DECL_P (t) && DECL_RTL_SET_P (t))
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 116725)
+++ tree-vectorizer.c	(working copy)
@@ -1237,7 +1237,7 @@ find_loop_location (struct loop *loop)
 
   node = get_loop_exit_condition (loop);
 
-  if (node && EXPR_P (node) && EXPR_HAS_LOCATION (node)
+  if (node && CAN_HAVE_LOCATION_P (node) && EXPR_HAS_LOCATION (node)
       && EXPR_FILENAME (node) && EXPR_LINENO (node))
     return EXPR_LOC (node);
 
@@ -1252,7 +1252,7 @@ find_loop_location (struct loop *loop)
   for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
     {
       node = bsi_stmt (si);
-      if (node && EXPR_P (node) && EXPR_HAS_LOCATION (node))
+      if (node && CAN_HAVE_LOCATION_P (node) && EXPR_HAS_LOCATION (node))
         return EXPR_LOC (node);
     }
 
Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 116647)
+++ c-typeck.c	(working copy)
@@ -7411,7 +7411,7 @@ c_process_expr_stmt (tree expr)
   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
     expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
 
-  if (EXPR_P (expr))
+  if (CAN_HAVE_LOCATION_P (expr))
     SET_EXPR_LOCATION (expr, input_location);
 
   return expr;
@@ -7548,7 +7548,7 @@ c_finish_stmt_expr (tree body)
     {
       /* Do not warn if the return value of a statement expression is
 	 unused.  */
-      if (EXPR_P (last))
+      if (CAN_HAVE_LOCATION_P (last))
 	TREE_NO_WARNING (last) = 1;
       return last;
     }
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 117154)
+++ gimplify.c	(working copy)
@@ -778,7 +778,8 @@ should_carry_locus_p (tree stmt)
 static void
 annotate_one_with_locus (tree t, location_t locus)
 {
-  if (EXPR_P (t) && ! EXPR_HAS_LOCATION (t) && should_carry_locus_p (t))
+  if (CAN_HAVE_LOCATION_P (t)
+      && ! EXPR_HAS_LOCATION (t) && should_carry_locus_p (t))
     SET_EXPR_LOCATION (t, locus);
 }
 
@@ -3508,7 +3509,6 @@ tree_to_gimple_tuple (tree *tp)
     case MODIFY_EXPR:
       {
         struct gimple_stmt *gs;
-        tree save_tree_block = TREE_BLOCK(*tp);
 	tree lhs = TREE_OPERAND (*tp, 0);
 	bool def_stmt_self_p = false;
 
@@ -3528,7 +3528,7 @@ tree_to_gimple_tuple (tree *tp)
         gs->locus = EXPR_LOCUS (*tp);
         gs->operands[0] = TREE_OPERAND (*tp, 0);
         gs->operands[1] = TREE_OPERAND (*tp, 1);
-        gs->block = save_tree_block;
+        gs->block = TREE_BLOCK (*tp);
         *tp = (tree)gs;
 
 	/* If we re-gimplify a set to an SSA_NAME, we must change the
Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c	(revision 117112)
+++ tree-ssa-pre.c	(working copy)
@@ -1041,7 +1041,7 @@ phi_translate (tree expr, value_set_t se
     return expr;
 
   /* Phi translations of a given expression don't change.  */
-  if (EXPR_P (expr))
+  if (EXPR_P (expr) || GIMPLE_STMT_P (expr))
     {
       tree vh;
 
@@ -2400,8 +2400,8 @@ create_expression_by_pieces (basic_block
       for (; !tsi_end_p (tsi); tsi_next (&tsi))
 	{
 	  tree stmt = tsi_stmt (tsi);
-	  tree forcedname = TREE_OPERAND (stmt, 0);
-	  tree forcedexpr = TREE_OPERAND (stmt, 1);
+	  tree forcedname = GIMPLE_STMT_OPERAND (stmt, 0);
+	  tree forcedexpr = GIMPLE_STMT_OPERAND (stmt, 1);
 	  tree val = vn_lookup_or_add (forcedexpr, NULL);
 
 	  VEC_safe_push (tree, heap, inserted_exprs, stmt);
@@ -3291,7 +3291,7 @@ realify_fake_stores (void)
 	  tree newstmt;
 
 	  /* Mark the temp variable as referenced */
-	  add_referenced_var (SSA_NAME_VAR (TREE_OPERAND (stmt, 0)));
+	  add_referenced_var (SSA_NAME_VAR (GIMPLE_STMT_OPERAND (stmt, 0)));
 
 	  /* Put the new statement in GC memory, fix up the
 	     SSA_NAME_DEF_STMT on it, and then put it in place of
@@ -3300,9 +3300,9 @@ realify_fake_stores (void)
 	  bsi = bsi_for_stmt (stmt);
 	  bsi_prev (&bsi);
 	  newstmt = build2_gimple (GIMPLE_MODIFY_STMT,
-			           TREE_OPERAND (stmt, 0),
-			    	   TREE_OPERAND (bsi_stmt (bsi), 1));
-	  SSA_NAME_DEF_STMT (TREE_OPERAND (newstmt, 0)) = newstmt;
+			           GIMPLE_STMT_OPERAND (stmt, 0),
+			    	   GIMPLE_STMT_OPERAND (bsi_stmt (bsi), 1));
+	  SSA_NAME_DEF_STMT (GIMPLE_STMT_OPERAND (newstmt, 0)) = newstmt;
 	  bsi_insert_before (&bsi, newstmt, BSI_SAME_STMT);
 	  bsi = bsi_for_stmt (stmt);
 	  bsi_remove (&bsi, true);
Index: tree-ssa-forwprop.c
===================================================================
--- tree-ssa-forwprop.c	(revision 116725)
+++ tree-ssa-forwprop.c	(working copy)
@@ -620,7 +620,7 @@ forward_propagate_addr_into_variable_arr
   if (!is_gimple_cast (offset))
     return false;
 
-  offset = GIMPLE_STMT_OPERAND (offset, 0);
+  offset = TREE_OPERAND (offset, 0);
   if (TREE_CODE (offset) != SSA_NAME)
     return false;
 
@@ -639,13 +639,13 @@ forward_propagate_addr_into_variable_arr
      is constant.  */
   offset = GIMPLE_STMT_OPERAND (offset, 1);
   if (TREE_CODE (offset) != MULT_EXPR
-      || TREE_CODE (GIMPLE_STMT_OPERAND (offset, 1)) != INTEGER_CST
-      || !simple_cst_equal (GIMPLE_STMT_OPERAND (offset, 1),
+      || TREE_CODE (TREE_OPERAND (offset, 1)) != INTEGER_CST
+      || !simple_cst_equal (TREE_OPERAND (offset, 1),
 			    TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (lhs)))))
     return false;
 
   /* The first operand to the MULT_EXPR is the desired index.  */
-  index = GIMPLE_STMT_OPERAND (offset, 0);
+  index = TREE_OPERAND (offset, 0);
 
   /* Replace the pointer addition with array indexing.  */
   GIMPLE_STMT_OPERAND (use_stmt, 1)
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 116725)
+++ tree-inline.c	(working copy)
@@ -623,7 +623,7 @@ copy_body_r (tree *tp, int *walk_subtree
       /* If EXPR has block defined, map it to newly constructed block.
          When inlining we want EXPRs without block appear in the block
 	 of function call.  */
-      if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (*tp))))
+      if (EXPR_P (*tp) || GIMPLE_STMT_P (*tp))
 	{
 	  new_block = id->block;
 	  if (TREE_BLOCK (*tp))
@@ -2307,10 +2307,11 @@ tree
 copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
 {
   enum tree_code code = TREE_CODE (*tp);
+  enum tree_code_class cl = TREE_CODE_CLASS (code);
 
   /* We make copies of most nodes.  */
-  if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code))
-      || GIMPLE_TUPLE_P (*tp)
+  if (IS_EXPR_CODE_CLASS (cl)
+      || IS_GIMPLE_STMT_CODE_CLASS (cl)
       || code == TREE_LIST
       || code == TREE_VEC
       || code == TYPE_DECL
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 117154)
+++ tree-cfg.c	(working copy)
@@ -4604,7 +4604,8 @@ move_stmt_r (tree *tp, int *walk_subtree
   struct move_stmt_d *p = (struct move_stmt_d *) data;
   tree t = *tp;
 
-  if (p->block && IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t))))
+  if (p->block
+      && (EXPR_P (t) || GIMPLE_STMT_P (t)))
     TREE_BLOCK (t) = p->block;
 
   if (OMP_DIRECTIVE_P (t)
Index: c-parser.c
===================================================================
--- c-parser.c	(revision 116647)
+++ c-parser.c	(working copy)
@@ -2172,7 +2172,7 @@ c_parser_typeof_specifier (c_parser *par
 	  if (DECL_P (e) || CONSTANT_CLASS_P (e))
 	    e = build1 (NOP_EXPR, void_type_node, e);
 
-	  if (EXPR_P (e))
+	  if (CAN_HAVE_LOCATION_P (e))
 	    SET_EXPR_LOCATION (e, input_location);
 
 	  add_stmt (e);
@@ -3812,7 +3812,7 @@ c_parser_statement_after_labels (c_parse
      (recursively) all of the component statements should already have
      line numbers assigned.  ??? Can we discard no-op statements
      earlier?  */
-  if (stmt && EXPR_P (stmt))
+  if (stmt && CAN_HAVE_LOCATION_P (stmt))
     SET_EXPR_LOCATION (stmt, loc);
 }
 
@@ -3831,7 +3831,7 @@ c_parser_paren_condition (c_parser *pars
   loc = c_parser_peek_token (parser)->location;
   cond = c_objc_common_truthvalue_conversion
     (c_parser_expression_conv (parser).value);
-  if (EXPR_P (cond))
+  if (CAN_HAVE_LOCATION_P (cond))
     SET_EXPR_LOCATION (cond, loc);
   c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
   return cond;
@@ -4068,7 +4068,7 @@ c_parser_for_statement (c_parser *parser
 	{
 	  tree ocond = c_parser_expression_conv (parser).value;
 	  cond = c_objc_common_truthvalue_conversion (ocond);
-	  if (EXPR_P (cond))
+	  if (CAN_HAVE_LOCATION_P (cond))
 	    SET_EXPR_LOCATION (cond, loc);
 	  c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
 	}
@@ -7419,7 +7419,7 @@ c_parser_omp_for_loop (c_parser *parser)
     {
       cond = c_parser_expression_conv (parser).value;
       cond = c_objc_common_truthvalue_conversion (cond);
-      if (EXPR_P (cond))
+      if (CAN_HAVE_LOCATION_P (cond))
 	SET_EXPR_LOCATION (cond, input_location);
     }
   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
Index: tree-ssa-reassoc.c
===================================================================
--- tree-ssa-reassoc.c	(revision 116725)
+++ tree-ssa-reassoc.c	(working copy)
@@ -950,7 +950,7 @@ static void
 linearize_expr (tree stmt)
 {
   block_stmt_iterator bsinow, bsirhs;
-  tree rhs = TREE_OPERAND (stmt, 1);
+  tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
   enum tree_code rhscode = TREE_CODE (rhs);
   tree binrhs = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 1));
   tree binlhs = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 0));
@@ -963,11 +963,12 @@ linearize_expr (tree stmt)
   bsirhs = bsi_for_stmt (binrhs);
   bsi_move_before (&bsirhs, &bsinow);
 
-  TREE_OPERAND (rhs, 1) = TREE_OPERAND (TREE_OPERAND (binrhs, 1), 0);
+  TREE_OPERAND (rhs, 1) = TREE_OPERAND (GIMPLE_STMT_OPERAND (binrhs, 1), 0);
   if (TREE_CODE (TREE_OPERAND (rhs, 1)) == SSA_NAME)
     newbinrhs = SSA_NAME_DEF_STMT (TREE_OPERAND (rhs, 1));
-  TREE_OPERAND (TREE_OPERAND (binrhs, 1), 0) = TREE_OPERAND (binlhs, 0);
-  TREE_OPERAND (rhs, 0) = TREE_OPERAND (binrhs, 0);
+  TREE_OPERAND (GIMPLE_STMT_OPERAND (binrhs, 1), 0)
+    = GIMPLE_STMT_OPERAND (binlhs, 0);
+  TREE_OPERAND (rhs, 0) = GIMPLE_STMT_OPERAND (binrhs, 0);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -1178,7 +1179,7 @@ linearize_expr_tree (VEC(operand_entry_t
   else if (binrhsisreassoc)
     {
       linearize_expr (stmt);
-      gcc_assert (rhs == TREE_OPERAND (stmt, 1));
+      gcc_assert (rhs == GIMPLE_STMT_OPERAND (stmt, 1));
       binlhs = TREE_OPERAND (rhs, 0);
       binrhs = TREE_OPERAND (rhs, 1);
     }


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