re PR tree-optimization/91293 (Wrong code with -O3 -mavx2)

2019-07-31  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91293
	* tree-vect-slp.c (vect_build_slp_tree_2): Do not swap operands
	of reduction stmts.

	* gcc.dg/vect/pr91293-1.c: New testcase.
	* gcc.dg/vect/pr91293-2.c: Likewise.
	* gcc.dg/vect/pr91293-3.c: Likewise.

From-SVN: r273934
This commit is contained in:
Richard Biener 2019-07-31 14:15:37 +00:00 committed by Richard Biener
parent 428642b132
commit 2153fa7b60
6 changed files with 74 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2019-07-31 Richard Biener <rguenther@suse.de>
PR tree-optimization/91293
* tree-vect-slp.c (vect_build_slp_tree_2): Do not swap operands
of reduction stmts.
2019-07-31 Matt Thomas <matt@3am-software.com>
Nick Hudson <nick@nthcliff.demon.co.uk>
Matthew Green <mrg@eterna.com.au>

View file

@ -1,3 +1,10 @@
2019-07-31 Richard Biener <rguenther@suse.de>
PR tree-optimization/91293
* gcc.dg/vect/pr91293-1.c: New testcase.
* gcc.dg/vect/pr91293-2.c: Likewise.
* gcc.dg/vect/pr91293-3.c: Likewise.
2019-07-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/91201

View file

@ -0,0 +1,19 @@
/* { dg-do run } */
/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */
long long a;
unsigned b, c;
int d = 62;
void e(long long *f, int p2) { *f = p2; }
int main()
{
for (int g = 2; g <= d; g++)
{
b += g + 4;
c += 5 - g;
}
e(&a, b);
if (a != 2196)
__builtin_abort ();
return 0;
}

View file

@ -0,0 +1,19 @@
/* { dg-do run } */
/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */
long long a;
unsigned b, c;
int d = 62;
void e(long long *f, int p2) { *f = p2; }
int main()
{
for (int g = 2; g <= d; g++)
{
c += 5 - g;
b += g + 4;
}
e(&a, b);
if (a != 2196)
__builtin_abort ();
return 0;
}

View file

@ -0,0 +1,20 @@
/* { dg-do run } */
/* { dg-additional-options "-msse4.1" { target { sse4_runtime } } } */
long long a;
unsigned b, c;
int d = 62;
void e(long long *f, int p2) { *f = p2; }
int xx = 5, yy = 4;
int main()
{
for (int g = 2; g <= d; g++)
{
c += xx - g;
b += yy + g;
}
e(&a, b);
if (a != 2196)
__builtin_abort ();
return 0;
}

View file

@ -1296,6 +1296,9 @@ vect_build_slp_tree_2 (vec_info *vinfo,
&& nops == 2
&& oprnds_info[1]->first_dt == vect_internal_def
&& is_gimple_assign (stmt_info->stmt)
/* Swapping operands for reductions breaks assumptions later on. */
&& STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
&& STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def
/* Do so only if the number of not successful permutes was nor more
than a cut-ff as re-trying the recursive match on
possibly each level of the tree would expose exponential