Commit f502d50e by Michael Matz Committed by Michael Matz

re PR middle-end/66253 (459.GemsFDTD in SPEC CPU 2006 is miscompiled)

	PR middle-end/66253
	* tree-vect-stmts.c (vectorizable_store): Implement non-SLP
	grouped strided stores.
	(vectorizable_load): Don't use the DR from first_stmt in
	the non-SLP grouped strided case.

testsuite/
	* gcc.dg/vect/pr66253.c: New testcase.

From-SVN: r224605
parent 55429190
2015-06-18 Michael Matz <matz@suse.de>
PR middle-end/66253
* tree-vect-stmts.c (vectorizable_store): Implement non-SLP
grouped strided stores.
(vectorizable_load): Don't use the DR from first_stmt in
the non-SLP grouped strided case.
2015-06-18 Ilya Enkovich <enkovich.gnu@gmail.com> 2015-06-18 Ilya Enkovich <enkovich.gnu@gmail.com>
PR target/66569 PR target/66569
......
2015-06-18 Michael Matz <matz@suse.de>
PR middle-end/66253
* gcc.dg/vect/pr66253.c: New testcase.
2015-06-18 Ilya Enkovich <enkovich.gnu@gmail.com> 2015-06-18 Ilya Enkovich <enkovich.gnu@gmail.com>
PR target/66569 PR target/66569
......
/* { dg-require-effective-target vect_double } */
/* { dg-require-effective-target vect_hw_misalign } */
#include "tree-vect.h"
void __attribute__((noinline,noclone))
test1(_Complex double * __restrict__ a, _Complex double * __restrict__ b,
double * __restrict__ c, int stride, int n)
{
int i;
for (i = 0; i < n; i++)
{
a[i*stride] = 0.5 * b[i*stride] * c[i*stride];
}
}
double ca[256];
_Complex double ia[256];
_Complex double da[256];
extern void abort (void);
int main ()
{
int i;
int stride;
check_vect ();
for (stride = 1; stride < 15; stride++)
{
for (i = 0; i < 256; i++)
{
__real__ ia[i] = (i + stride) % 19;
__imag__ ia[i] = (i + stride) % 23;
ca[i] = (i + stride) % 29;
__asm__ volatile ("");
}
test1(da, ia, ca, stride, 256/stride);
for (i = 0; i < 256/stride; i++)
{
if (da[i*stride] != 0.5 * ia[i*stride] * ca[i*stride])
abort ();
}
}
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
...@@ -5262,16 +5262,17 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5262,16 +5262,17 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
gimple_seq stmts = NULL; gimple_seq stmts = NULL;
tree stride_base, stride_step, alias_off; tree stride_base, stride_step, alias_off;
tree vec_oprnd; tree vec_oprnd;
unsigned int g;
gcc_assert (!nested_in_vect_loop_p (loop, stmt)); gcc_assert (!nested_in_vect_loop_p (loop, stmt));
stride_base stride_base
= fold_build_pointer_plus = fold_build_pointer_plus
(unshare_expr (DR_BASE_ADDRESS (dr)), (unshare_expr (DR_BASE_ADDRESS (first_dr)),
size_binop (PLUS_EXPR, size_binop (PLUS_EXPR,
convert_to_ptrofftype (unshare_expr (DR_OFFSET (dr))), convert_to_ptrofftype (unshare_expr (DR_OFFSET (first_dr))),
convert_to_ptrofftype (DR_INIT(dr)))); convert_to_ptrofftype (DR_INIT(first_dr))));
stride_step = fold_convert (sizetype, unshare_expr (DR_STEP (dr))); stride_step = fold_convert (sizetype, unshare_expr (DR_STEP (first_dr)));
/* For a store with loop-invariant (but other than power-of-2) /* For a store with loop-invariant (but other than power-of-2)
stride (i.e. not a grouped access) like so: stride (i.e. not a grouped access) like so:
...@@ -5302,6 +5303,7 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5302,6 +5303,7 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
ltype = vectype; ltype = vectype;
ltype = build_aligned_type (ltype, TYPE_ALIGN (elem_type)); ltype = build_aligned_type (ltype, TYPE_ALIGN (elem_type));
ncopies = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); ncopies = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
group_size = 1;
} }
ivstep = stride_step; ivstep = stride_step;
...@@ -5322,8 +5324,22 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5322,8 +5324,22 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts); gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
prev_stmt_info = NULL; prev_stmt_info = NULL;
alias_off = build_int_cst (reference_alias_ptr_type (DR_REF (first_dr)), 0);
next_stmt = first_stmt;
for (g = 0; g < group_size; g++)
{
running_off = offvar; running_off = offvar;
alias_off = build_int_cst (reference_alias_ptr_type (DR_REF (dr)), 0); if (g)
{
tree size = TYPE_SIZE_UNIT (ltype);
tree pos = fold_build2 (MULT_EXPR, sizetype, size_int (g),
size);
tree newoff = copy_ssa_name (running_off, NULL);
incr = gimple_build_assign (newoff, POINTER_PLUS_EXPR,
running_off, pos);
vect_finish_stmt_generation (stmt, incr, gsi);
running_off = newoff;
}
for (j = 0; j < ncopies; j++) for (j = 0; j < ncopies; j++)
{ {
/* We've set op and dt above, from gimple_assign_rhs1(stmt), /* We've set op and dt above, from gimple_assign_rhs1(stmt),
...@@ -5337,7 +5353,12 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5337,7 +5353,12 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
vec_oprnd = vec_oprnds[0]; vec_oprnd = vec_oprnds[0];
} }
else else
vec_oprnd = vect_get_vec_def_for_operand (op, first_stmt, NULL); {
gcc_assert (gimple_assign_single_p (next_stmt));
op = gimple_assign_rhs1 (next_stmt);
vec_oprnd = vect_get_vec_def_for_operand (op, next_stmt,
NULL);
}
} }
else else
{ {
...@@ -5353,8 +5374,8 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5353,8 +5374,8 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
gimple incr, assign; gimple incr, assign;
tree size = TYPE_SIZE (ltype); tree size = TYPE_SIZE (ltype);
/* Extract the i'th component. */ /* Extract the i'th component. */
tree pos = fold_build2 (MULT_EXPR, bitsizetype, bitsize_int (i), tree pos = fold_build2 (MULT_EXPR, bitsizetype,
size); bitsize_int (i), size);
tree elem = fold_build3 (BIT_FIELD_REF, ltype, vec_oprnd, tree elem = fold_build3 (BIT_FIELD_REF, ltype, vec_oprnd,
size, pos); size, pos);
...@@ -5375,6 +5396,8 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5375,6 +5396,8 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
vect_finish_stmt_generation (stmt, incr, gsi); vect_finish_stmt_generation (stmt, incr, gsi);
running_off = newoff; running_off = newoff;
if (g == group_size - 1)
{
if (j == 0 && i == 0) if (j == 0 && i == 0)
STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = assign; STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = assign;
else else
...@@ -5382,6 +5405,9 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -5382,6 +5405,9 @@ vectorizable_store (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
prev_stmt_info = vinfo_for_stmt (assign); prev_stmt_info = vinfo_for_stmt (assign);
} }
} }
}
next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
}
return true; return true;
} }
...@@ -6265,7 +6291,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt, ...@@ -6265,7 +6291,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
gcc_assert (!nested_in_vect_loop); gcc_assert (!nested_in_vect_loop);
if (grouped_load) if (slp && grouped_load)
first_dr = STMT_VINFO_DATA_REF first_dr = STMT_VINFO_DATA_REF
(vinfo_for_stmt (GROUP_FIRST_ELEMENT (stmt_info))); (vinfo_for_stmt (GROUP_FIRST_ELEMENT (stmt_info)));
else else
......
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