@@ -4340,9 +4340,8 @@ gimple_switch_set_num_labels (gimple_switch g, unsigned nlabels)
/* Return the index variable used by the switch statement GS. */
static inline tree
-gimple_switch_index (const_gimple gs)
+gimple_switch_index (const_gimple_switch gs)
{
- GIMPLE_CHECK (gs, GIMPLE_SWITCH);
return gimple_op (gs, 0);
}
@@ -4350,9 +4349,8 @@ gimple_switch_index (const_gimple gs)
/* Return a pointer to the index variable for the switch statement GS. */
static inline tree *
-gimple_switch_index_ptr (const_gimple gs)
+gimple_switch_index_ptr (const_gimple_switch gs)
{
- GIMPLE_CHECK (gs, GIMPLE_SWITCH);
return gimple_op_ptr (gs, 0);
}
@@ -174,8 +174,8 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
is_gimple_val, fb_rvalue);
break;
case GIMPLE_SWITCH:
- gimplify_expr (gimple_switch_index_ptr (stmt), &pre, NULL,
- is_gimple_val, fb_rvalue);
+ gimplify_expr (gimple_switch_index_ptr (stmt->as_a_gimple_switch ()),
+ &pre, NULL, is_gimple_val, fb_rvalue);
break;
case GIMPLE_OMP_ATOMIC_LOAD:
gimplify_expr (gimple_omp_atomic_load_rhs_ptr (
@@ -113,7 +113,7 @@ cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi)
break;
case GIMPLE_SWITCH:
- val = gimple_switch_index (stmt);
+ val = gimple_switch_index (stmt->as_a_gimple_switch ());
break;
default:
@@ -1128,7 +1128,7 @@ ccp_fold (gimple stmt)
case GIMPLE_SWITCH:
{
/* Return the constant switch index. */
- return valueize_op (gimple_switch_index (stmt));
+ return valueize_op (gimple_switch_index (stmt->as_a_gimple_switch ()));
}
case GIMPLE_ASSIGN:
@@ -1650,7 +1650,7 @@ evaluate_stmt (gimple stmt)
simplified = gimple_assign_rhs1 (stmt);
}
else if (code == GIMPLE_SWITCH)
- simplified = gimple_switch_index (stmt);
+ simplified = gimple_switch_index (stmt->as_a_gimple_switch ());
else
/* These cannot satisfy is_gimple_min_invariant without folding. */
gcc_assert (code == GIMPLE_CALL || code == GIMPLE_COND);
@@ -342,11 +342,11 @@ initialize_hash_element (gimple stmt, tree lhs,
for (i = 0; i < nargs; i++)
expr->ops.call.args[i] = gimple_call_arg (stmt, i);
}
- else if (code == GIMPLE_SWITCH)
+ else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
{
- expr->type = TREE_TYPE (gimple_switch_index (stmt));
+ expr->type = TREE_TYPE (gimple_switch_index (swtch_stmt));
expr->kind = EXPR_SINGLE;
- expr->ops.single.rhs = gimple_switch_index (stmt);
+ expr->ops.single.rhs = gimple_switch_index (swtch_stmt);
}
else if (code == GIMPLE_GOTO)
{
@@ -1794,7 +1794,7 @@ record_edge_info (basic_block bb)
if (gimple_code (stmt) == GIMPLE_SWITCH)
{
gimple_switch switch_stmt = stmt->as_a_gimple_switch ();
- tree index = gimple_switch_index (stmt);
+ tree index = gimple_switch_index (switch_stmt);
if (TREE_CODE (index) == SSA_NAME)
{
@@ -2079,8 +2079,8 @@ eliminate_redundant_computations (gimple_stmt_iterator* gsi)
expr_type = TREE_TYPE (gimple_call_lhs (stmt));
assigns_var_p = true;
}
- else if (gimple_code (stmt) == GIMPLE_SWITCH)
- expr_type = TREE_TYPE (gimple_switch_index (stmt));
+ else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+ expr_type = TREE_TYPE (gimple_switch_index (swtch_stmt));
else if (gimple_code (stmt) == GIMPLE_PHI)
/* We can't propagate into a phi, so the logic below doesn't apply.
Instead record an equivalence between the cached LHS and the
@@ -2373,9 +2373,9 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
rhs = gimple_assign_rhs1 (stmt);
else if (gimple_code (stmt) == GIMPLE_GOTO)
rhs = gimple_goto_dest (stmt);
- else if (gimple_code (stmt) == GIMPLE_SWITCH)
+ else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
/* This should never be an ADDR_EXPR. */
- rhs = gimple_switch_index (stmt);
+ rhs = gimple_switch_index (swtch_stmt);
if (rhs && TREE_CODE (rhs) == ADDR_EXPR)
recompute_tree_invariant_for_addr_expr (rhs);
@@ -2497,8 +2497,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si)
val = fold_binary_loc (gimple_location (stmt),
gimple_cond_code (stmt), boolean_type_node,
gimple_cond_lhs (stmt), gimple_cond_rhs (stmt));
- else if (gimple_code (stmt) == GIMPLE_SWITCH)
- val = gimple_switch_index (stmt);
+ else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+ val = gimple_switch_index (swtch_stmt);
if (val && TREE_CODE (val) == INTEGER_CST && find_taken_edge (bb, val))
cfg_altered = true;
@@ -2856,7 +2856,7 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name
gimple_cond_lhs (use_stmt),
gimple_cond_rhs (use_stmt));
else if (gimple_code (use_stmt) == GIMPLE_SWITCH)
- val = gimple_switch_index (use_stmt);
+ val = gimple_switch_index (use_stmt->as_a_gimple_switch ());
else
val = gimple_goto_dest (use_stmt);
@@ -305,7 +305,9 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
&& constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
&& constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop))
|| (gimple_code (stmt) == GIMPLE_SWITCH
- && constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
+ && constant_after_peeling (gimple_switch_index (
+ stmt->as_a_gimple_switch ()),
+ stmt, loop)))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " Constant conditional.\n");
@@ -357,7 +359,9 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
&& (!constant_after_peeling (gimple_cond_lhs (stmt), stmt, loop)
|| constant_after_peeling (gimple_cond_rhs (stmt), stmt, loop)))
|| (gimple_code (stmt) == GIMPLE_SWITCH
- && !constant_after_peeling (gimple_switch_index (stmt), stmt, loop)))
+ && !constant_after_peeling (gimple_switch_index (
+ stmt->as_a_gimple_switch ()),
+ stmt, loop)))
&& (!exit || bb != exit->src))
size->num_branches_on_hot_path++;
}
@@ -1297,8 +1297,8 @@ may_propagate_copy_into_stmt (gimple dest, tree orig)
if (gimple_assign_single_p (dest))
return may_propagate_copy (gimple_assign_rhs1 (dest), orig);
- else if (gimple_code (dest) == GIMPLE_SWITCH)
- return may_propagate_copy (gimple_switch_index (dest), orig);
+ else if (gimple_switch dest_swtch = dest->dyn_cast_gimple_switch ())
+ return may_propagate_copy (gimple_switch_index (dest_swtch), orig);
/* In other cases, the expression is not materialized, so there
is no destination to pass to may_propagate_copy. On the other
@@ -1449,8 +1449,8 @@ propagate_tree_value_into_stmt (gimple_stmt_iterator *gsi, tree val)
res = update_call_from_tree (gsi, expr);
gcc_assert (res);
}
- else if (gimple_code (stmt) == GIMPLE_SWITCH)
- propagate_tree_value (gimple_switch_index_ptr (stmt), val);
+ else if (gimple_switch swtch_stmt = stmt->dyn_cast_gimple_switch ())
+ propagate_tree_value (gimple_switch_index_ptr (swtch_stmt), val);
else
gcc_unreachable ();
}
@@ -624,7 +624,7 @@ simplify_control_stmt_condition (edge e,
}
if (code == GIMPLE_SWITCH)
- cond = gimple_switch_index (stmt);
+ cond = gimple_switch_index (stmt->as_a_gimple_switch ());
else if (code == GIMPLE_GOTO)
cond = gimple_goto_dest (stmt);
else