Commit 1f24dd47 by Daniel Berlin Committed by Daniel Berlin

re PR tree-optimization/18792 (ICE with -O1 -ftree-loop-linear on small test case)

2005-01-06  Daniel Berlin <dberlin@dberlin.org>

	Fix PR tree-optimization/18792

	* tree-data-ref.c (build_classic_dist_vector): Change first_loop
	to first_loop_depth, and use loop depth instead of loop number.
	(build_classic_dir_vector): Ditto.
	(compute_data_dependences_for_loop): Use depth, not loop number.
	* tree-loop-linear.c (try_interchange_loops): Use loop depth, not loop
	number. Pass in loops, instead of loop numbers.
	(gather_interchange_stats): Ditto.
	(linear_transform_loops): Ditto.

From-SVN: r93008
parent a8e3a00f
2005-01-06 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/18792
* tree-data-ref.c (build_classic_dist_vector): Change first_loop
to first_loop_depth, and use loop depth instead of loop number.
(build_classic_dir_vector): Ditto.
(compute_data_dependences_for_loop): Use depth, not loop number.
* tree-loop-linear.c (try_interchange_loops): Use loop depth, not loop
number. Pass in loops, instead of loop numbers.
(gather_interchange_stats): Ditto.
(linear_transform_loops): Ditto.
2005-01-06 Richard Sandiford <rsandifo@redhat.com> 2005-01-06 Richard Sandiford <rsandifo@redhat.com>
PR rtl-opt/13299 PR rtl-opt/13299
......
/* PR tree-optimization/18792 */
/* { dg-do compile } */
/* { dg-options "-O1 -ftree-loop-linear" } */
void put_atoms_in_triclinic_unitcell(float x[][3])
{
int i=0,d;
while (x[i][3] < 0)
for (d=0; d<=3; d++)
x[i][d] = 0;
while (x[i][3] >= 0)
for (d=0; d<=3; d++)
x[i][d] = 0;
}
...@@ -55,19 +55,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -55,19 +55,19 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
transform matrix for locality purposes. transform matrix for locality purposes.
TODO: Completion of partial transforms. */ TODO: Completion of partial transforms. */
/* Gather statistics for loop interchange. LOOP_NUMBER is a relative /* Gather statistics for loop interchange. LOOP is the loop being
index in the considered loop nest. The first loop in the considered. The first loop in the considered loop nest is
considered loop nest is FIRST_LOOP, and consequently the index of FIRST_LOOP, and consequently, the index of the considered loop is
the considered loop is obtained by FIRST_LOOP + LOOP_NUMBER. obtained by LOOP->DEPTH - FIRST_LOOP->DEPTH
Initializes: Initializes:
- DEPENDENCE_STEPS the sum of all the data dependence distances - DEPENDENCE_STEPS the sum of all the data dependence distances
carried by loop LOOP_NUMBER, carried by loop LOOP,
- NB_DEPS_NOT_CARRIED_BY_LOOP the number of dependence relations - NB_DEPS_NOT_CARRIED_BY_LOOP the number of dependence relations
for which the loop LOOP_NUMBER is not carrying any dependence, for which the loop LOOP is not carrying any dependence,
- ACCESS_STRIDES the sum of all the strides in LOOP_NUMBER. - ACCESS_STRIDES the sum of all the strides in LOOP.
Example: for the following loop, Example: for the following loop,
...@@ -93,8 +93,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -93,8 +93,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static void static void
gather_interchange_stats (varray_type dependence_relations, gather_interchange_stats (varray_type dependence_relations,
varray_type datarefs, varray_type datarefs,
unsigned int loop_number, struct loop *loop,
unsigned int first_loop, struct loop *first_loop,
unsigned int *dependence_steps, unsigned int *dependence_steps,
unsigned int *nb_deps_not_carried_by_loop, unsigned int *nb_deps_not_carried_by_loop,
unsigned int *access_strides) unsigned int *access_strides)
...@@ -123,7 +123,7 @@ gather_interchange_stats (varray_type dependence_relations, ...@@ -123,7 +123,7 @@ gather_interchange_stats (varray_type dependence_relations,
dist = DDR_DIST_VECT (ddr)[loop_number]; dist = DDR_DIST_VECT (ddr)[loop->depth - first_loop->depth];
if (dist == 0) if (dist == 0)
(*nb_deps_not_carried_by_loop) += 1; (*nb_deps_not_carried_by_loop) += 1;
else if (dist < 0) else if (dist < 0)
...@@ -139,17 +139,16 @@ gather_interchange_stats (varray_type dependence_relations, ...@@ -139,17 +139,16 @@ gather_interchange_stats (varray_type dependence_relations,
struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i); struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i);
tree stmt = DR_STMT (dr); tree stmt = DR_STMT (dr);
struct loop *stmt_loop = loop_containing_stmt (stmt); struct loop *stmt_loop = loop_containing_stmt (stmt);
struct loop *inner_loop = current_loops->parray[first_loop + 1]; struct loop *inner_loop = first_loop->inner;
if (!flow_loop_nested_p (inner_loop, stmt_loop) if (inner_loop != stmt_loop
&& inner_loop->num != stmt_loop->num) && !flow_loop_nested_p (inner_loop, stmt_loop))
continue; continue;
for (it = 0; it < DR_NUM_DIMENSIONS (dr); it++) for (it = 0; it < DR_NUM_DIMENSIONS (dr); it++)
{ {
tree chrec = DR_ACCESS_FN (dr, it); tree chrec = DR_ACCESS_FN (dr, it);
tree tstride = evolution_part_in_loop_num tree tstride = evolution_part_in_loop_num
(chrec, first_loop + loop_number); (chrec, loop->num);
if (tstride == NULL_TREE if (tstride == NULL_TREE
|| TREE_CODE (tstride) != INTEGER_CST) || TREE_CODE (tstride) != INTEGER_CST)
...@@ -173,9 +172,10 @@ try_interchange_loops (lambda_trans_matrix trans, ...@@ -173,9 +172,10 @@ try_interchange_loops (lambda_trans_matrix trans,
unsigned int depth, unsigned int depth,
varray_type dependence_relations, varray_type dependence_relations,
varray_type datarefs, varray_type datarefs,
unsigned int first_loop) struct loop *first_loop)
{ {
unsigned int loop_i, loop_j; struct loop *loop_i;
struct loop *loop_j;
unsigned int dependence_steps_i, dependence_steps_j; unsigned int dependence_steps_i, dependence_steps_j;
unsigned int access_strides_i, access_strides_j; unsigned int access_strides_i, access_strides_j;
unsigned int nb_deps_not_carried_by_i, nb_deps_not_carried_by_j; unsigned int nb_deps_not_carried_by_i, nb_deps_not_carried_by_j;
...@@ -189,8 +189,12 @@ try_interchange_loops (lambda_trans_matrix trans, ...@@ -189,8 +189,12 @@ try_interchange_loops (lambda_trans_matrix trans,
return trans; return trans;
/* LOOP_I is always the outer loop. */ /* LOOP_I is always the outer loop. */
for (loop_j = 1; loop_j < depth; loop_j++) for (loop_j = first_loop->inner;
for (loop_i = 0; loop_i < loop_j; loop_i++) loop_j;
loop_j = loop_j->inner)
for (loop_i = first_loop;
loop_i->depth < loop_j->depth;
loop_i = loop_i->inner)
{ {
gather_interchange_stats (dependence_relations, datarefs, gather_interchange_stats (dependence_relations, datarefs,
loop_i, first_loop, loop_i, first_loop,
...@@ -218,11 +222,15 @@ try_interchange_loops (lambda_trans_matrix trans, ...@@ -218,11 +222,15 @@ try_interchange_loops (lambda_trans_matrix trans,
|| nb_deps_not_carried_by_i > nb_deps_not_carried_by_j || nb_deps_not_carried_by_i > nb_deps_not_carried_by_j
|| access_strides_i < access_strides_j) || access_strides_i < access_strides_j)
{ {
lambda_matrix_row_exchange (LTM_MATRIX (trans), loop_i, loop_j); lambda_matrix_row_exchange (LTM_MATRIX (trans),
loop_i->depth - first_loop->depth,
loop_j->depth - first_loop->depth);
/* Validate the resulting matrix. When the transformation /* Validate the resulting matrix. When the transformation
is not valid, reverse to the previous transformation. */ is not valid, reverse to the previous transformation. */
if (!lambda_transform_legal_p (trans, depth, dependence_relations)) if (!lambda_transform_legal_p (trans, depth, dependence_relations))
lambda_matrix_row_exchange (LTM_MATRIX (trans), loop_i, loop_j); lambda_matrix_row_exchange (LTM_MATRIX (trans),
loop_i->depth - first_loop->depth,
loop_j->depth - first_loop->depth);
} }
} }
...@@ -318,7 +326,7 @@ linear_transform_loops (struct loops *loops) ...@@ -318,7 +326,7 @@ linear_transform_loops (struct loops *loops)
lambda_matrix_id (LTM_MATRIX (trans), depth); lambda_matrix_id (LTM_MATRIX (trans), depth);
trans = try_interchange_loops (trans, depth, dependence_relations, trans = try_interchange_loops (trans, depth, dependence_relations,
datarefs, loop_nest->num); datarefs, loop_nest);
if (lambda_trans_matrix_id_p (trans)) if (lambda_trans_matrix_id_p (trans))
{ {
......
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