aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2007-01-18 18:17:08 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2007-01-18 18:17:08 +0000
commit3bf783b7e2095210aaee3da1e797b4348b796896 (patch)
tree8e73ebedbd664148992d609d0ca894ca246ff53c /gcc
parente2265be077337cbef09d8910ee391b3f3f7a048f (diff)
downloadgcc-3bf783b7e2095210aaee3da1e797b4348b796896.zip
gcc-3bf783b7e2095210aaee3da1e797b4348b796896.tar.gz
gcc-3bf783b7e2095210aaee3da1e797b4348b796896.tar.bz2
trans-stmt.c (compute_overall_iter_number): Enhance to precompute the number of interations in unconditional FORALL nests...
* trans-stmt.c (compute_overall_iter_number): Enhance to precompute the number of interations in unconditional FORALL nests with constant bounds. From-SVN: r120905
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-stmt.c30
2 files changed, 33 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 55c5ece..4c1a3c5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2007-01-18 Roger Sayle <roger@eyesopen.com>
+
+ * trans-stmt.c (compute_overall_iter_number): Enhance to precompute
+ the number of interations in unconditional FORALL nests with constant
+ bounds.
+
2007-01-18 Francois-Xavier Coudert <coudert@clipper.ens.fr>
Tobias Burnus <burnus@net-b.de>
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 437aa36..c36d6fa 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -2034,9 +2034,33 @@ compute_overall_iter_number (forall_info *nested_forall_info, tree inner_size,
tree tmp, number;
stmtblock_t body;
- /* Optimize the case for an outer-most loop with constant bounds. */
- if (INTEGER_CST_P (inner_size) && !nested_forall_info)
- return inner_size;
+ /* Optimize the case of unconditional FORALL nests with constant bounds. */
+ if (INTEGER_CST_P (inner_size))
+ {
+ bool all_const_p = true;
+ forall_info *forall_tmp;
+
+ /* First check whether all the bounds are constant. */
+ for (forall_tmp = nested_forall_info;
+ forall_tmp;
+ forall_tmp = forall_tmp->next_nest)
+ if (forall_tmp->mask || !INTEGER_CST_P (forall_tmp->size))
+ {
+ all_const_p = false;
+ break;
+ }
+
+ if (all_const_p)
+ {
+ tree tmp = inner_size;
+ for (forall_tmp = nested_forall_info;
+ forall_tmp;
+ forall_tmp = forall_tmp->next_nest)
+ tmp = fold_build2 (MULT_EXPR, gfc_array_index_type,
+ tmp, forall->size);
+ return tmp;
+ }
+ }
/* TODO: optimizing the computing process. */
number = gfc_create_var (gfc_array_index_type, "num");