diff options
author | Razya Ladelsky <razya@il.ibm.com> | 2007-06-05 10:48:33 +0000 |
---|---|---|
committer | Razya Ladelsky <razya@gcc.gnu.org> | 2007-06-05 10:48:33 +0000 |
commit | b8ff1d5bbb496e1afc8580f129706e18ddad09ea (patch) | |
tree | 9187506bf0371b9dc9b15f8f5c7415edca8032a4 /gcc | |
parent | cc55c4b0747681df3256493e2d10fd482ec451f8 (diff) | |
download | gcc-b8ff1d5bbb496e1afc8580f129706e18ddad09ea.zip gcc-b8ff1d5bbb496e1afc8580f129706e18ddad09ea.tar.gz gcc-b8ff1d5bbb496e1afc8580f129706e18ddad09ea.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/matrix-reorg.c | 69 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/matrix/matrix-6.c | 2 |
3 files changed, 49 insertions, 28 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 964a347..8862f51 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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> * config/i386/i386.c (override_options): Use diff --git a/gcc/matrix-reorg.c b/gcc/matrix-reorg.c index 98bb895..e5bd461 100644 --- a/gcc/matrix-reorg.c +++ b/gcc/matrix-reorg.c @@ -1654,6 +1654,42 @@ record_all_accesses_in_func (void) 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 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. @@ -1783,8 +1819,6 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED) tmp1 = offset; else { - int x, y; - tree ratio; tree new_offset; tree d_type_size, d_type_size_k; @@ -1793,29 +1827,11 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED) mi->dimension_type_size[min_escape_l]); d_type_size_k = 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) - { - if (x - y == 0) - 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); - } + new_offset = + compute_offset (mi->dimension_type_size[min_escape_l], + mi->dimension_type_size[k + 1], offset); + total_elements = new_offset; if (new_offset != offset) { @@ -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 with the size of DIM1*DIM2*...*DIMN*size_of_element 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) add_new_static_var (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. */ /* Find which dim ID becomes dim I. */ for (id = 0; id < mi->min_indirect_level_escape; id++) if (mi->dim_map[id] == i) break; + d_type_size = + build_int_cst (type, mi->dimension_type_size[id + 1]); if (!prev_dim_size) prev_dim_size = build_int_cst (type, element_size); if (!check_transpose_p && i == mi->min_indirect_level_escape - 1) diff --git a/gcc/testsuite/gcc.dg/matrix/matrix-6.c b/gcc/testsuite/gcc.dg/matrix/matrix-6.c index 3b9fcee..536afb5 100644 --- a/gcc/testsuite/gcc.dg/matrix/matrix-6.c +++ b/gcc/testsuite/gcc.dg/matrix/matrix-6.c @@ -89,7 +89,7 @@ mem_init (void) } } } - *vel[1] = (int *)d; + *vel[1] = &d; } /*--------------------------------------------------------------------------*/ |