aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorYuri Rumyantsev <ysrumyan@gmail.com>2014-06-18 11:40:59 +0000
committerKirill Yukhin <kyukhin@gcc.gnu.org>2014-06-18 11:40:59 +0000
commit560c75e960fafc380191bf162a8e428a35e5fb67 (patch)
treea73d2e99228d20c464e25f44518f4a4346c72d1a /gcc
parent751738cb0c1aac9501284e6973d8438919edc581 (diff)
downloadgcc-560c75e960fafc380191bf162a8e428a35e5fb67.zip
gcc-560c75e960fafc380191bf162a8e428a35e5fb67.tar.gz
gcc-560c75e960fafc380191bf162a8e428a35e5fb67.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr61518.c29
-rw-r--r--gcc/tree-if-conv.c14
4 files changed, 54 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d0a07c..19f33b2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-18 Yuri Rumyantsev <ysrumyan@gmail.com>
+
+ 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 <kyrylo.tkachov@arm.com>
* config/arm/arm_neon.h (vadd_f32): Change #ifdef to __FAST_MATH.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c673056..702fc36 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-18 Yuri Rumyantsev <ysrumyan@gmail.com>
+
+ PR tree-optimization/61518
+ * gcc.dg/torture/pr61518.c: New test.
+
2014-06-18 Thomas Preud'homme <thomas.preudhomme@arm.com>
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 0000000..98429b0
--- /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 6e298d3..36a879d 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;