summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-reassoc.c
diff options
context:
space:
mode:
authoreraman <eraman@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-04 17:48:15 +0000
committereraman <eraman@138bc75d-0d04-0410-961f-82ee72b054a4>2013-09-04 17:48:15 +0000
commitc9dbb922205f25ad7a759c2a0fdfc4545fb9b371 (patch)
tree978a3db48b7e445927f02ae5baf19f5a0cba2a00 /gcc/tree-ssa-reassoc.c
parent7d500d30a2205a6e6e6783a4b92cc38d66f3b70b (diff)
downloadgcc-c9dbb922205f25ad7a759c2a0fdfc4545fb9b371.tar.gz
2013-09-04 Easwaran Raman <eraman@google.com>
PR middle-end/57370 PR tree-optimization/58011 * tree-ssa-reassoc.c (get_stmt_uid_with_default): New function, (build_and_add_sum): Use it. (appears_later_in_bb): Simplify code. gcc/testsuite/ChangeLog: 2013-09-04 Easwaran Raman <eraman@google.com> PR middle-end/57370 PR tree-optimization/58011 * gfortran.dg/reassoc_12.f90: New testcase. * gcc.dg/tree-ssa/reassoc-31.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202262 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r--gcc/tree-ssa-reassoc.c25
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);