@@ -1,5 +1,31 @@
2014-10-24 David Malcolm <dmalcolm@redhat.com>
+ Concretize gimple_cond_set_code
+
+ * gimple.h (gimple_cond_set_code): Require a gimple_cond.
+
+ * tree-complex.c (expand_complex_comparison): Add a checked cast to
+ gimple_cond within "case GIMPLE_COND".
+
+ * tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond"
+ to a gimple_cond, adding a checked cast. The existing code requires
+ that the last statement before the exit edge have code GIMPLE_COND,
+ though it's not clear to me where this is verified.
+
+ * tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast
+ to gimple_cond on "use->stmt".
+
+ * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert
+ local "exit_if" to gimple_cond, adding a checked cast. It's not
+ clear to me exactly where the GIMPLE_COND-ness of this is
+ established, but the existing code requires it.
+ (canonicalize_loop_ivs): Similarly for "stmt".
+
+ * tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace
+ a check against GIMPLE_COND with a dyn_cast<gimple_cond>.
+
+2014-10-24 David Malcolm <dmalcolm@redhat.com>
+
Concretize gimple_cond_{true|false}_label
* gimple.h (gimple_cond_true_label): Require a const_gimple_cond
@@ -3008,9 +3008,8 @@ gimple_cond_code (const_gimple gs)
/* Set CODE to be the predicate code for the conditional statement GS. */
static inline void
-gimple_cond_set_code (gimple gs, enum tree_code code)
+gimple_cond_set_code (gimple_cond gs, enum tree_code code)
{
- GIMPLE_CHECK (gs, GIMPLE_COND);
gs->subcode = code;
}
@@ -1405,9 +1405,12 @@ expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
break;
case GIMPLE_COND:
- gimple_cond_set_code (stmt, EQ_EXPR);
- gimple_cond_set_lhs (stmt, cc);
- gimple_cond_set_rhs (stmt, boolean_true_node);
+ {
+ gimple_cond cond_stmt = as_a <gimple_cond> (stmt);
+ gimple_cond_set_code (cond_stmt, EQ_EXPR);
+ gimple_cond_set_lhs (cond_stmt, cc);
+ gimple_cond_set_rhs (cond_stmt, boolean_true_node);
+ }
break;
default:
@@ -89,7 +89,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter)
{
edge in;
tree type, var;
- gimple cond;
+ gimple_cond cond;
gimple_stmt_iterator incr_at;
enum tree_code cmp;
@@ -100,7 +100,7 @@ create_canonical_iv (struct loop *loop, edge exit, tree niter)
fprintf (dump_file, " iterations.\n");
}
- cond = last_stmt (exit->src);
+ cond = as_a <gimple_cond> (last_stmt (exit->src));
in = EDGE_SUCC (exit->src, 0);
if (in == exit)
in = EDGE_SUCC (exit->src, 1);
@@ -6480,9 +6480,10 @@ rewrite_use_compare (struct ivopts_data *data,
loop_preheader_edge (data->current_loop),
stmts);
- gimple_cond_set_lhs (use->stmt, var);
- gimple_cond_set_code (use->stmt, compare);
- gimple_cond_set_rhs (use->stmt, op);
+ gimple_cond cond_stmt = as_a <gimple_cond> (use->stmt);
+ gimple_cond_set_lhs (cond_stmt, var);
+ gimple_cond_set_code (cond_stmt, compare);
+ gimple_cond_set_rhs (cond_stmt, op);
return;
}
@@ -1020,7 +1020,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
transform_callback transform,
void *data)
{
- gimple exit_if;
+ gimple_cond exit_if;
tree ctr_before, ctr_after;
tree enter_main_cond, exit_base, exit_step, exit_bound;
enum tree_code exit_cmp;
@@ -1217,7 +1217,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
/* Finally create the new counter for number of iterations and add the new
exit instruction. */
bsi = gsi_last_nondebug_bb (exit_bb);
- exit_if = gsi_stmt (bsi);
+ exit_if = as_a <gimple_cond> (gsi_stmt (bsi));
create_iv (exit_base, exit_step, NULL_TREE, loop,
&bsi, false, &ctr_before, &ctr_after);
gimple_cond_set_code (exit_if, exit_cmp);
@@ -1328,7 +1328,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
tree type, var_before;
gimple_stmt_iterator gsi;
gimple_phi_iterator psi;
- gimple stmt;
+ gimple_cond stmt;
edge exit = single_dom_exit (loop);
gimple_seq stmts;
enum machine_mode mode;
@@ -1379,7 +1379,7 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
rewrite_all_phi_nodes_with_iv (loop, var_before);
- stmt = last_stmt (exit->src);
+ stmt = as_a <gimple_cond> (last_stmt (exit->src));
/* Make the loop exit if the control condition is not satisfied. */
if (exit->flags & EDGE_TRUE_VALUE)
{
@@ -1445,14 +1445,14 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
propagate_tree_value (&expr, val);
gimple_assign_set_rhs_from_tree (gsi, expr);
}
- else if (gimple_code (stmt) == GIMPLE_COND)
+ else if (gimple_cond cond_stmt = dyn_cast <gimple_cond> (stmt))
{
tree lhs = NULL_TREE;
tree rhs = build_zero_cst (TREE_TYPE (val));
propagate_tree_value (&lhs, val);
- gimple_cond_set_code (stmt, NE_EXPR);
- gimple_cond_set_lhs (stmt, lhs);
- gimple_cond_set_rhs (stmt, rhs);
+ gimple_cond_set_code (cond_stmt, NE_EXPR);
+ gimple_cond_set_lhs (cond_stmt, lhs);
+ gimple_cond_set_rhs (cond_stmt, rhs);
}
else if (is_gimple_call (stmt)
&& gimple_call_lhs (stmt) != NULL_TREE)
This corresponds to: [PATCH 74/89] Concretize gimple_cond_set_code https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01209.html from the original 89-patch kit That earlier patch was approved by Jeff: > Fine once prerequisites go in. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00849.html gcc/ * gimple.h (gimple_cond_set_code): Require a gimple_cond. * tree-complex.c (expand_complex_comparison): Add a checked cast to gimple_cond within "case GIMPLE_COND". * tree-ssa-loop-ivcanon.c (create_canonical_iv): Convert local "cond" to a gimple_cond, adding a checked cast. The existing code requires that the last statement before the exit edge have code GIMPLE_COND, though it's not clear to me where this is verified. * tree-ssa-loop-ivopts.c (rewrite_use_compare): Add a checked cast to gimple_cond on "use->stmt". * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Convert local "exit_if" to gimple_cond, adding a checked cast. It's not clear to me exactly where the GIMPLE_COND-ness of this is established, but the existing code requires it. (canonicalize_loop_ivs): Similarly for "stmt". * tree-ssa-propagate.c (propagate_tree_value_into_stmt): Replace a check against GIMPLE_COND with a dyn_cast<gimple_cond>. --- gcc/ChangeLog.gimple-classes | 26 ++++++++++++++++++++++++++ gcc/gimple.h | 3 +-- gcc/tree-complex.c | 9 ++++++--- gcc/tree-ssa-loop-ivcanon.c | 4 ++-- gcc/tree-ssa-loop-ivopts.c | 7 ++++--- gcc/tree-ssa-loop-manip.c | 8 ++++---- gcc/tree-ssa-propagate.c | 8 ++++---- 7 files changed, 47 insertions(+), 18 deletions(-)