aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-02-20 14:22:33 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-02-20 14:22:33 +0000
commit90f58ec8ed9cbf26dce58c867e204afd19298509 (patch)
tree198c569b1f6f7e1aa0b1e096ca980cb549bac953 /gcc
parentc849c938da6a020ec36b705ae9d4ce159661241d (diff)
downloadgcc-90f58ec8ed9cbf26dce58c867e204afd19298509.zip
gcc-90f58ec8ed9cbf26dce58c867e204afd19298509.tar.gz
gcc-90f58ec8ed9cbf26dce58c867e204afd19298509.tar.bz2
trans-stmt.c (gfc_trans_where_2): Avoid updating unused current execution mask for empty WHERE/ELSEWHERE clauses.
* trans-stmt.c (gfc_trans_where_2): Avoid updating unused current execution mask for empty WHERE/ELSEWHERE clauses. Don't allocate temporary mask arrays if they won't be used. From-SVN: r111303
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/trans-stmt.c41
2 files changed, 35 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 885cdee..b54c9df 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2006-02-20 Roger Sayle <roger@eyesopen.com>
+ * trans-stmt.c (gfc_trans_where_2): Avoid updating unused current
+ execution mask for empty WHERE/ELSEWHERE clauses. Don't allocate
+ temporary mask arrays if they won't be used.
+
+2006-02-20 Roger Sayle <roger@eyesopen.com>
+
* trans-stmt.c (gfc_trans_where_assign): Remove code to handle
traversing a linked list of MASKs. The MASK is now always a
single element requiring no ANDing during the assignment.
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 2ee881a..14a2a23 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -2960,12 +2960,28 @@ gfc_trans_where_2 (gfc_code * code, tree mask,
/* As the mask array can be very big, prefer compact boolean types. */
mask_type = gfc_get_logical_type (gfc_logical_kinds[0].kind);
- /* Allocate temporary for where mask. */
- cmask = allocate_temp_for_forall_nest_1 (mask_type, size, block, &pcmask);
+ /* Allocate temporary for WHERE mask. We only need a "cmask" if
+ there are statements to be executed. The following test only
+ checks the first ELSEWHERE to catch the F90 cases. */
+ if (cblock->next
+ || (cblock->block && cblock->block->next && cblock->block->expr)
+ || (cblock->block && cblock->block->block))
+ {
+ cmask = allocate_temp_for_forall_nest_1 (mask_type, size, block,
+ &pcmask);
+ }
+ else
+ {
+ pcmask = NULL_TREE;
+ cmask = NULL_TREE;
+ }
- if (cblock->block)
+ /* Allocate temporary for !mask. We only need a "pmask" if there
+ is an ELSEWHERE clause containing executable statements. Again
+ we only lookahead a single ELSEWHERE to catch the F90 cases. */
+ if ((cblock->block && cblock->block->next)
+ || (cblock->block && cblock->block->block))
{
- /* Allocate temporary for !mask. */
pmask = allocate_temp_for_forall_nest_1 (mask_type, size, block,
&ppmask);
}
@@ -2980,17 +2996,18 @@ gfc_trans_where_2 (gfc_code * code, tree mask,
/* Has mask-expr. */
if (cblock->expr)
{
- /* If this is the last clause of the WHERE construct, then
+ /* Ensure that the WHERE mask will be evaluated exactly once.
+ If there are no statements in this WHERE/ELSEWHERE clause,
+ then we don't need to update the control mask (cmask).
+ If this is the last clause of the WHERE construct, then
we don't need to update the pending control mask (pmask). */
- if (! cblock->block)
- pmask = NULL_TREE;
-
- /* Ensure that the WHERE mask be evaluated only once. */
- gfc_evaluate_where_mask (cblock->expr, nested_forall_info,
- mask, cmask, pmask, mask_type, block);
+ gfc_evaluate_where_mask (cblock->expr, nested_forall_info, mask,
+ cblock->next ? cmask : NULL_TREE,
+ cblock->block ? pmask : NULL_TREE,
+ mask_type, block);
}
- /* It's a elsewhere-stmt. No mask-expr is present. */
+ /* It's a final elsewhere-stmt. No mask-expr is present. */
else
cmask = mask;