Commit acdcd61b by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/59591 (ICE in vect_get_vec_def_for_stmt_copy, at…

re PR tree-optimization/59591 (ICE in vect_get_vec_def_for_stmt_copy, at tree-vect-stmts.c:156 for -march=core-avx2)

	PR tree-optimization/59591
	* tree-vect-stmts.c (vectorizable_mask_load_store): Fix up handling
	of modifier = NARROW masked gathers.
	(permute_vec_elements): Use gimple_get_lhs instead of
	gimple_assign_lhs.

	* gcc.dg/vect/pr59591-1.c: New test.
	* gcc.dg/vect/pr59591-2.c: New test.
	* gcc.target/i386/pr59591-1.c: New test.
	* gcc.target/i386/pr59591-2.c: New test.

From-SVN: r206248
parent 51ac3042
2013-12-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/59591
* tree-vect-stmts.c (vectorizable_mask_load_store): Fix up handling
of modifier = NARROW masked gathers.
(permute_vec_elements): Use gimple_get_lhs instead of
gimple_assign_lhs.
2013-12-30 Nick Clifton <nickc@redhat.com> 2013-12-30 Nick Clifton <nickc@redhat.com>
* config/msp430/msp430.c (msp430_print_operand): Rename %B to %b * config/msp430/msp430.c (msp430_print_operand): Rename %B to %b
2013-12-30 Jakub Jelinek <jakub@redhat.com> 2013-12-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/59591
* gcc.dg/vect/pr59591-1.c: New test.
* gcc.dg/vect/pr59591-2.c: New test.
* gcc.target/i386/pr59591-1.c: New test.
* gcc.target/i386/pr59591-2.c: New test.
PR target/59501 PR target/59501
* gcc.target/i386/pr59501-1.c: New test. * gcc.target/i386/pr59501-1.c: New test.
* gcc.target/i386/pr59501-1a.c: New test. * gcc.target/i386/pr59501-1a.c: New test.
......
/* PR tree-optimization/59591 */
/* { dg-do run } */
/* { dg-additional-options "-fopenmp-simd" } */
#ifndef CHECK_H
#include "tree-vect.h"
#endif
extern void abort (void);
int p[256], q[256], r[256], t[256];
__attribute__((noinline, noclone)) void
foo (void)
{
int i;
#pragma omp simd safelen(64)
for (i = 0; i < 256; i++)
if (r[i] > 32)
t[i] = p[q[i] * 3L + 2L];
}
__attribute__((noinline, noclone)) void
bar (void)
{
int i;
for (i = 0; i < 256; i++)
{
r[i] = ((i >> 2) & (1 << (i & 3))) ? 32 + i : 32 - i;
q[i] = r[i] > 32 ? ((i * 7) % 84) : 99 + i;
p[i] = i * 11;
t[i] = i * 13;
}
foo ();
for (i = 0; i < 256; i++)
if ((i >> 2) & (1 << (i & 3)))
{
if (t[i] != (((i * 7) % 84) * 3 + 2) * 11)
abort ();
}
else if (t[i] != i * 13)
abort ();
}
#ifndef CHECK_H
int
main ()
{
check_vect ();
bar ();
return 0;
}
#endif
/* { dg-final { cleanup-tree-dump "vect" } } */
/* PR tree-optimization/59591 */
/* { dg-do run } */
/* { dg-additional-options "-fopenmp-simd" } */
#ifndef CHECK_H
#include "tree-vect.h"
#endif
extern void abort (void);
long long int p[256], r[256], t[256];
int q[256];
__attribute__((noinline, noclone)) void
foo (void)
{
int i;
#pragma omp simd safelen(64)
for (i = 0; i < 256; i++)
if (r[i] > 32LL)
t[i] = p[q[i]];
}
__attribute__((noinline, noclone)) void
bar (void)
{
int i;
for (i = 0; i < 256; i++)
{
r[i] = ((i >> 2) & (1 << (i & 3))) ? 32 + i : 32 - i;
q[i] = r[i] > 32 ? ((i * 7) % 256) : 258 + i;
p[i] = i * 11;
t[i] = i * 13;
}
foo ();
for (i = 0; i < 256; i++)
if ((i >> 2) & (1 << (i & 3)))
{
if (t[i] != ((i * 7) % 256) * 11)
abort ();
}
else if (t[i] != i * 13)
abort ();
}
#ifndef CHECK_H
int
main ()
{
check_vect ();
bar ();
return 0;
}
#endif
/* { dg-final { cleanup-tree-dump "vect" } } */
/* PR tree-optimization/59591 */
/* { dg-do run } */
/* { dg-options "-O2 -fopenmp-simd -mavx2 -fno-vect-cost-model" } */
/* { dg-require-effective-target avx2 } */
#define CHECK_H "avx2-check.h"
#define TEST avx2_test
#include "../../gcc.dg/vect/pr59591-1.c"
#include CHECK_H
static void
TEST (void)
{
bar ();
}
/* PR tree-optimization/59591 */
/* { dg-do run } */
/* { dg-options "-O2 -fopenmp-simd -mavx2 -fno-vect-cost-model" } */
/* { dg-require-effective-target avx2 } */
#define CHECK_H "avx2-check.h"
#define TEST avx2_test
#include "../../gcc.dg/vect/pr59591-2.c"
#include CHECK_H
static void
TEST (void)
{
bar ();
}
...@@ -1855,14 +1855,24 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi, ...@@ -1855,14 +1855,24 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi,
tree vec_oprnd0 = NULL_TREE, op; tree vec_oprnd0 = NULL_TREE, op;
tree arglist = TYPE_ARG_TYPES (TREE_TYPE (gather_decl)); tree arglist = TYPE_ARG_TYPES (TREE_TYPE (gather_decl));
tree rettype, srctype, ptrtype, idxtype, masktype, scaletype; tree rettype, srctype, ptrtype, idxtype, masktype, scaletype;
tree ptr, vec_mask = NULL_TREE, mask_op, var, scale; tree ptr, vec_mask = NULL_TREE, mask_op = NULL_TREE, var, scale;
tree perm_mask = NULL_TREE, prev_res = NULL_TREE; tree perm_mask = NULL_TREE, prev_res = NULL_TREE;
tree mask_perm_mask = NULL_TREE;
edge pe = loop_preheader_edge (loop); edge pe = loop_preheader_edge (loop);
gimple_seq seq; gimple_seq seq;
basic_block new_bb; basic_block new_bb;
enum { NARROW, NONE, WIDEN } modifier; enum { NARROW, NONE, WIDEN } modifier;
int gather_off_nunits = TYPE_VECTOR_SUBPARTS (gather_off_vectype); int gather_off_nunits = TYPE_VECTOR_SUBPARTS (gather_off_vectype);
rettype = TREE_TYPE (TREE_TYPE (gather_decl));
srctype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
ptrtype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
idxtype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
masktype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
scaletype = TREE_VALUE (arglist);
gcc_checking_assert (types_compatible_p (srctype, rettype)
&& types_compatible_p (srctype, masktype));
if (nunits == gather_off_nunits) if (nunits == gather_off_nunits)
modifier = NONE; modifier = NONE;
else if (nunits == gather_off_nunits / 2) else if (nunits == gather_off_nunits / 2)
...@@ -1888,19 +1898,14 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi, ...@@ -1888,19 +1898,14 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi,
perm_mask = vect_gen_perm_mask (vectype, sel); perm_mask = vect_gen_perm_mask (vectype, sel);
gcc_assert (perm_mask != NULL_TREE); gcc_assert (perm_mask != NULL_TREE);
ncopies *= 2; ncopies *= 2;
for (i = 0; i < nunits; ++i)
sel[i] = i | gather_off_nunits;
mask_perm_mask = vect_gen_perm_mask (masktype, sel);
gcc_assert (mask_perm_mask != NULL_TREE);
} }
else else
gcc_unreachable (); gcc_unreachable ();
rettype = TREE_TYPE (TREE_TYPE (gather_decl));
srctype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
ptrtype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
idxtype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
masktype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist);
scaletype = TREE_VALUE (arglist);
gcc_checking_assert (types_compatible_p (srctype, rettype)
&& types_compatible_p (srctype, masktype));
vec_dest = vect_create_destination_var (gimple_call_lhs (stmt), vectype); vec_dest = vect_create_destination_var (gimple_call_lhs (stmt), vectype);
ptr = fold_convert (ptrtype, gather_base); ptr = fold_convert (ptrtype, gather_base);
...@@ -1940,28 +1945,35 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi, ...@@ -1940,28 +1945,35 @@ vectorizable_mask_load_store (gimple stmt, gimple_stmt_iterator *gsi,
op = var; op = var;
} }
if (j == 0) if (mask_perm_mask && (j & 1))
vec_mask = vect_get_vec_def_for_operand (mask, stmt, NULL); mask_op = permute_vec_elements (mask_op, mask_op,
mask_perm_mask, stmt, gsi);
else else
{ {
vect_is_simple_use (vec_mask, NULL, loop_vinfo, NULL, &def_stmt, if (j == 0)
&def, &dt); vec_mask = vect_get_vec_def_for_operand (mask, stmt, NULL);
vec_mask = vect_get_vec_def_for_stmt_copy (dt, vec_mask); else
} {
vect_is_simple_use (vec_mask, NULL, loop_vinfo, NULL,
&def_stmt, &def, &dt);
vec_mask = vect_get_vec_def_for_stmt_copy (dt, vec_mask);
}
mask_op = vec_mask; mask_op = vec_mask;
if (!useless_type_conversion_p (masktype, TREE_TYPE (vec_mask))) if (!useless_type_conversion_p (masktype, TREE_TYPE (vec_mask)))
{ {
gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask_op)) gcc_assert (TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask_op))
== TYPE_VECTOR_SUBPARTS (masktype)); == TYPE_VECTOR_SUBPARTS (masktype));
var = vect_get_new_vect_var (masktype, vect_simple_var, NULL); var = vect_get_new_vect_var (masktype, vect_simple_var,
var = make_ssa_name (var, NULL); NULL);
mask_op = build1 (VIEW_CONVERT_EXPR, masktype, mask_op); var = make_ssa_name (var, NULL);
new_stmt mask_op = build1 (VIEW_CONVERT_EXPR, masktype, mask_op);
= gimple_build_assign_with_ops (VIEW_CONVERT_EXPR, var, new_stmt
mask_op, NULL_TREE); = gimple_build_assign_with_ops (VIEW_CONVERT_EXPR, var,
vect_finish_stmt_generation (stmt, new_stmt, gsi); mask_op, NULL_TREE);
mask_op = var; vect_finish_stmt_generation (stmt, new_stmt, gsi);
mask_op = var;
}
} }
new_stmt new_stmt
...@@ -5446,7 +5458,7 @@ permute_vec_elements (tree x, tree y, tree mask_vec, gimple stmt, ...@@ -5446,7 +5458,7 @@ permute_vec_elements (tree x, tree y, tree mask_vec, gimple stmt,
tree perm_dest, data_ref; tree perm_dest, data_ref;
gimple perm_stmt; gimple perm_stmt;
perm_dest = vect_create_destination_var (gimple_assign_lhs (stmt), vectype); perm_dest = vect_create_destination_var (gimple_get_lhs (stmt), vectype);
data_ref = make_ssa_name (perm_dest, NULL); data_ref = make_ssa_name (perm_dest, NULL);
/* Generate the permute statement. */ /* Generate the permute statement. */
......
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