Commit 71c92d17 by Jakub Jelinek

re PR tree-optimization/50596 (Problems in vectorization of condition expression)

	PR tree-optimization/50596
	* tree-vectorizer.h (NUM_PATTERNS): Increase to 7.
	* tree-vect-patterns.c (vect_vect_recog_func_ptrs): Add
	vect_recog_bool_pattern.
	(check_bool_pattern, adjust_bool_pattern_cast,
	adjust_bool_pattern, vect_recog_bool_pattern): New functions.

	* gcc.dg/vect/vect-cond-9.c: New test.

From-SVN: r180057
parent ea10ca9c
2011-10-16 Ira Rosen <ira.rosen@linaro.org> 2011-10-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/50596
* tree-vectorizer.h (NUM_PATTERNS): Increase to 7.
* tree-vect-patterns.c (vect_vect_recog_func_ptrs): Add
vect_recog_bool_pattern.
(check_bool_pattern, adjust_bool_pattern_cast,
adjust_bool_pattern, vect_recog_bool_pattern): New functions.
* gcc.dg/vect/vect-cond-9.c: New test.
2011-10-16 Ira Rosen <ira.rosen@linaro.org>
* tree-vect-stmts.c (vectorizable_load): For SLP without permutation * tree-vect-stmts.c (vectorizable_load): For SLP without permutation
treat the first load of the node as the first element in its treat the first load of the node as the first element in its
2011-10-16 Ira Rosen <ira.rosen@linaro.org> 2011-10-16 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/50596
* gcc.dg/vect/vect-cond-9.c: New test.
2011-10-16 Ira Rosen <ira.rosen@linaro.org>
* gcc.dg/vect/bb-slp-29.c: New test. * gcc.dg/vect/bb-slp-29.c: New test.
......
/* { dg-require-effective-target vect_cond_mixed } */
#include "tree-vect.h"
#define N 1024
float a[N], b[N], c[N], d[N];
int j[N];
unsigned char k[N];
__attribute__((noinline, noclone)) void
f1 (void)
{
int i;
for (i = 0; i < N; ++i)
{
unsigned int x = a[i] < b[i] ? -1 : 0;
unsigned int y = c[i] < d[i] ? -1 : 0;
j[i] = (x & y) >> 31;
}
}
__attribute__((noinline, noclone)) void
f2 (void)
{
int i;
for (i = 0; i < N; ++i)
{
int x = a[i] < b[i];
int y = c[i] < d[i];
j[i] = x & y;
}
}
__attribute__((noinline, noclone)) void
f3 (void)
{
int i;
for (i = 0; i < N; ++i)
j[i] = (a[i] < b[i]) & (c[i] < d[i]);
}
__attribute__((noinline, noclone)) void
f4 (void)
{
int i;
for (i = 0; i < N; ++i)
{
int x = a[i] < b[i];
int y = c[i] < d[i];
k[i] = x & y;
}
}
__attribute__((noinline, noclone)) void
f5 (void)
{
int i;
for (i = 0; i < N; ++i)
k[i] = (a[i] < b[i]) & (c[i] < d[i]);
}
__attribute__((noinline, noclone)) void
f6 (void)
{
int i;
for (i = 0; i < N; ++i)
{
unsigned int x = a[i] < b[i] ? -1 : 0;
unsigned int y = c[i] < d[i] ? -1 : 0;
j[i] = (x | y) >> 31;
}
}
__attribute__((noinline, noclone)) void
f7 (void)
{
int i;
for (i = 0; i < N; ++i)
{
int x = a[i] < b[i];
int y = c[i] < d[i];
j[i] = x | y;
}
}
__attribute__((noinline, noclone)) void
f8 (void)
{
int i;
for (i = 0; i < N; ++i)
j[i] = (a[i] < b[i]) | (c[i] < d[i]);
}
__attribute__((noinline, noclone)) void
f9 (void)
{
int i;
for (i = 0; i < N; ++i)
{
int x = a[i] < b[i];
int y = c[i] < d[i];
k[i] = x | y;
}
}
__attribute__((noinline, noclone)) void
f10 (void)
{
int i;
for (i = 0; i < N; ++i)
k[i] = (a[i] < b[i]) | (c[i] < d[i]);
}
int
main ()
{
int i;
check_vect ();
for (i = 0; i < N; i++)
{
switch (i % 9)
{
case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break;
case 1: a[i] = 0; b[i] = 0; break;
case 2: a[i] = i + 1; b[i] = - i - 1; break;
case 3: a[i] = i; b[i] = i + 7; break;
case 4: a[i] = i; b[i] = i; break;
case 5: a[i] = i + 16; b[i] = i + 3; break;
case 6: a[i] = - i - 5; b[i] = - i; break;
case 7: a[i] = - i; b[i] = - i; break;
case 8: a[i] = - i; b[i] = - i - 7; break;
}
}
for (i = 0; i < N; i++)
{
switch ((i / 9) % 3)
{
case 0: c[i] = a[i / 9]; d[i] = b[i / 9]; break;
case 1: c[i] = a[i / 9 + 3]; d[i] = b[i / 9 + 3]; break;
case 2: c[i] = a[i / 9 + 6]; d[i] = b[i / 9 + 6]; break;
}
}
f1 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f2 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f3 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f4 ();
for (i = 0; i < N; i++)
if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
abort ();
__builtin_memset (k, -6, sizeof (k));
f5 ();
for (i = 0; i < N; i++)
if (k[i] != ((i % 3) == 0 && ((i / 9) % 3) == 0))
abort ();
__builtin_memset (k, -6, sizeof (k));
f6 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f7 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f8 ();
for (i = 0; i < N; i++)
if (j[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
abort ();
__builtin_memset (j, -6, sizeof (j));
f9 ();
for (i = 0; i < N; i++)
if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
abort ();
__builtin_memset (k, -6, sizeof (k));
f10 ();
for (i = 0; i < N; i++)
if (k[i] != ((i % 3) == 0 || ((i / 9) % 3) == 0))
abort ();
__builtin_memset (k, -6, sizeof (k));
return 0;
}
/* { dg-final { scan-tree-dump-times "note: vectorized 1 loops" 10 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
...@@ -902,7 +902,7 @@ extern void vect_slp_transform_bb (basic_block); ...@@ -902,7 +902,7 @@ extern void vect_slp_transform_bb (basic_block);
Additional pattern recognition functions can (and will) be added Additional pattern recognition functions can (and will) be added
in the future. */ in the future. */
typedef gimple (* vect_recog_func_ptr) (VEC (gimple, heap) **, tree *, tree *); typedef gimple (* vect_recog_func_ptr) (VEC (gimple, heap) **, tree *, tree *);
#define NUM_PATTERNS 6 #define NUM_PATTERNS 7
void vect_pattern_recog (loop_vec_info); void vect_pattern_recog (loop_vec_info);
/* In tree-vectorizer.c. */ /* In tree-vectorizer.c. */
......
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