Commit 12c667b5 by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/80631 (Compiling with -O3 -mavx2 gives wrong code)

	PR tree-optimization/80631
	* tree-vect-loop.c (get_initial_def_for_reduction): Fix comment typo.
	(vect_create_epilog_for_reduction): Add INDUC_VAL and INDUC_CODE
	arguments, for INTEGER_INDUC_COND_REDUCTION use INDUC_VAL instead of
	hardcoding zero as the value if COND_EXPR is never true.  For
	INTEGER_INDUC_COND_REDUCTION don't emit the final COND_EXPR if
	INDUC_VAL is equal to INITIAL_DEF, and use INDUC_CODE instead of
	hardcoding MAX_EXPR as the reduction operation.
	(is_nonwrapping_integer_induction): Allow negative step.
	(vectorizable_reduction): Compute INDUC_VAL and INDUC_CODE for
	vect_create_epilog_for_reduction, if no value is suitable, don't
	use INTEGER_INDUC_COND_REDUCTION for now.  Formatting fixes.

	* gcc.dg/vect/pr80631-1.c: New test.
	* gcc.dg/vect/pr80631-2.c: New test.
	* gcc.dg/vect/pr65947-13.c: Expect integer induc cond reduction
	vectorization.

From-SVN: r255574
parent 5b0c69ae
2017-12-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/80631
* tree-vect-loop.c (get_initial_def_for_reduction): Fix comment typo.
(vect_create_epilog_for_reduction): Add INDUC_VAL and INDUC_CODE
arguments, for INTEGER_INDUC_COND_REDUCTION use INDUC_VAL instead of
hardcoding zero as the value if COND_EXPR is never true. For
INTEGER_INDUC_COND_REDUCTION don't emit the final COND_EXPR if
INDUC_VAL is equal to INITIAL_DEF, and use INDUC_CODE instead of
hardcoding MAX_EXPR as the reduction operation.
(is_nonwrapping_integer_induction): Allow negative step.
(vectorizable_reduction): Compute INDUC_VAL and INDUC_CODE for
vect_create_epilog_for_reduction, if no value is suitable, don't
use INTEGER_INDUC_COND_REDUCTION for now. Formatting fixes.
2017-12-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/81889
2017-12-12 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/80631
* gcc.dg/vect/pr80631-1.c: New test.
* gcc.dg/vect/pr80631-2.c: New test.
* gcc.dg/vect/pr65947-13.c: Expect integer induc cond reduction
vectorization.
2017-12-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/81889
......
......@@ -6,8 +6,7 @@ extern void abort (void) __attribute__ ((noreturn));
#define N 32
/* Simple condition reduction with a reversed loop.
Will fail to vectorize to a simple case. */
/* Simple condition reduction with a reversed loop. */
int
condition_reduction (int *a, int min_v)
......@@ -42,4 +41,4 @@ main (void)
}
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */
/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */
/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 4 "vect" } } */
/* PR tree-optimization/80631 */
/* { dg-do run } */
#include "tree-vect.h"
int v[8] = { 77, 1, 79, 3, 4, 3, 6, 7 };
__attribute__((noipa)) void
f1 (void)
{
int k, r = -1;
for (k = 0; k < 8; k++)
if (v[k] == 77)
r = k;
if (r != 0)
abort ();
}
__attribute__((noipa)) void
f2 (void)
{
int k, r = 4;
for (k = 0; k < 8; k++)
if (v[k] == 79)
r = k;
if (r != 2)
abort ();
}
__attribute__((noipa)) void
f3 (void)
{
int k, r = -17;
for (k = 0; k < 8; k++)
if (v[k] == 78)
r = k;
if (r != -17)
abort ();
}
__attribute__((noipa)) void
f4 (void)
{
int k, r = 7;
for (k = 0; k < 8; k++)
if (v[k] == 78)
r = k;
if (r != 7)
abort ();
}
__attribute__((noipa)) void
f5 (void)
{
int k, r = -1;
for (k = 0; k < 8; k++)
if (v[k] == 3)
r = k;
if (r != 5)
abort ();
}
int
main ()
{
check_vect ();
f1 ();
f2 ();
f3 ();
f4 ();
f5 ();
return 0;
}
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 5 "vect" { target vect_condition } } } */
/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 10 "vect" { target vect_condition } } } */
/* PR tree-optimization/80631 */
/* { dg-do run } */
#include "tree-vect.h"
int v[8] = { 77, 1, 79, 3, 4, 3, 6, 7 };
__attribute__((noipa)) void
f1 (void)
{
int k, r = -1;
for (k = 7; k >= 0; k--)
if (v[k] == 77)
r = k;
if (r != 0)
abort ();
}
__attribute__((noipa)) void
f2 (void)
{
int k, r = 4;
for (k = 7; k >= 0; k--)
if (v[k] == 79)
r = k;
if (r != 2)
abort ();
}
__attribute__((noipa)) void
f3 (void)
{
int k, r = -17;
for (k = 7; k >= 0; k--)
if (v[k] == 78)
r = k;
if (r != -17)
abort ();
}
__attribute__((noipa)) void
f4 (void)
{
int k, r = 7;
for (k = 7; k >= 0; k--)
if (v[k] == 78)
r = k;
if (r != 7)
abort ();
}
__attribute__((noipa)) void
f5 (void)
{
int k, r = -1;
for (k = 7; k >= 0; k--)
if (v[k] == 3)
r = k;
if (r != 3)
abort ();
}
int
main ()
{
check_vect ();
f1 ();
f2 ();
f3 ();
f4 ();
f5 ();
return 0;
}
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 5 "vect" { target vect_condition } } } */
/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 10 "vect" { target vect_condition } } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment