mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 00:01:21 +08:00
Use more switch statements.
2019-09-24 Martin Liska <mliska@suse.cz> * cfgexpand.c (gimple_assign_rhs_to_tree): Use switch statement instead of if-elseif-elseif-... * gimple-expr.c (extract_ops_from_tree): Likewise. * gimple.c (get_gimple_rhs_num_ops): Likewise. * tree-ssa-forwprop.c (rhs_to_tree): Likewise. From-SVN: r276095
This commit is contained in:
parent
231f75463c
commit
90acd49f6b
@ -1,3 +1,11 @@
|
||||
2019-09-24 Martin Liska <mliska@suse.cz>
|
||||
|
||||
* cfgexpand.c (gimple_assign_rhs_to_tree): Use switch statement
|
||||
instead of if-elseif-elseif-...
|
||||
* gimple-expr.c (extract_ops_from_tree): Likewise.
|
||||
* gimple.c (get_gimple_rhs_num_ops): Likewise.
|
||||
* tree-ssa-forwprop.c (rhs_to_tree): Likewise.
|
||||
|
||||
2019-09-24 Martin Jambor <mjambor@suse.cz>
|
||||
|
||||
PR ipa/91831
|
||||
|
@ -104,38 +104,38 @@ tree
|
||||
gimple_assign_rhs_to_tree (gimple *stmt)
|
||||
{
|
||||
tree t;
|
||||
enum gimple_rhs_class grhs_class;
|
||||
|
||||
grhs_class = get_gimple_rhs_class (gimple_expr_code (stmt));
|
||||
|
||||
if (grhs_class == GIMPLE_TERNARY_RHS)
|
||||
t = build3 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt),
|
||||
gimple_assign_rhs3 (stmt));
|
||||
else if (grhs_class == GIMPLE_BINARY_RHS)
|
||||
t = build2 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt));
|
||||
else if (grhs_class == GIMPLE_UNARY_RHS)
|
||||
t = build1 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt));
|
||||
else if (grhs_class == GIMPLE_SINGLE_RHS)
|
||||
switch (get_gimple_rhs_class (gimple_expr_code (stmt)))
|
||||
{
|
||||
t = gimple_assign_rhs1 (stmt);
|
||||
/* Avoid modifying this tree in place below. */
|
||||
if ((gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (t)
|
||||
&& gimple_location (stmt) != EXPR_LOCATION (t))
|
||||
|| (gimple_block (stmt)
|
||||
&& currently_expanding_to_rtl
|
||||
&& EXPR_P (t)))
|
||||
t = copy_node (t);
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
t = build3 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt),
|
||||
gimple_assign_rhs3 (stmt));
|
||||
break;
|
||||
case GIMPLE_BINARY_RHS:
|
||||
t = build2 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt));
|
||||
break;
|
||||
case GIMPLE_UNARY_RHS:
|
||||
t = build1 (gimple_assign_rhs_code (stmt),
|
||||
TREE_TYPE (gimple_assign_lhs (stmt)),
|
||||
gimple_assign_rhs1 (stmt));
|
||||
break;
|
||||
case GIMPLE_SINGLE_RHS:
|
||||
{
|
||||
t = gimple_assign_rhs1 (stmt);
|
||||
/* Avoid modifying this tree in place below. */
|
||||
if ((gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (t)
|
||||
&& gimple_location (stmt) != EXPR_LOCATION (t))
|
||||
|| (gimple_block (stmt) && currently_expanding_to_rtl
|
||||
&& EXPR_P (t)))
|
||||
t = copy_node (t);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
else
|
||||
gcc_unreachable ();
|
||||
|
||||
if (gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (t))
|
||||
SET_EXPR_LOCATION (t, gimple_location (stmt));
|
||||
|
@ -528,37 +528,40 @@ void
|
||||
extract_ops_from_tree (tree expr, enum tree_code *subcode_p, tree *op1_p,
|
||||
tree *op2_p, tree *op3_p)
|
||||
{
|
||||
enum gimple_rhs_class grhs_class;
|
||||
|
||||
*subcode_p = TREE_CODE (expr);
|
||||
grhs_class = get_gimple_rhs_class (*subcode_p);
|
||||
|
||||
if (grhs_class == GIMPLE_TERNARY_RHS)
|
||||
switch (get_gimple_rhs_class (*subcode_p))
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = TREE_OPERAND (expr, 1);
|
||||
*op3_p = TREE_OPERAND (expr, 2);
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = TREE_OPERAND (expr, 1);
|
||||
*op3_p = TREE_OPERAND (expr, 2);
|
||||
break;
|
||||
}
|
||||
case GIMPLE_BINARY_RHS:
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = TREE_OPERAND (expr, 1);
|
||||
*op3_p = NULL_TREE;
|
||||
break;
|
||||
}
|
||||
case GIMPLE_UNARY_RHS:
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = NULL_TREE;
|
||||
*op3_p = NULL_TREE;
|
||||
break;
|
||||
}
|
||||
case GIMPLE_SINGLE_RHS:
|
||||
{
|
||||
*op1_p = expr;
|
||||
*op2_p = NULL_TREE;
|
||||
*op3_p = NULL_TREE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
else if (grhs_class == GIMPLE_BINARY_RHS)
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = TREE_OPERAND (expr, 1);
|
||||
*op3_p = NULL_TREE;
|
||||
}
|
||||
else if (grhs_class == GIMPLE_UNARY_RHS)
|
||||
{
|
||||
*op1_p = TREE_OPERAND (expr, 0);
|
||||
*op2_p = NULL_TREE;
|
||||
*op3_p = NULL_TREE;
|
||||
}
|
||||
else if (grhs_class == GIMPLE_SINGLE_RHS)
|
||||
{
|
||||
*op1_p = expr;
|
||||
*op2_p = NULL_TREE;
|
||||
*op3_p = NULL_TREE;
|
||||
}
|
||||
else
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
||||
/* Extract operands for a GIMPLE_COND statement out of COND_EXPR tree COND. */
|
||||
|
22
gcc/gimple.c
22
gcc/gimple.c
@ -2225,16 +2225,18 @@ dump_gimple_statistics (void)
|
||||
unsigned
|
||||
get_gimple_rhs_num_ops (enum tree_code code)
|
||||
{
|
||||
enum gimple_rhs_class rhs_class = get_gimple_rhs_class (code);
|
||||
|
||||
if (rhs_class == GIMPLE_UNARY_RHS || rhs_class == GIMPLE_SINGLE_RHS)
|
||||
return 1;
|
||||
else if (rhs_class == GIMPLE_BINARY_RHS)
|
||||
return 2;
|
||||
else if (rhs_class == GIMPLE_TERNARY_RHS)
|
||||
return 3;
|
||||
else
|
||||
gcc_unreachable ();
|
||||
switch (get_gimple_rhs_class (code))
|
||||
{
|
||||
case GIMPLE_UNARY_RHS:
|
||||
case GIMPLE_SINGLE_RHS:
|
||||
return 1;
|
||||
case GIMPLE_BINARY_RHS:
|
||||
return 2;
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
return 3;
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFTREECODE(SYM, STRING, TYPE, NARGS) \
|
||||
|
@ -347,19 +347,22 @@ rhs_to_tree (tree type, gimple *stmt)
|
||||
{
|
||||
location_t loc = gimple_location (stmt);
|
||||
enum tree_code code = gimple_assign_rhs_code (stmt);
|
||||
if (get_gimple_rhs_class (code) == GIMPLE_TERNARY_RHS)
|
||||
return fold_build3_loc (loc, code, type, gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt),
|
||||
gimple_assign_rhs3 (stmt));
|
||||
else if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS)
|
||||
return fold_build2_loc (loc, code, type, gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt));
|
||||
else if (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS)
|
||||
return build1 (code, type, gimple_assign_rhs1 (stmt));
|
||||
else if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
|
||||
return gimple_assign_rhs1 (stmt);
|
||||
else
|
||||
gcc_unreachable ();
|
||||
switch (get_gimple_rhs_class (code))
|
||||
{
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
return fold_build3_loc (loc, code, type, gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt),
|
||||
gimple_assign_rhs3 (stmt));
|
||||
case GIMPLE_BINARY_RHS:
|
||||
return fold_build2_loc (loc, code, type, gimple_assign_rhs1 (stmt),
|
||||
gimple_assign_rhs2 (stmt));
|
||||
case GIMPLE_UNARY_RHS:
|
||||
return build1 (code, type, gimple_assign_rhs1 (stmt));
|
||||
case GIMPLE_SINGLE_RHS:
|
||||
return gimple_assign_rhs1 (stmt);
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Combine OP0 CODE OP1 in the context of a COND_EXPR. Returns
|
||||
|
Loading…
x
Reference in New Issue
Block a user