summaryrefslogtreecommitdiff
path: root/gcc/lambda-code.c
diff options
context:
space:
mode:
authorlauras <lauras@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-22 12:42:15 +0000
committerlauras <lauras@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-22 12:42:15 +0000
commit1e33ad50b5d37f30af9e92c75a3d30f5d5b2d312 (patch)
tree378620453122ae49e7bf7e0d9a64259baa14bbcd /gcc/lambda-code.c
parent0ca212b8bd0fdb1d7d94c440a9b3c4ca66b242d5 (diff)
downloadgcc-1e33ad50b5d37f30af9e92c75a3d30f5d5b2d312.tar.gz
2010-04-22 Laurynas Biveinis <laurynas.biveinis@gmail.com>
* tree-parloops.c (loop_parallel_p): New argument parloop_obstack. Pass it down. (parallelize_loops): New variable parloop_obstack. Initialize it, pass it down, free it. * tree-loop-linear.c (linear_transform_loops): Pass down lambda_obstack. * tree-data-ref.h (lambda_compute_access_matrices): New argument of type struct obstack *. * tree-data-ref.c (analyze_subscript_affine_affine): New variable scratch_obstack. Initialize it, pass down, free it. * lambda.h (lambda_loop_new): Remove. (lambda_matrix_new, lambda_matrix_inverse) (lambda_trans_matrix_new, lambda_trans_matrix_inverse): New argument of type struct obstack *. * lambda-trans.c (lambda_trans_matrix_new): New argument lambda_obstack. Pass it down, use obstack allocation for ret. (lambda_trans_matrix_inverse): New argument lambda_obstack. Pass it down. * lambda-mat.c (lambda_matrix_get_column) (lambda_matrix_project_to_null): Remove. (lambda_matrix_new): New argument lambda_obstack. Use obstack allocation for mat. (lambda_matrix_inverse_hard, lambda_matrix_inverse): New argument lambda_obstack. * lambda-code.c (lambda_loop_new): New function. (lambda_lattice_new, compute_nest_using_fourier_motzkin) (lambda_compute_auxillary_space, lambda_compute_target_space) (lambda_loopnest_transform, gcc_loop_to_lambda_loop) (lambda_loopnest_to_gcc_loopnest): Pass down lambda_obstack. (build_access_matrix): New argument lambda_obstack. Use obstack allocation for am. (lambda_compute_step_signs, lambda_compute_access_matrices): New argument lambda_obstack. Pass it down. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158644 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lambda-code.c')
-rw-r--r--gcc/lambda-code.c84
1 files changed, 53 insertions, 31 deletions
diff --git a/gcc/lambda-code.c b/gcc/lambda-code.c
index b3143da8e38..fff6ff800f3 100644
--- a/gcc/lambda-code.c
+++ b/gcc/lambda-code.c
@@ -150,6 +150,17 @@ static lambda_lattice lambda_lattice_compute_base (lambda_loopnest,
static bool can_convert_to_perfect_nest (struct loop *);
+/* Create a new lambda loop in LAMBDA_OBSTACK. */
+
+static lambda_loop
+lambda_loop_new (struct obstack * lambda_obstack)
+{
+ lambda_loop result = (lambda_loop)
+ obstack_alloc (lambda_obstack, sizeof (struct lambda_loop_s));
+ memset (result, 0, sizeof (struct lambda_loop_s));
+ return result;
+}
+
/* Create a new lambda body vector. */
lambda_body_vector
@@ -157,7 +168,8 @@ lambda_body_vector_new (int size, struct obstack * lambda_obstack)
{
lambda_body_vector ret;
- ret = (lambda_body_vector)obstack_alloc (lambda_obstack, sizeof (*ret));
+ ret = (lambda_body_vector) obstack_alloc (lambda_obstack,
+ sizeof (*ret));
LBV_COEFFICIENTS (ret) = lambda_vector_new (size);
LBV_SIZE (ret) = size;
LBV_DENOMINATOR (ret) = 1;
@@ -367,9 +379,10 @@ lambda_lattice_new (int depth, int invariants, struct obstack * lambda_obstack)
{
lambda_lattice ret
= (lambda_lattice)obstack_alloc (lambda_obstack, sizeof (*ret));
- LATTICE_BASE (ret) = lambda_matrix_new (depth, depth);
+ LATTICE_BASE (ret) = lambda_matrix_new (depth, depth, lambda_obstack);
LATTICE_ORIGIN (ret) = lambda_vector_new (depth);
- LATTICE_ORIGIN_INVARIANTS (ret) = lambda_matrix_new (depth, invariants);
+ LATTICE_ORIGIN_INVARIANTS (ret) = lambda_matrix_new (depth, invariants,
+ lambda_obstack);
LATTICE_DIMENSION (ret) = depth;
LATTICE_INVARIANTS (ret) = invariants;
return ret;
@@ -500,15 +513,15 @@ compute_nest_using_fourier_motzkin (int size,
lambda_vector swapvector, a1;
int newsize;
- A1 = lambda_matrix_new (128, depth);
- B1 = lambda_matrix_new (128, invariants);
+ A1 = lambda_matrix_new (128, depth, lambda_obstack);
+ B1 = lambda_matrix_new (128, invariants, lambda_obstack);
a1 = lambda_vector_new (128);
auxillary_nest = lambda_loopnest_new (depth, invariants, lambda_obstack);
for (i = depth - 1; i >= 0; i--)
{
- loop = lambda_loop_new ();
+ loop = lambda_loop_new (lambda_obstack);
LN_LOOPS (auxillary_nest)[i] = loop;
LL_STEP (loop) = 1;
@@ -654,12 +667,12 @@ lambda_compute_auxillary_space (lambda_loopnest nest,
/* Unfortunately, we can't know the number of constraints we'll have
ahead of time, but this should be enough even in ridiculous loop nest
cases. We must not go over this limit. */
- A = lambda_matrix_new (128, depth);
- B = lambda_matrix_new (128, invariants);
+ A = lambda_matrix_new (128, depth, lambda_obstack);
+ B = lambda_matrix_new (128, invariants, lambda_obstack);
a = lambda_vector_new (128);
- A1 = lambda_matrix_new (128, depth);
- B1 = lambda_matrix_new (128, invariants);
+ A1 = lambda_matrix_new (128, depth, lambda_obstack);
+ B1 = lambda_matrix_new (128, invariants, lambda_obstack);
a1 = lambda_vector_new (128);
/* Store the bounds in the equation matrix A, constant vector a, and
@@ -754,11 +767,11 @@ lambda_compute_auxillary_space (lambda_loopnest nest,
/* Now compute the auxiliary space bounds by first inverting U, multiplying
it by A1, then performing Fourier-Motzkin. */
- invertedtrans = lambda_matrix_new (depth, depth);
+ invertedtrans = lambda_matrix_new (depth, depth, lambda_obstack);
/* Compute the inverse of U. */
lambda_matrix_inverse (LTM_MATRIX (trans),
- invertedtrans, depth);
+ invertedtrans, depth, lambda_obstack);
/* A = A1 inv(U). */
lambda_matrix_mult (A1, invertedtrans, A, size, depth, depth);
@@ -795,18 +808,19 @@ lambda_compute_target_space (lambda_loopnest auxillary_nest,
depth = LN_DEPTH (auxillary_nest);
invariants = LN_INVARIANTS (auxillary_nest);
- inverse = lambda_matrix_new (depth, depth);
- determinant = lambda_matrix_inverse (LTM_MATRIX (H), inverse, depth);
+ inverse = lambda_matrix_new (depth, depth, lambda_obstack);
+ determinant = lambda_matrix_inverse (LTM_MATRIX (H), inverse, depth,
+ lambda_obstack);
/* H1 is H excluding its diagonal. */
- H1 = lambda_matrix_new (depth, depth);
+ H1 = lambda_matrix_new (depth, depth, lambda_obstack);
lambda_matrix_copy (LTM_MATRIX (H), H1, depth, depth);
for (i = 0; i < depth; i++)
H1[i][i] = 0;
/* Computes the linear offsets of the loop bounds. */
- target = lambda_matrix_new (depth, depth);
+ target = lambda_matrix_new (depth, depth, lambda_obstack);
lambda_matrix_mult (H1, inverse, target, depth, depth, depth);
target_nest = lambda_loopnest_new (depth, invariants, lambda_obstack);
@@ -815,7 +829,7 @@ lambda_compute_target_space (lambda_loopnest auxillary_nest,
{
/* Get a new loop structure. */
- target_loop = lambda_loop_new ();
+ target_loop = lambda_loop_new (lambda_obstack);
LN_LOOPS (target_nest)[i] = target_loop;
/* Computes the gcd of the coefficients of the linear part. */
@@ -982,7 +996,9 @@ lambda_compute_target_space (lambda_loopnest auxillary_nest,
result. */
static lambda_vector
-lambda_compute_step_signs (lambda_trans_matrix trans, lambda_vector stepsigns)
+lambda_compute_step_signs (lambda_trans_matrix trans,
+ lambda_vector stepsigns,
+ struct obstack * lambda_obstack)
{
lambda_matrix matrix, H;
int size;
@@ -992,7 +1008,7 @@ lambda_compute_step_signs (lambda_trans_matrix trans, lambda_vector stepsigns)
matrix = LTM_MATRIX (trans);
size = LTM_ROWSIZE (trans);
- H = lambda_matrix_new (size, size);
+ H = lambda_matrix_new (size, size, lambda_obstack);
newsteps = lambda_vector_new (size);
lambda_vector_copy (stepsigns, newsteps, size);
@@ -1067,7 +1083,7 @@ lambda_loopnest_transform (lambda_loopnest nest, lambda_trans_matrix trans,
/* Compute the lattice base. */
lattice = lambda_lattice_compute_base (nest, lambda_obstack);
- trans1 = lambda_trans_matrix_new (depth, depth);
+ trans1 = lambda_trans_matrix_new (depth, depth, lambda_obstack);
/* Multiply the transformation matrix by the lattice base. */
@@ -1075,25 +1091,27 @@ lambda_loopnest_transform (lambda_loopnest nest, lambda_trans_matrix trans,
LTM_MATRIX (trans1), depth, depth, depth);
/* Compute the Hermite normal form for the new transformation matrix. */
- H = lambda_trans_matrix_new (depth, depth);
- U = lambda_trans_matrix_new (depth, depth);
+ H = lambda_trans_matrix_new (depth, depth, lambda_obstack);
+ U = lambda_trans_matrix_new (depth, depth, lambda_obstack);
lambda_matrix_hermite (LTM_MATRIX (trans1), depth, LTM_MATRIX (H),
LTM_MATRIX (U));
/* Compute the auxiliary loop nest's space from the unimodular
portion. */
- auxillary_nest = lambda_compute_auxillary_space (nest, U, lambda_obstack);
+ auxillary_nest = lambda_compute_auxillary_space (nest, U,
+ lambda_obstack);
/* Compute the loop step signs from the old step signs and the
transformation matrix. */
- stepsigns = lambda_compute_step_signs (trans1, stepsigns);
+ stepsigns = lambda_compute_step_signs (trans1, stepsigns,
+ lambda_obstack);
/* Compute the target loop nest space from the auxiliary nest and
the lower triangular matrix H. */
target_nest = lambda_compute_target_space (auxillary_nest, H, stepsigns,
lambda_obstack);
origin = lambda_vector_new (depth);
- origin_invariants = lambda_matrix_new (depth, invariants);
+ origin_invariants = lambda_matrix_new (depth, invariants, lambda_obstack);
lambda_matrix_vector_mult (LTM_MATRIX (trans), depth, depth,
LATTICE_ORIGIN (lattice), origin);
lambda_matrix_mult (LTM_MATRIX (trans), LATTICE_ORIGIN_INVARIANTS (lattice),
@@ -1424,7 +1442,7 @@ gcc_loop_to_lambda_loop (struct loop *loop, int depth,
return NULL;
}
- lloop = lambda_loop_new ();
+ lloop = lambda_loop_new (lambda_obstack);
LL_STEP (lloop) = stepint;
LL_LOWER_BOUND (lloop) = lbound;
LL_UPPER_BOUND (lloop) = ubound;
@@ -1702,7 +1720,7 @@ lambda_loopnest_to_gcc_loopnest (struct loop *old_loopnest,
tree oldiv;
gimple_stmt_iterator bsi;
- transform = lambda_trans_matrix_inverse (transform);
+ transform = lambda_trans_matrix_inverse (transform, lambda_obstack);
if (dump_file)
{
@@ -2801,9 +2819,12 @@ av_for_af (tree access_fun, lambda_vector cy, struct access_matrix *am)
static bool
build_access_matrix (data_reference_p data_reference,
- VEC (tree, heap) *parameters, VEC (loop_p, heap) *nest)
+ VEC (tree, heap) *parameters,
+ VEC (loop_p, heap) *nest,
+ struct obstack * lambda_obstack)
{
- struct access_matrix *am = GGC_NEW (struct access_matrix);
+ struct access_matrix *am = (struct access_matrix *)
+ obstack_alloc(lambda_obstack, sizeof (struct access_matrix));
unsigned i, ndim = DR_NUM_DIMENSIONS (data_reference);
unsigned nivs = VEC_length (loop_p, nest);
unsigned lambda_nb_columns;
@@ -2835,13 +2856,14 @@ build_access_matrix (data_reference_p data_reference,
bool
lambda_compute_access_matrices (VEC (data_reference_p, heap) *datarefs,
VEC (tree, heap) *parameters,
- VEC (loop_p, heap) *nest)
+ VEC (loop_p, heap) *nest,
+ struct obstack * lambda_obstack)
{
data_reference_p dataref;
unsigned ix;
for (ix = 0; VEC_iterate (data_reference_p, datarefs, ix, dataref); ix++)
- if (!build_access_matrix (dataref, parameters, nest))
+ if (!build_access_matrix (dataref, parameters, nest, lambda_obstack))
return false;
return true;