backport: re PR tree-optimization/56350 (ICE in vectorizable_reduction, at tree-vect-loop.c:4731)

Backported from mainline
	2013-02-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/56350
	* tree-vect-loop.c (vectorizable_reduction): If orig_stmt, return false
	if haven't found reduction or nested cycle operand, rather than
	asserting we must find it.

	* gcc.dg/pr56350.c: New test.

From-SVN: r196150
This commit is contained in:
Jakub Jelinek 2013-02-19 18:30:27 +01:00 committed by Jakub Jelinek
parent 3aef24e456
commit 3bd9de5476
4 changed files with 36 additions and 6 deletions

View File

@ -3,6 +3,11 @@
Backported from mainline
2013-02-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56350
* tree-vect-loop.c (vectorizable_reduction): If orig_stmt, return false
if haven't found reduction or nested cycle operand, rather than
asserting we must find it.
PR tree-optimization/56381
* tree-ssa-pre.c (create_expression_by_pieces): Fix up last argument
to fold_build3.

View File

@ -1,6 +1,11 @@
2013-02-19 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2013-02-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56350
* gcc.dg/pr56350.c: New test.
2013-02-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/56250

View File

@ -0,0 +1,13 @@
/* PR tree-optimization/56350 */
/* { dg-do compile } */
/* { dg-options "-O -ftree-vectorize" } */
int a, b, c;
void
f (void)
{
for (; c; c++)
for (b = 0; b < 2; b++)
a /= 8;
}

View File

@ -4522,7 +4522,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
The last use is the reduction variable. In case of nested cycle this
assumption is not true: we use reduc_index to record the index of the
reduction variable. */
for (i = 0; i < op_type-1; i++)
for (i = 0; i < op_type - 1; i++)
{
/* The condition of COND_EXPR is checked in vectorizable_condition(). */
if (i == 0 && code == COND_EXPR)
@ -4554,11 +4554,18 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi,
if (!vectype_in)
vectype_in = tem;
gcc_assert (is_simple_use);
gcc_assert (dt == vect_reduction_def
|| dt == vect_nested_cycle
|| ((dt == vect_internal_def || dt == vect_external_def
|| dt == vect_constant_def || dt == vect_induction_def)
&& nested_cycle && found_nested_cycle_def));
if (!(dt == vect_reduction_def
|| dt == vect_nested_cycle
|| ((dt == vect_internal_def || dt == vect_external_def
|| dt == vect_constant_def || dt == vect_induction_def)
&& nested_cycle && found_nested_cycle_def)))
{
/* For pattern recognized stmts, orig_stmt might be a reduction,
but some helper statements for the pattern might not, or
might be COND_EXPRs with reduction uses in the condition. */
gcc_assert (orig_stmt);
return false;
}
if (!found_nested_cycle_def)
reduc_def_stmt = def_stmt;