diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2014-05-17 14:37:58 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2014-05-17 12:37:58 +0000 |
commit | 87a34442667d0ecd397e141e26a64419fb71850c (patch) | |
tree | 9c6585b0e1d0714051cd59a6525632df8fb094bd /gcc | |
parent | 6ca74b5cf0e747981fed0a8e8e71cba37c03bd8b (diff) | |
download | gcc-87a34442667d0ecd397e141e26a64419fb71850c.zip gcc-87a34442667d0ecd397e141e26a64419fb71850c.tar.gz gcc-87a34442667d0ecd397e141e26a64419fb71850c.tar.bz2 |
re PR tree-optimization/61140 (wrong code at -O1 and above on x86_64-linux-gnu)
2014-05-17 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/61140
PR tree-optimization/61150
PR tree-optimization/61197
gcc/
* tree-ssa-phiopt.c (value_replacement): Punt on multiple phis.
gcc/testsuite/
* gcc.dg/tree-ssa/pr61140.c: New file.
* gcc.dg/tree-ssa/pr61150.c: New file.
* gcc.dg/tree-ssa/pr61197.c: New file.
From-SVN: r210554
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr61140.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr61150.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr61197.c | 26 | ||||
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 4 |
6 files changed, 88 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84345c0..daf6e1a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-05-17 Marc Glisse <marc.glisse@inria.fr> + + PR tree-optimization/61140 + PR tree-optimization/61150 + PR tree-optimization/61197 + * tree-ssa-phiopt.c (value_replacement): Punt on multiple phis. + 2014-05-17 Uros Bizjak <ubizjak@gmail.com> * doc/invoke.texi (free): Mention Alpha. Also enabled at -Os. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c400767..3c7ff36 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2014-05-17 Marc Glisse <marc.glisse@inria.fr> + + PR tree-optimization/61140 + PR tree-optimization/61150 + PR tree-optimization/61197 + * gcc.dg/tree-ssa/pr61140.c: New file. + * gcc.dg/tree-ssa/pr61150.c: New file. + * gcc.dg/tree-ssa/pr61197.c: New file. + 2014-05-17 Uros Bizjak <ubizjak@gmail.com> * g++.dg/pr60969.C: Compile for all ilp32 x86 targets. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c new file mode 100644 index 0000000..2f175cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61140.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +int a[1] = { 1 }, b = 1, c; + +int +main () +{ + for (; c < 1; c++) + if (a[0]) + { + a[0] &= 1; + b = 0; + } + if (b) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c new file mode 100644 index 0000000..c11798c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61150.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, b, c, d = 1; + +int +main () +{ + int e = d; + for (b = 0; b < 5; b++) + { + for (a = 0; a < 1; a++) + { + if (e) + break; + for (c = 0; c < 1; c++) + ; + } + e |= 1; + } + if (c) + __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c b/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c new file mode 100644 index 0000000..919578b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr61197.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +int a, b = 1, *c = &a; + +int +foo () +{ + if (b) + b |= 1; + else + { + b = 1; + return 0; + } + return 1; +} + +int +main () +{ + *c = foo (); + if (a != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index d4aaf42..e3b6f1d 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -849,6 +849,10 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, && !POINTER_TYPE_P (TREE_TYPE (arg0)))) return 0; + /* Only transform if it removes the condition. */ + if (!single_non_singleton_phi_for_edges (phi_nodes (gimple_bb (phi)), e0, e1)) + return 0; + /* Size-wise, this is always profitable. */ if (optimize_bb_for_speed_p (cond_bb) /* The special case is useless if it has a low probability. */ |