[PATCH] Fix PR34706, PR34683 -- use more precise types for fortran arrays
Richard Guenther
rguenther@suse.de
Tue Jan 8 15:49:00 GMT 2008
This improves the type accuracy of fortran array types as used for example
for the temporaries in the testcase in PR34683. This allows the
middle-end to more precisely see what is accessed and thus it reduces the
number of VOPs generated which in turn improves compile-time of that
testcase (-O -fstrict-aliasing) from 120s to 80s.
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for mainline?
Thanks,
Richard.
2008-01-08 Richard Guenther <rguenther@suse.de>
PR fortran/34706
PR tree-optimization/34683
* trans-types.c (gfc_get_array_type_bounds): Use an array type
with known size for accesses if that is known.
Index: fortran/trans-types.c
===================================================================
*** fortran/trans-types.c (revision 131372)
--- fortran/trans-types.c (working copy)
*************** gfc_get_array_type_bounds (tree etype, i
*** 1436,1442 ****
enum gfc_array_kind akind)
{
char name[8 + GFC_RANK_DIGITS + GFC_MAX_SYMBOL_LEN];
! tree fat_type, base_type, arraytype, lower, upper, stride, tmp;
const char *typename;
int n;
--- 1436,1442 ----
enum gfc_array_kind akind)
{
char name[8 + GFC_RANK_DIGITS + GFC_MAX_SYMBOL_LEN];
! tree fat_type, base_type, arraytype, lower, upper, stride, tmp, rtype;
const char *typename;
int n;
*************** gfc_get_array_type_bounds (tree etype, i
*** 1511,1520 ****
/* TODO: known offsets for descriptors. */
GFC_TYPE_ARRAY_OFFSET (fat_type) = NULL_TREE;
! /* We define data as an unknown size array. Much better than doing
! pointer arithmetic. */
! arraytype =
! build_array_type (etype, gfc_array_range_type);
arraytype = build_pointer_type (arraytype);
GFC_TYPE_ARRAY_DATAPTR_TYPE (fat_type) = arraytype;
--- 1511,1525 ----
/* TODO: known offsets for descriptors. */
GFC_TYPE_ARRAY_OFFSET (fat_type) = NULL_TREE;
! /* We define data as an array with the correct size if possible.
! Much better than doing pointer arithmetic. */
! if (stride)
! rtype = build_range_type (gfc_array_index_type, gfc_index_zero_node,
! int_const_binop (MINUS_EXPR, stride,
! integer_one_node, 0));
! else
! rtype = gfc_array_range_type;
! arraytype = build_array_type (etype, rtype);
arraytype = build_pointer_type (arraytype);
GFC_TYPE_ARRAY_DATAPTR_TYPE (fat_type) = arraytype;
More information about the Fortran
mailing list