Commit b8ff1d5b by Razya Ladelsky Committed by Razya Ladelsky

matrix-reorg.c (transform_access_sites): Fix computation.

2007-06-05  Razya Ladelsky  <razya@il.ibm.com>

        * matrix-reorg.c (transform_access_sites): Fix computation.
        (transform_allocation_sites): Same.
        * testsuite/gcc.dg/matrix/matrix-6.c: Remove conversion.

From-SVN: r125331
parent cc55c4b0
2007-06-05 Razya Ladelsky <razya@il.ibm.com>
* matrix-reorg.c (transform_access_sites): Fix computation.
(transform_allocation_sites): Same.
* testsuite/gcc.dg/matrix/matrix-6.c: Remove conversion.
2007-06-05 Uros Bizjak <ubizjak@gmail.com> 2007-06-05 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (override_options): Use * config/i386/i386.c (override_options): Use
......
...@@ -1654,6 +1654,42 @@ record_all_accesses_in_func (void) ...@@ -1654,6 +1654,42 @@ record_all_accesses_in_func (void)
sbitmap_free (visited_stmts_1); sbitmap_free (visited_stmts_1);
} }
/* Used when we want to convert the expression: RESULT = something * ORIG to RESULT = something * NEW. If ORIG and NEW are power of 2, shift operations can be done, else division and multiplication. */
static tree
compute_offset (HOST_WIDE_INT orig, HOST_WIDE_INT new, tree result)
{
int x, y;
tree result1, ratio, log, orig_tree, new_tree;
x = exact_log2 (orig);
y = exact_log2 (new);
if (x != -1 && y != -1)
{
if (x == y)
return result;
else if (x > y)
{
log = build_int_cst (TREE_TYPE (result), x - y);
result1 =
fold_build2 (LSHIFT_EXPR, TREE_TYPE (result), result, log);
return result1;
}
log = build_int_cst (TREE_TYPE (result), y - x);
result1 = fold_build2 (RSHIFT_EXPR, TREE_TYPE (result), result, log);
return result1;
}
orig_tree = build_int_cst (TREE_TYPE (result), orig);
new_tree = build_int_cst (TREE_TYPE (result), new);
ratio = fold_build2 (TRUNC_DIV_EXPR, TREE_TYPE (result), result, orig_tree);
result1 = fold_build2 (MULT_EXPR, TREE_TYPE (result), ratio, new_tree);
return result1;
}
/* We know that we are allowed to perform matrix flattening (according to the /* We know that we are allowed to perform matrix flattening (according to the
escape analysis), so we traverse the use-def chains of the SSA vars escape analysis), so we traverse the use-def chains of the SSA vars
defined by the global variables pointing to the matrices of our interest. defined by the global variables pointing to the matrices of our interest.
...@@ -1783,8 +1819,6 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED) ...@@ -1783,8 +1819,6 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
tmp1 = offset; tmp1 = offset;
else else
{ {
int x, y;
tree ratio;
tree new_offset; tree new_offset;
tree d_type_size, d_type_size_k; tree d_type_size, d_type_size_k;
...@@ -1793,29 +1827,11 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED) ...@@ -1793,29 +1827,11 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
mi->dimension_type_size[min_escape_l]); mi->dimension_type_size[min_escape_l]);
d_type_size_k = d_type_size_k =
build_int_cst (type, mi->dimension_type_size[k + 1]); build_int_cst (type, mi->dimension_type_size[k + 1]);
x = exact_log2 (mi->dimension_type_size[min_escape_l]);
y = exact_log2 (mi->dimension_type_size[k + 1]);
if (x != -1 && y != -1) new_offset =
{ compute_offset (mi->dimension_type_size[min_escape_l],
if (x - y == 0) mi->dimension_type_size[k + 1], offset);
new_offset = offset;
else
{
tree log = build_int_cst (type, x - y);
new_offset =
fold_build2 (LSHIFT_EXPR, TREE_TYPE (offset),
offset, log);
}
}
else
{
ratio =
fold_build2 (TRUNC_DIV_EXPR, type, d_type_size,
d_type_size_k);
new_offset =
fold_build2 (MULT_EXPR, type, offset, ratio);
}
total_elements = new_offset; total_elements = new_offset;
if (new_offset != offset) if (new_offset != offset)
{ {
...@@ -1916,7 +1932,6 @@ sort_dim_hot_level (gcov_type * a, int *dim_map, int n) ...@@ -1916,7 +1932,6 @@ sort_dim_hot_level (gcov_type * a, int *dim_map, int n)
} }
} }
/* Replace multiple mallocs (one for each dimension) to one malloc /* Replace multiple mallocs (one for each dimension) to one malloc
with the size of DIM1*DIM2*...*DIMN*size_of_element with the size of DIM1*DIM2*...*DIMN*size_of_element
Make sure that we hold the size in the malloc site inside a Make sure that we hold the size in the malloc site inside a
...@@ -2065,14 +2080,14 @@ transform_allocation_sites (void **slot, void *data ATTRIBUTE_UNUSED) ...@@ -2065,14 +2080,14 @@ transform_allocation_sites (void **slot, void *data ATTRIBUTE_UNUSED)
add_new_static_var (TREE_TYPE add_new_static_var (TREE_TYPE
(mi->dimension_size_orig[mi->dim_map[i]])); (mi->dimension_size_orig[mi->dim_map[i]]));
type = TREE_TYPE (mi->dimension_size_orig[mi->dim_map[i]]); type = TREE_TYPE (mi->dimension_size_orig[mi->dim_map[i]]);
d_type_size =
build_int_cst (type, mi->dimension_type_size[mi->dim_map[i] + 1]);
/* DIM_SIZE = MALLOC_SIZE_PARAM / TYPE_SIZE. */ /* DIM_SIZE = MALLOC_SIZE_PARAM / TYPE_SIZE. */
/* Find which dim ID becomes dim I. */ /* Find which dim ID becomes dim I. */
for (id = 0; id < mi->min_indirect_level_escape; id++) for (id = 0; id < mi->min_indirect_level_escape; id++)
if (mi->dim_map[id] == i) if (mi->dim_map[id] == i)
break; break;
d_type_size =
build_int_cst (type, mi->dimension_type_size[id + 1]);
if (!prev_dim_size) if (!prev_dim_size)
prev_dim_size = build_int_cst (type, element_size); prev_dim_size = build_int_cst (type, element_size);
if (!check_transpose_p && i == mi->min_indirect_level_escape - 1) if (!check_transpose_p && i == mi->min_indirect_level_escape - 1)
......
...@@ -89,7 +89,7 @@ mem_init (void) ...@@ -89,7 +89,7 @@ mem_init (void)
} }
} }
} }
*vel[1] = (int *)d; *vel[1] = &d;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
......
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