diff options
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 7e1d8c77a3f..03c6c5dbfa4 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1141,6 +1141,14 @@ zero_one_operation (tree *def, enum tree_code opcode, tree op) while (1); } +/* Returns the UID of STMT if it is non-NULL. Otherwise return 1. */ + +static inline unsigned +get_stmt_uid_with_default (gimple stmt) +{ + return stmt ? gimple_uid (stmt) : 1; +} + /* Builds one statement performing OP1 OPCODE OP2 using TMPVAR for the result. Places the statement after the definition of either OP1 or OP2. Returns the new statement. */ @@ -1165,12 +1173,8 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode) if ((!op1def || gimple_nop_p (op1def)) && (!op2def || gimple_nop_p (op2def))) { - gimple first_stmt; - unsigned uid; gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR)); - first_stmt = gsi_stmt (gsi); - uid = first_stmt ? gimple_uid (first_stmt) : 1; - gimple_set_uid (sum, uid); + gimple_set_uid (sum, get_stmt_uid_with_default (gsi_stmt (gsi))); gsi_insert_before (&gsi, sum, GSI_NEW_STMT); } else if ((!op1def || gimple_nop_p (op1def)) @@ -1180,7 +1184,7 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode) if (gimple_code (op2def) == GIMPLE_PHI) { gsi = gsi_after_labels (gimple_bb (op2def)); - gimple_set_uid (sum, gimple_uid (gsi_stmt (gsi))); + gimple_set_uid (sum, get_stmt_uid_with_default (gsi_stmt (gsi))); gsi_insert_before (&gsi, sum, GSI_NEW_STMT); } else @@ -1207,7 +1211,7 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode) if (gimple_code (op1def) == GIMPLE_PHI) { gsi = gsi_after_labels (gimple_bb (op1def)); - gimple_set_uid (sum, gimple_uid (op1def)); + gimple_set_uid (sum, get_stmt_uid_with_default (gsi_stmt (gsi))); gsi_insert_before (&gsi, sum, GSI_NEW_STMT); } else @@ -2860,7 +2864,7 @@ not_dominated_by (gimple a, gimple b) basic_block bb_a, bb_b; bb_a = gimple_bb (a); bb_b = gimple_bb (b); - return ((bb_a == bb_b && gimple_uid (a) < gimple_uid (b)) + return ((bb_a == bb_b && gimple_uid (a) < gimple_uid (b)) || (bb_a != bb_b && !dominated_by_p (CDI_DOMINATORS, bb_a, bb_b))); @@ -2874,10 +2878,7 @@ appears_later_in_bb (gimple stmt1, gimple stmt2) { unsigned uid = gimple_uid (stmt1); gimple_stmt_iterator gsi = gsi_for_stmt (stmt1); - gsi_next (&gsi); - if (gsi_end_p (gsi)) - return stmt1; - for (; !gsi_end_p (gsi); gsi_next (&gsi)) + for (gsi_next (&gsi); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); |