aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@inria.fr>2007-03-15 00:23:24 +0100
committerSebastian Pop <spop@gcc.gnu.org>2007-03-14 23:23:24 +0000
commitc4d8f83b551c953d7cbbe85cf24bab3595defaaa (patch)
treed21c23b85fba4827eae8894e489ee403c78576ed /gcc
parent1f7f19c46a9fa0c1be528bfb9fa54196d8ca0e4b (diff)
downloadgcc-c4d8f83b551c953d7cbbe85cf24bab3595defaaa.zip
gcc-c4d8f83b551c953d7cbbe85cf24bab3595defaaa.tar.gz
gcc-c4d8f83b551c953d7cbbe85cf24bab3595defaaa.tar.bz2
tree-loop-linear.c (gather_interchange_stats): For multidimensional arrays...
* tree-loop-linear.c (gather_interchange_stats): For multidimensional arrays, multiply the access strides by the size of the sub-array. * testsuite/gcc.dg/tree-ssa/ltrans-5.c: New. From-SVN: r122935
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ltrans-5.c17
-rw-r--r--gcc/tree-loop-linear.c22
3 files changed, 37 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3cb3328..56d9d74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-14 Sebastian Pop <sebastian.pop@inria.fr>
+
+ * tree-loop-linear.c (gather_interchange_stats): For multidimensional
+ arrays, multiply the access strides by the size of the sub-array.
+ * testsuite/gcc.dg/tree-ssa/ltrans-5.c: New.
+
2007-03-14 Uros Bizjak <ubizjak@gmail.com>
* configure.ac (HAVE_AS_IX86_SAHF): On x86 targets check whether
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ltrans-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ltrans-5.c
new file mode 100644
index 0000000..fae44d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ltrans-5.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-linear -fdump-tree-ltrans-all" } */
+
+int foo ()
+{
+ int A[100][1111];
+ int i, j;
+
+ for( i = 0; i < 1111; i++)
+ for( j = 0; j < 100; j++)
+ A[j][i] = 5 * A[j][i];
+
+ return A[10][10];
+}
+
+/* { dg-final { scan-tree-dump-times "transformed loop" 1 "ltrans"} } */
+/* { dg-final { cleanup-tree-dump "ltrans" } } */
diff --git a/gcc/tree-loop-linear.c b/gcc/tree-loop-linear.c
index 61fdee3..94f3d59 100644
--- a/gcc/tree-loop-linear.c
+++ b/gcc/tree-loop-linear.c
@@ -134,24 +134,30 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
{
unsigned int it;
+ tree ref = DR_REF (dr);
tree stmt = DR_STMT (dr);
struct loop *stmt_loop = loop_containing_stmt (stmt);
struct loop *inner_loop = first_loop->inner;
-
+
if (inner_loop != stmt_loop
&& !flow_loop_nested_p (inner_loop, stmt_loop))
continue;
- for (it = 0; it < DR_NUM_DIMENSIONS (dr); it++)
+
+ for (it = 0; it < DR_NUM_DIMENSIONS (dr);
+ it++, ref = TREE_OPERAND (ref, 0))
{
tree chrec = DR_ACCESS_FN (dr, it);
- tree tstride = evolution_part_in_loop_num
- (chrec, loop->num);
-
+ tree tstride = evolution_part_in_loop_num (chrec, loop->num);
+ tree array_size = TYPE_SIZE (TREE_TYPE (ref));
+
if (tstride == NULL_TREE
- || TREE_CODE (tstride) != INTEGER_CST)
+ || array_size == NULL_TREE
+ || TREE_CODE (tstride) != INTEGER_CST
+ || TREE_CODE (array_size) != INTEGER_CST)
continue;
-
- (*access_strides) += int_cst_value (tstride);
+
+ (*access_strides) +=
+ int_cst_value (array_size) * int_cst_value (tstride);
}
}
}