From 91c4c1db4a2508c341ffefd5ccf6333ad38a4ae0 Mon Sep 17 00:00:00 2001 From: kyukhin Date: Tue, 8 Jul 2014 07:52:12 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212347 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr61576.c | 29 +++++++++++++++++++++++++++++ gcc/tree-if-conv.c | 8 +++++++- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr61576.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index edf3dc11d5e..84ed7824c3b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-07-08 Yuri Rumyantsev + + 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 PR c/60226 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9940e724cb3..1350da434d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-07-08 Yuri Rumyantsev + + PR tree-optimization/61576 + * gcc.dg/torture/pr61576.c: New test. + 2014-07-08 Marek Polacek 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 00000000000..4ac755dab3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61576.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +#include +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 36a879d1e7b..98962c2fdec 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; -- 2.11.4.GIT