From df0675b8336a12cae7dd1c3a4629918577ba06b4 Mon Sep 17 00:00:00 2001 From: rguenth Date: Tue, 16 Nov 2010 14:15:55 +0000 Subject: 2010-11-16 Richard Guenther PR tree-optimization/44545 * tree-ssa-reassoc.c (linearize_expr_tree): Possibly throwing statements are not reassociatable. (reassociate_bb): Likewise. * gcc.dg/pr44545.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166799 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr44545.c | 13 +++++++++++++ gcc/tree-ssa-reassoc.c | 9 ++++++--- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr44545.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 273b853474b..9bfc01bd56e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-11-16 Richard Guenther + + PR tree-optimization/44545 + * tree-ssa-reassoc.c (linearize_expr_tree): Possibly throwing + statements are not reassociatable. + (reassociate_bb): Likewise. + 2010-11-16 Nathan Froyd * bitmap.c: Delete unnecessary includes. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1684d0ff7c8..1ffbb15a1f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-16 Richard Guenther + + PR tree-optimization/44545 + * gcc.dg/pr44545.c: New testcase. + 2010-11-16 Andrey Belevantsev PR rtl-optimization/46366 diff --git a/gcc/testsuite/gcc.dg/pr44545.c b/gcc/testsuite/gcc.dg/pr44545.c new file mode 100644 index 00000000000..51983ef76b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr44545.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions" } */ +int +DrawChunk(int *tabSize, int x) +{ + const int numEnds = 10; + int ends[numEnds + 2]; + if (*tabSize > 0) { + x -= 5; + x = (x + *tabSize) / *tabSize; + } +} + diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 790635cf05b..197591e330f 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1786,13 +1786,15 @@ linearize_expr_tree (VEC(operand_entry_t, heap) **ops, gimple stmt, if (TREE_CODE (binlhs) == SSA_NAME) { binlhsdef = SSA_NAME_DEF_STMT (binlhs); - binlhsisreassoc = is_reassociable_op (binlhsdef, rhscode, loop); + binlhsisreassoc = (is_reassociable_op (binlhsdef, rhscode, loop) + && !stmt_could_throw_p (binlhsdef)); } if (TREE_CODE (binrhs) == SSA_NAME) { binrhsdef = SSA_NAME_DEF_STMT (binrhs); - binrhsisreassoc = is_reassociable_op (binrhsdef, rhscode, loop); + binrhsisreassoc = (is_reassociable_op (binrhsdef, rhscode, loop) + && !stmt_could_throw_p (binrhsdef)); } /* If the LHS is not reassociable, but the RHS is, we need to swap @@ -2027,7 +2029,8 @@ reassociate_bb (basic_block bb) { gimple stmt = gsi_stmt (gsi); - if (is_gimple_assign (stmt)) + if (is_gimple_assign (stmt) + && !stmt_could_throw_p (stmt)) { tree lhs, rhs1, rhs2; enum tree_code rhs_code = gimple_assign_rhs_code (stmt); -- cgit v1.2.1