[PATCH] Use logical1 for forall mask array if possible (was Re: [gfortran testsuite, committed] Re: gfortran.dg/forall_1.f90)
Jakub Jelinek
jakub@redhat.com
Sun Jun 12 19:52:00 GMT 2005
On Tue, Jun 07, 2005 at 09:39:36PM +0200, Tobias Schl?ter wrote:
> If we were more efficient in deciding what we need to know about the mask, we
> could probably be much more efficient than by optimizing the way we're
> representing the mask in memory. Obviously, the former is a difficult task,
> whereas the latter will be fairly easy, so we should probably go for it.
Well, there will still be cases where we really need the temp array.
So doing this and making the dependency checking code smarter are
separate things that are both desirable.
Here is a patch that makes it use logical1 on most targets (really smallest
logical type). Tested with make check-f95.
2005-06-12 Jakub Jelinek <jakub@redhat.com>
* trans-stmt.c (gfc_trans_forall_1): Prefer to use smaller logical
type than boolean_type_node.
--- gcc/fortran/trans-stmt.c.jj 2005-06-12 12:27:17.455990000 -0400
+++ gcc/fortran/trans-stmt.c 2005-06-12 13:29:16.910939158 -0400
@@ -2346,11 +2346,17 @@ gfc_trans_forall_1 (gfc_code * code, for
For now we assume a mask temporary is needed. */
if (code->expr)
{
+ /* As the mask array can be very big, prefer compact
+ boolean types. */
+ tree smallest_boolean_type_node
+ = gfc_get_logical_type (gfc_logical_kinds[0].kind);
+
/* Allocate the mask temporary. */
bytesize = fold_build2 (MULT_EXPR, gfc_array_index_type, size,
- TYPE_SIZE_UNIT (boolean_type_node));
+ TYPE_SIZE_UNIT (smallest_boolean_type_node));
- mask = gfc_do_allocate (bytesize, size, &pmask, &block, boolean_type_node);
+ mask = gfc_do_allocate (bytesize, size, &pmask, &block,
+ smallest_boolean_type_node);
maskindex = gfc_create_var_np (gfc_array_index_type, "mi");
/* Record them in the info structure. */
@@ -2369,7 +2375,7 @@ gfc_trans_forall_1 (gfc_code * code, for
gfc_add_block_to_block (&body, &se.pre);
/* Store the mask. */
- se.expr = convert (boolean_type_node, se.expr);
+ se.expr = convert (smallest_boolean_type_node, se.expr);
if (pmask)
tmp = gfc_build_indirect_ref (mask);
Jakub
More information about the Fortran
mailing list