Commit f20132e7 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/54132 (Incorrect loop transformation with -ftree-loop-distribute-patterns)

2012-09-19  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/54132
	* tree-loop-distribution.c (classify_partition): Properly
	check dependences for memmove.
	* tree-data-ref.h (compute_affine_dependence): Declare.
	* tree-data-ref.c (compute_affine_dependence): Export.

	* gcc.dg/tree-ssa/ldist-21.c: New testcase.
	* gcc.dg/torture/pr54132.c: Likewise.

From-SVN: r191463
parent f7d0c571
2012-09-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54132
* tree-loop-distribution.c (classify_partition): Properly
check dependences for memmove.
* tree-data-ref.h (compute_affine_dependence): Declare.
* tree-data-ref.c (compute_affine_dependence): Export.
2012-09-19 Zhenqiang Chen <zhenqiang.chen@arm.com>
PR middle-end/54364
......
2012-09-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54132
* gcc.dg/tree-ssa/ldist-21.c: New testcase.
* gcc.dg/torture/pr54132.c: Likewise.
2012-09-19 Terry Guo <terry.guo@arm.com>
* lib/gcc-dg.exp (dg_runtest_extra_prunes): New variable to define
......
/* { dg-do run } */
extern void abort (void);
void foo(char *p, int n)
{
int i;
for (i = 1; i < n; i++)
p[i] = p[i - 1];
}
int main()
{
char a[1024];
a[0] = 1;
foo (a, 1024);
if (a[1023] != 1)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-ldist-details" } */
void bar(char *p, int n)
{
int i;
for (i = 1; i < n; i++)
p[i-1] = p[i];
}
/* { dg-final { scan-tree-dump "generated memmove" "ldist" } } */
......@@ -4130,7 +4130,7 @@ ddr_consistent_p (FILE *file,
relation the first time we detect a CHREC_KNOWN element for a given
subscript. */
static void
void
compute_affine_dependence (struct data_dependence_relation *ddr,
struct loop *loop_nest)
{
......
......@@ -396,6 +396,8 @@ struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool);
extern bool find_loop_nest (struct loop *, VEC (loop_p, heap) **);
extern struct data_dependence_relation *initialize_data_dependence_relation
(struct data_reference *, struct data_reference *, VEC (loop_p, heap) *);
extern void compute_affine_dependence (struct data_dependence_relation *,
loop_p);
extern void compute_self_dependence (struct data_dependence_relation *);
extern bool compute_all_dependences (VEC (data_reference_p, heap) *,
VEC (ddr_p, heap) **, VEC (loop_p, heap) *,
......
......@@ -1011,6 +1011,39 @@ classify_partition (loop_p loop, struct graph *rdg, partition_t partition)
|| !operand_equal_p (DR_STEP (single_store),
DR_STEP (single_load), 0))
return;
/* Now check that if there is a dependence this dependence is
of a suitable form for memmove. */
VEC(loop_p, heap) *loops = NULL;
ddr_p ddr;
VEC_safe_push (loop_p, heap, loops, loop);
ddr = initialize_data_dependence_relation (single_load, single_store,
loops);
compute_affine_dependence (ddr, loop);
VEC_free (loop_p, heap, loops);
if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
{
free_dependence_relation (ddr);
return;
}
if (DDR_ARE_DEPENDENT (ddr) != chrec_known)
{
if (DDR_NUM_DIST_VECTS (ddr) == 0)
{
free_dependence_relation (ddr);
return;
}
lambda_vector dist_v;
FOR_EACH_VEC_ELT (lambda_vector, DDR_DIST_VECTS (ddr), i, dist_v)
{
int dist = dist_v[index_in_loop_nest (loop->num,
DDR_LOOP_NEST (ddr))];
if (dist > 0 && !DDR_REVERSED_P (ddr))
{
free_dependence_relation (ddr);
return;
}
}
}
partition->kind = PKIND_MEMCPY;
partition->main_dr = single_store;
partition->secondary_dr = single_load;
......
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