gcc/ * gimple.h (gimple_cond_set_lhs): Require a gimple_cond. (gimple_cond_set_rhs): Likewise.
* tree-parloops.c (transform_to_exit_first_loop): Convert locals "cond_stmt" and "cond_nit" to gimple_cond, adding checked casts, since the existing code assumes that code is GIMPLE_COND. Convert "stmt" to a gimple_assign. (create_parallel_loop): Likewise for "cond_stmt". * tree-ssa-loop-im.c (rewrite_bittest): Replace check for code GIMPLE_COND with a dyn_cast, adding new local "cond_stmt". --- gcc/gimple.h | 6 ++---- gcc/tree-parloops.c | 12 +++++++----- gcc/tree-ssa-loop-im.c | 19 ++++++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gcc/gimple.h b/gcc/gimple.h index bb8c3c1..a8da0c4 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -3315,9 +3315,8 @@ gimple_cond_lhs_ptr (const_gimple gs) conditional statement GS. */ static inline void -gimple_cond_set_lhs (gimple gs, tree lhs) +gimple_cond_set_lhs (gimple_cond gs, tree lhs) { - GIMPLE_CHECK (gs, GIMPLE_COND); gimple_set_op (gs, 0, lhs); } @@ -3346,9 +3345,8 @@ gimple_cond_rhs_ptr (const_gimple gs) conditional statement GS. */ static inline void -gimple_cond_set_rhs (gimple gs, tree rhs) +gimple_cond_set_rhs (gimple_cond gs, tree rhs) { - GIMPLE_CHECK (gs, GIMPLE_COND); gimple_set_op (gs, 1, rhs); } diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 94af311..521e050 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -1513,14 +1513,15 @@ transform_to_exit_first_loop (struct loop *loop, edge exit = single_dom_exit (loop), hpred; tree control, control_name, res, t; gimple_phi phi, nphi; - gimple cond_stmt, stmt, cond_nit; + gimple_assign stmt; + gimple_cond cond_stmt, cond_nit; tree nit_1; split_block_after_labels (loop->header); orig_header = single_succ (loop->header); hpred = single_succ_edge (loop->header); - cond_stmt = last_stmt (exit->src); + cond_stmt = last_stmt (exit->src)->as_a_gimple_cond (); control = gimple_cond_lhs (cond_stmt); gcc_assert (gimple_cond_rhs (cond_stmt) == nit); @@ -1600,7 +1601,7 @@ transform_to_exit_first_loop (struct loop *loop, /* Initialize the control variable to number of iterations according to the rhs of the exit condition. */ gimple_stmt_iterator gsi = gsi_after_labels (ex_bb); - cond_nit = last_stmt (exit->src); + cond_nit = last_stmt (exit->src)->as_a_gimple_cond (); nit_1 = gimple_cond_rhs (cond_nit); nit_1 = force_gimple_operand_gsi (&gsi, fold_convert (TREE_TYPE (control_name), nit_1), @@ -1624,7 +1625,8 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, tree t, param; gimple_omp_parallel omp_par_stmt; gimple omp_return_stmt1, omp_return_stmt2; - gimple phi, cond_stmt; + gimple phi; + gimple_cond cond_stmt; gimple_omp_for for_stmt; gimple_omp_continue omp_cont_stmt; tree cvar, cvar_init, initvar, cvar_next, cvar_base, type; @@ -1668,7 +1670,7 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, /* Extract data for GIMPLE_OMP_FOR. */ gcc_assert (loop->header == single_dom_exit (loop)->src); - cond_stmt = last_stmt (loop->header); + cond_stmt = last_stmt (loop->header)->as_a_gimple_cond (); cvar = gimple_cond_lhs (cond_stmt); cvar_base = SSA_NAME_VAR (cvar); diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index f1a1b3d..3a0b518 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -901,6 +901,7 @@ rewrite_bittest (gimple_stmt_iterator *bsi) gimple stmt1; gimple_assign stmt2; gimple use_stmt; + gimple_cond cond_stmt; tree lhs, name, t, a, b; use_operand_p use; @@ -909,13 +910,15 @@ rewrite_bittest (gimple_stmt_iterator *bsi) /* Verify that the single use of lhs is a comparison against zero. */ if (TREE_CODE (lhs) != SSA_NAME - || !single_imm_use (lhs, &use, &use_stmt) - || gimple_code (use_stmt) != GIMPLE_COND) + || !single_imm_use (lhs, &use, &use_stmt)) return stmt; - if (gimple_cond_lhs (use_stmt) != lhs - || (gimple_cond_code (use_stmt) != NE_EXPR - && gimple_cond_code (use_stmt) != EQ_EXPR) - || !integer_zerop (gimple_cond_rhs (use_stmt))) + cond_stmt = use_stmt->dyn_cast_gimple_cond (); + if (!cond_stmt) + return stmt; + if (gimple_cond_lhs (cond_stmt) != lhs + || (gimple_cond_code (cond_stmt) != NE_EXPR + && gimple_cond_code (cond_stmt) != EQ_EXPR) + || !integer_zerop (gimple_cond_rhs (cond_stmt))) return stmt; /* Get at the operands of the shift. The rhs is TMP1 & 1. */ @@ -963,7 +966,9 @@ rewrite_bittest (gimple_stmt_iterator *bsi) /* Replace the SSA_NAME we compare against zero. Adjust the type of zero accordingly. */ SET_USE (use, name); - gimple_cond_set_rhs (use_stmt, build_int_cst_type (TREE_TYPE (name), 0)); + gimple_cond_set_rhs (cond_stmt, + build_int_cst_type (TREE_TYPE (name), + 0)); /* Don't use gsi_replace here, none of the new assignments sets the variable originally set in stmt. Move bsi to stmt1, and -- 1.8.5.3