From: Yuri Rumyantsev Date: Wed, 18 Jun 2014 11:40:59 +0000 (+0000) Subject: re PR tree-optimization/61518 (wrong code (by tree vectorizer) at -O3 on x86_64-linux... X-Git-Tag: releases/gcc-5.1.0~6801 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=560c75e960fafc380191bf162a8e428a35e5fb67;p=thirdparty%2Fgcc.git re PR tree-optimization/61518 (wrong code (by tree vectorizer) at -O3 on x86_64-linux-gnu) PR tree-optimization/61518 gcc/ * tree-if-conv.c (is_cond_scalar_reduction): Add missed check that reduction var is used in reduction stmt or phi-function only. gcc/testsuite/ * gcc.dg/torture/pr61518.c: New test. From-SVN: r211780 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d0a07cda659..19f33b2041c6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-06-18 Yuri Rumyantsev + + PR tree-optimization/61518 + * tree-if-conv.c (is_cond_scalar_reduction): Add missed check that + reduction var is used in reduction stmt or phi-function only. + 2014-06-18 Kyrylo Tkachov * config/arm/arm_neon.h (vadd_f32): Change #ifdef to __FAST_MATH. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c67305601e6b..702fc36af5cf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-06-18 Yuri Rumyantsev + + PR tree-optimization/61518 + * gcc.dg/torture/pr61518.c: New test. + 2014-06-18 Thomas Preud'homme PR tree-optimization/61517 diff --git a/gcc/testsuite/gcc.dg/torture/pr61518.c b/gcc/testsuite/gcc.dg/torture/pr61518.c new file mode 100644 index 000000000000..98429b09a93d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr61518.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ + +int a, b, c[1], d, e, f; + +void +fn1 () +{ + for (; d < 1; d++) + { + if (b) + { + a = e++ && f; + b = f; + } + c[b] = 0; + } +} + +int +main () +{ + fn1 (); + + if (e != 0) + __builtin_abort (); + + return 0; +} + diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 6e298d328aa6..36a879d1e7bb 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -1409,6 +1409,8 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc, enum tree_code reduction_op; struct loop *loop = gimple_bb (phi)->loop_father; edge latch_e = loop_latch_edge (loop); + imm_use_iterator imm_iter; + use_operand_p use_p; arg_0 = PHI_ARG_DEF (phi, 0); arg_1 = PHI_ARG_DEF (phi, 1); @@ -1465,6 +1467,18 @@ is_cond_scalar_reduction (gimple phi, gimple *reduc, else if (r_op1 != PHI_RESULT (header_phi)) return false; + /* Check that R_OP1 is used in reduction stmt or in PHI only. */ + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, r_op1) + { + gimple use_stmt = USE_STMT (use_p); + if (is_gimple_debug (use_stmt)) + continue; + if (use_stmt == stmt) + continue; + if (gimple_code (use_stmt) != GIMPLE_PHI) + return false; + } + *op0 = r_op1; *op1 = r_op2; *reduc = stmt; return true;