diff options
author | Kugan Vivekanandarajah <kuganv@linaro.org> | 2016-05-30 10:47:57 +0000 |
---|---|---|
committer | Kugan Vivekanandarajah <kugan@gcc.gnu.org> | 2016-05-30 10:47:57 +0000 |
commit | 5d476e35f0d9877b34330e9df9b6f72d33020533 (patch) | |
tree | 4bd7ac6454dc0b3294ce67725411c6bfec7fb42d /gcc | |
parent | db5447cad85ddee2973bc95cb5d4890b8c3d847b (diff) | |
download | gcc-5d476e35f0d9877b34330e9df9b6f72d33020533.zip gcc-5d476e35f0d9877b34330e9df9b6f72d33020533.tar.gz gcc-5d476e35f0d9877b34330e9df9b6f72d33020533.tar.bz2 |
re PR middle-end/71269 (segfault while compiling sqlite)
gcc/testsuite/ChangeLog:
2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/71269
PR middle-end/71292
* gcc.dg/tree-ssa/pr71269.c: New test.
* gcc.dg/tree-ssa/pr71292.c: New test.
gcc/ChangeLog:
2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/71269
PR middle-end/71252
* tree-ssa-reassoc.c (insert_stmt_before_use): Use find_insert_point so
that inserted stmt will not dominate stmts that defines its operand.
(rewrite_expr_tree): Add stmt_to_insert before adding the use stmt.
(rewrite_expr_tree_parallel): Likewise.
From-SVN: r236876
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr71269.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr71292.c | 12 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 71 |
5 files changed, 75 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c88748f..e328b41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org> + PR middle-end/71269 + PR middle-end/71252 + * tree-ssa-reassoc.c (insert_stmt_before_use): Use find_insert_point so + that inserted stmt will not dominate stmts that defines its operand. + (rewrite_expr_tree): Add stmt_to_insert before adding the use stmt. + (rewrite_expr_tree_parallel): Likewise. + +2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org> + PR middle-end/71252 * tree-ssa-reassoc.c (swap_ops_for_binary_stmt): Fix swap such that all fields including stmt_to_insert are swapped. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 37f06b7..9d233f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org> + PR middle-end/71269 + PR middle-end/71292 + * gcc.dg/tree-ssa/pr71269.c: New test. + * gcc.dg/tree-ssa/pr71292.c: New test. + +2016-05-30 Kugan Vivekanandarajah <kuganv@linaro.org> + PR middle-end/71252 * gcc.dg/tree-ssa/pr71252-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71269.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71269.c new file mode 100644 index 0000000..4dceaaa --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71269.c @@ -0,0 +1,10 @@ +/* PR middle-end/71269 */ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int a, b, c; +void fn2 (int); +void fn1 () +{ + fn2 (sizeof 0 + c + a + b + b); +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71292.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71292.c new file mode 100644 index 0000000..1a25d93 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71292.c @@ -0,0 +1,12 @@ +/* PR middle-end/71292 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned long a; +long b, d; +int c; +void fn1 () +{ + unsigned long e = a + c; + b = d + e + a + 8; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index d13be29..9c06ca0 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1777,16 +1777,6 @@ eliminate_redundant_comparison (enum tree_code opcode, return false; } -/* If the stmt that defines operand has to be inserted, insert it - before the use. */ -static void -insert_stmt_before_use (gimple *stmt, gimple *stmt_to_insert) -{ - gimple_stmt_iterator gsi = gsi_for_stmt (stmt); - gimple_set_uid (stmt_to_insert, gimple_uid (stmt)); - gsi_insert_before (&gsi, stmt_to_insert, GSI_NEW_STMT); -} - /* Transform repeated addition of same values into multiply with constant. */ @@ -3787,6 +3777,29 @@ find_insert_point (gimple *stmt, tree rhs1, tree rhs2) return stmt; } +/* If the stmt that defines operand has to be inserted, insert it + before the use. */ +static void +insert_stmt_before_use (gimple *stmt, gimple *stmt_to_insert) +{ + gcc_assert (is_gimple_assign (stmt_to_insert)); + tree rhs1 = gimple_assign_rhs1 (stmt_to_insert); + tree rhs2 = gimple_assign_rhs2 (stmt_to_insert); + gimple *insert_point = find_insert_point (stmt, rhs1, rhs2); + gimple_stmt_iterator gsi = gsi_for_stmt (insert_point); + gimple_set_uid (stmt_to_insert, gimple_uid (insert_point)); + + /* If the insert point is not stmt, then insert_point would be + the point where operand rhs1 or rhs2 is defined. In this case, + stmt_to_insert has to be inserted afterwards. This would + only happen when the stmt insertion point is flexible. */ + if (stmt == insert_point) + gsi_insert_before (&gsi, stmt_to_insert, GSI_NEW_STMT); + else + insert_stmt_after (stmt_to_insert, insert_point); +} + + /* Recursively rewrite our linearized statements so that the operators match those in OPS[OPINDEX], putting the computation in rank order. Return new lhs. */ @@ -3823,6 +3836,12 @@ rewrite_expr_tree (gimple *stmt, unsigned int opindex, print_gimple_stmt (dump_file, stmt, 0, 0); } + /* If the stmt that defines operand has to be inserted, insert it + before the use. */ + if (oe1->stmt_to_insert) + insert_stmt_before_use (stmt, oe1->stmt_to_insert); + if (oe2->stmt_to_insert) + insert_stmt_before_use (stmt, oe2->stmt_to_insert); /* Even when changed is false, reassociation could have e.g. removed some redundant operations, so unless we are just swapping the arguments or unless there is no change at all (then we just @@ -3831,12 +3850,6 @@ rewrite_expr_tree (gimple *stmt, unsigned int opindex, { gimple *insert_point = find_insert_point (stmt, oe1->op, oe2->op); - /* If the stmt that defines operand has to be inserted, insert it - before the use. */ - if (oe1->stmt_to_insert) - insert_stmt_before_use (stmt, oe1->stmt_to_insert); - if (oe2->stmt_to_insert) - insert_stmt_before_use (stmt, oe2->stmt_to_insert); lhs = make_ssa_name (TREE_TYPE (lhs)); stmt = gimple_build_assign (lhs, gimple_assign_rhs_code (stmt), @@ -3852,12 +3865,6 @@ rewrite_expr_tree (gimple *stmt, unsigned int opindex, { gcc_checking_assert (find_insert_point (stmt, oe1->op, oe2->op) == stmt); - /* If the stmt that defines operand has to be inserted, insert it - before the use. */ - if (oe1->stmt_to_insert) - insert_stmt_before_use (stmt, oe1->stmt_to_insert); - if (oe2->stmt_to_insert) - insert_stmt_before_use (stmt, oe2->stmt_to_insert); gimple_assign_set_rhs1 (stmt, oe1->op); gimple_assign_set_rhs2 (stmt, oe2->op); update_stmt (stmt); @@ -4097,16 +4104,18 @@ rewrite_expr_tree_parallel (gassign *stmt, int width, print_gimple_stmt (dump_file, stmts[i], 0, 0); } + /* If the stmt that defines operand has to be inserted, insert it + before the use. */ + if (stmt1) + insert_stmt_before_use (stmts[i], stmt1); + if (stmt2) + insert_stmt_before_use (stmts[i], stmt2); + stmt1 = stmt2 = NULL; + /* We keep original statement only for the last one. All others are recreated. */ if (i == stmt_num - 1) { - /* If the stmt that defines operand has to be inserted, insert it - before the use. */ - if (stmt1) - insert_stmt_before_use (stmts[i], stmt1); - if (stmt2) - insert_stmt_before_use (stmts[i], stmt2); gimple_assign_set_rhs1 (stmts[i], op1); gimple_assign_set_rhs2 (stmts[i], op2); update_stmt (stmts[i]); @@ -4114,12 +4123,6 @@ rewrite_expr_tree_parallel (gassign *stmt, int width, else { stmts[i] = build_and_add_sum (TREE_TYPE (last_rhs1), op1, op2, opcode); - /* If the stmt that defines operand has to be inserted, insert it - before new build_and_add stmt after it is created. */ - if (stmt1) - insert_stmt_before_use (stmts[i], stmt1); - if (stmt2) - insert_stmt_before_use (stmts[i], stmt2); } if (dump_file && (dump_flags & TDF_DETAILS)) { |