From: Yuri Rumyantsev Date: Tue, 8 Jul 2014 07:52:12 +0000 (+0000) Subject: re PR tree-optimization/61576 (wrong code at -O3 on x86_64-linux-gnu) X-Git-Tag: releases/gcc-5.1.0~6463 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f6284d27f11d16cced47627deb022041f8c9cac;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index edf3dc11d5e3..84ed7824c3b9 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 9940e724cb30..1350da434d64 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 000000000000..4ac755dab3cd --- /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 36a879d1e7bb..98962c2fdecc 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;