This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Inline SIZE if cheap (PR fortran/38181)
On Thu, Nov 20, 2008 at 10:40:01AM +0100, Paul Richard Thomas wrote:
> This good; I thought about doing the same but, having reduced the
> calls from 2+2*number of loops, I thought that one was enough:-)
>
> OK for trunk.
After committing, I've noticed that the FE already has precomputed
build_int_cst (gfc_array_index_type, 0)
and
build_int_cst (gfc_array_index_type, 1).
So the following patch saves the unnecessary build_int_cst calls
(and does the same in gfc_conv_intrinsic_minmaxloc as well).
Bootstrapped/regtested on x86_64-linux, committed to trunk as obvious.
2008-11-20 Jakub Jelinek <jakub@redhat.com>
* trans-intrinsic.c (gfc_conv_intrinsic_minmaxloc): Use
gfc_index_one_node.
(gfc_conv_intrinsic_size): Use gfc_index_{zero,one}_node.
--- gcc/fortran/trans-intrinsic.c.jj 2008-11-20 01:41:11.000000000 +0100
+++ gcc/fortran/trans-intrinsic.c 2008-11-20 14:14:36.000000000 +0100
@@ -2209,7 +2209,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * s
tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
gfc_index_one_node, loop.from[0]);
else
- tmp = build_int_cst (gfc_array_index_type, 1);
+ tmp = gfc_index_one_node;
gfc_add_modify (&block, offset, tmp);
@@ -3422,14 +3422,13 @@ gfc_conv_intrinsic_size (gfc_se * se, gf
else
{
se->expr = NULL_TREE;
- argse.expr = fold_build2 (MINUS_EXPR,
- gfc_array_index_type, argse.expr,
- build_int_cst (gfc_array_index_type, 1));
+ argse.expr = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+ argse.expr, gfc_index_one_node);
}
}
else if (expr->value.function.actual->expr->rank == 1)
{
- argse.expr = build_int_cst (gfc_array_index_type, 0);
+ argse.expr = gfc_index_zero_node;
se->expr = NULL_TREE;
}
else
@@ -3445,9 +3444,9 @@ gfc_conv_intrinsic_size (gfc_se * se, gf
se->expr = fold_build2 (MINUS_EXPR, gfc_array_index_type,
ubound, lbound);
se->expr = fold_build2 (PLUS_EXPR, gfc_array_index_type, se->expr,
- build_int_cst (gfc_array_index_type, 1));
+ gfc_index_one_node);
se->expr = fold_build2 (MAX_EXPR, gfc_array_index_type, se->expr,
- build_int_cst (gfc_array_index_type, 0));
+ gfc_index_zero_node);
}
type = gfc_typenode_for_spec (&expr->ts);
Jakub