diff options
author | Yuri Rumyantsev <ysrumyan@gmail.com> | 2014-07-08 07:52:12 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2014-07-08 07:52:12 +0000 |
commit | 0f6284d27f11d16cced47627deb022041f8c9cac (patch) | |
tree | fd782f878125aa7106ac5a7c54a0d726e5abe2e1 | |
parent | 605f12f4dcb80940461150cfa9427a12653d8ed3 (diff) | |
download | gcc-0f6284d27f11d16cced47627deb022041f8c9cac.zip gcc-0f6284d27f11d16cced47627deb022041f8c9cac.tar.gz gcc-0f6284d27f11d16cced47627deb022041f8c9cac.tar.bz2 |
re PR tree-optimization/61576 (wrong code at -O3 on x86_64-linux-gnu)
PR tree-optimization/61576
gcc/
* tree-if-conv.c (is_cond_scalar_reduction): Add check that
basic block containing reduction statement is predecessor
of phi basi block.
gcc/testsuite/
* gcc.dg/torture/pr61576.c: New test.
From-SVN: r212347
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr61576.c | 29 | ||||
-rw-r--r-- | gcc/tree-if-conv.c | 8 |
4 files changed, 48 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index edf3dc1..84ed782 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-07-08 Yuri Rumyantsev <ysrumyan@gmail.com> + + PR tree-optimization/61576 + * tree-if-conv.c (is_cond_scalar_reduction): Add check that + basic block containing reduction statement is predecessor + of phi basi block. + 2014-07-08 Marek Polacek <polacek@redhat.com> PR c/60226 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9940e72..1350da4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-07-08 Yuri Rumyantsev <ysrumyan@gmail.com> + + PR tree-optimization/61576 + * gcc.dg/torture/pr61576.c: New test. + 2014-07-08 Marek Polacek <polacek@redhat.com> PR c/60226 diff --git a/gcc/testsuite/gcc.dg/torture/pr61576.c b/gcc/testsuite/gcc.dg/torture/pr61576.c new file mode 100644 index 0000000..4ac755d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61576.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +#include <stdlib.h> +volatile int a, b; +int c, d, e, f; + +static int +fn1 () +{ + if (b) + { + d++; + e = c || f; + } + return 0; +} + +int +main () +{ + for (; a < 1; a++) + { + fn1 (); + continue; + } + if (d != 0) + abort(); + return 0; +} diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 36a879d..98962c2 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1407,7 +1407,8 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc, gimple stmt; gimple header_phi = NULL; enum tree_code reduction_op; - struct loop *loop = gimple_bb (phi)->loop_father; + basic_block bb = gimple_bb (phi); + struct loop *loop = bb->loop_father; edge latch_e = loop_latch_edge (loop); imm_use_iterator imm_iter; use_operand_p use_p; @@ -1447,6 +1448,11 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc, if (!is_predicated (gimple_bb (stmt))) return false; + /* Check that stmt-block is predecessor of phi-block. */ + if (EDGE_PRED (bb, 0)->src != gimple_bb (stmt) + && EDGE_PRED (bb, 1)->src != gimple_bb (stmt)) + return false; + if (!has_single_use (lhs)) return false; |