diff options
author | Jakub Jelinek <jakub@redhat.com> | 2015-02-26 22:03:14 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2015-02-26 22:03:14 +0100 |
commit | d288c0abe62b0ea097852174651c5b87c2ac7800 (patch) | |
tree | ea8d3e047154e05c0b011c78cf24dced1dc536c4 /gcc | |
parent | 5c2766c1a7a6ecf866d4aaa72e2e2a497fcc7995 (diff) | |
download | gcc-d288c0abe62b0ea097852174651c5b87c2ac7800.zip gcc-d288c0abe62b0ea097852174651c5b87c2ac7800.tar.gz gcc-d288c0abe62b0ea097852174651c5b87c2ac7800.tar.bz2 |
re PR tree-optimization/65216 (wrong code at -O3 on x86_64-linux-gnu)
PR tree-optimization/65216
* tree-ssa-reassoc.c (rewrite_expr_tree): Force creation of
new stmt and new SSA_NAME for lhs whenever the arguments have
changed and weren't just swapped. Fix comment typo.
* gcc.c-torture/execute/pr65216.c: New test.
From-SVN: r221034
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr65216.c | 20 | ||||
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 8 |
4 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1bbd014..9743435 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2015-02-26 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/65216 + * tree-ssa-reassoc.c (rewrite_expr_tree): Force creation of + new stmt and new SSA_NAME for lhs whenever the arguments have + changed and weren't just swapped. Fix comment typo. + PR tree-optimization/65215 * tree-ssa-math-opts.c (find_bswap_or_nop_load): Return false for PDP endian targets. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1852d25..93fc50f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-02-26 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/65216 + * gcc.c-torture/execute/pr65216.c: New test. + PR tree-optimization/65215 * gcc.c-torture/execute/pr65215-1.c: New test. * gcc.c-torture/execute/pr65215-2.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr65216.c b/gcc/testsuite/gcc.c-torture/execute/pr65216.c new file mode 100644 index 0000000..0714d8c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr65216.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/65216 */ + +int a, b = 62, e; +volatile int c, d; + +int +main () +{ + int f = 0; + for (a = 0; a < 2; a++) + { + b &= (8 ^ f) & 1; + for (e = 0; e < 6; e++) + if (c) + f = d; + } + if (b != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index ce37053..2e933e7 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -3532,7 +3532,7 @@ rewrite_expr_tree (gimple stmt, unsigned int opindex, /* The final recursion case for this function is that you have exactly two operations left. - If we had one exactly one op in the entire list to start with, we + If we had exactly one op in the entire list to start with, we would have never called this function, and the tail recursion rewrites them one at a time. */ if (opindex + 2 == ops.length ()) @@ -3553,7 +3553,11 @@ rewrite_expr_tree (gimple stmt, unsigned int opindex, print_gimple_stmt (dump_file, stmt, 0, 0); } - if (changed) + /* 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 + return lhs), force creation of a new SSA_NAME. */ + if (changed || ((rhs1 != oe2->op || rhs2 != oe1->op) && opindex)) { gimple insert_point = find_insert_point (stmt, oe1->op, oe2->op); lhs = make_ssa_name (TREE_TYPE (lhs)); |