[PATCH] fortran/30207 -- Fix a WHERE and array section problem
Paul Thomas
paulthomas2@wanadoo.fr
Sun Dec 17 16:40:00 GMT 2006
Roger and Steve,
> Ok for mainline? My apologies for any potential e-mail problems; I'm
> using a new mail client and this is my first attempt posting a patch
> to gcc-patches/fortran with it. Hopefully, the attachment will be fine,
> but it seems to insist on wrapping my ChangeLog entry :-(
>
I'm sorry that I took a little bit with this - I was checking out some
simpler alternatives.... which broke things!
OK for trunk and, I would suggest, 4.2 after a week or so of digestion!
Thanks to you both
Paul
>
>
> 2006-12-14 Roger Sayle <roger@eyesopen.com>
>
> PR fortran/30207
> * dependency.c (gfc_full_array_ref_p): New function to test whether
> the given array ref specifies the entire array.
> (gfc_dep_resolver): Use gfc_full_array_ref_p to analyze AR_FULL
> array refs against AR_SECTION array refs, and vice versa.
> * dependency.h (gfc_full_array_ref_p): Prototype here.
> * trans-array.c (gfc_conv_expr_descriptor):Use gfc_full_array_ref_p.
>
> 2006-12-14 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/30207
> * gfortran.fortran-torture/execute/where21.f90: New test.
>
>
> ------------------------------------------------------------------------
>
> Index: dependency.c
> ===================================================================
> *** dependency.c (revision 119864)
> --- dependency.c (working copy)
> *************** gfc_check_element_vs_element (gfc_ref *
> *** 1108,1113 ****
> --- 1108,1153 ----
> }
>
>
> + /* Determine if an array ref, usually an array section specifies the
> + entire array. */
> +
> + bool
> + gfc_full_array_ref_p (gfc_ref *ref)
> + {
> + int i;
> +
> + if (ref->type != REF_ARRAY)
> + return false;
> + if (ref->u.ar.type == AR_FULL)
> + return true;
> + if (ref->u.ar.type != AR_SECTION)
> + return false;
> +
> + for (i = 0; i < ref->u.ar.dimen; i++)
> + {
> + /* Check the lower bound. */
> + if (ref->u.ar.start[i]
> + && (!ref->u.ar.as
> + || !ref->u.ar.as->lower[i]
> + || gfc_dep_compare_expr (ref->u.ar.start[i],
> + ref->u.ar.as->lower[i])))
> + return false;
> + /* Check the upper bound. */
> + if (ref->u.ar.end[i]
> + && (!ref->u.ar.as
> + || !ref->u.ar.as->upper[i]
> + || gfc_dep_compare_expr (ref->u.ar.end[i],
> + ref->u.ar.as->upper[i])))
> + return false;
> + /* Check the stride. */
> + if (ref->u.ar.stride[i]
> + && !gfc_expr_is_one (ref->u.ar.stride[i], 0))
> + return false;
> + }
> + return true;
> + }
> +
> +
> /* Finds if two array references are overlapping or not.
> Return value
> 1 : array references are overlapping.
> *************** gfc_dep_resolver (gfc_ref * lref, gfc_re
> *** 1145,1150 ****
> --- 1185,1203 ----
> return 0;
>
> case REF_ARRAY:
> + if (lref->u.ar.dimen != rref->u.ar.dimen)
> + {
> + if (lref->u.ar.type == AR_FULL)
> + fin_dep = gfc_full_array_ref_p (rref) ? GFC_DEP_EQUAL
> + : GFC_DEP_OVERLAP;
> + else if (rref->u.ar.type == AR_FULL)
> + fin_dep = gfc_full_array_ref_p (lref) ? GFC_DEP_EQUAL
> + : GFC_DEP_OVERLAP;
> + else
> + return 1;
> + break;
> + }
> +
> for (n=0; n < lref->u.ar.dimen; n++)
> {
> /* Assume dependency when either of array reference is vector
> Index: dependency.h
> ===================================================================
> *** dependency.h (revision 119864)
> --- dependency.h (working copy)
> *************** Software Foundation, 51 Franklin Street,
> *** 22,27 ****
> --- 22,28 ----
>
>
> bool gfc_ref_needs_temporary_p (gfc_ref *);
> + bool gfc_full_array_ref_p (gfc_ref *);
> gfc_expr *gfc_get_noncopying_intrinsic_argument (gfc_expr *);
> int gfc_check_fncall_dependency (gfc_expr *, sym_intent, gfc_symbol *,
> gfc_actual_arglist *);
> Index: trans-array.c
> ===================================================================
> *** trans-array.c (revision 119864)
> --- trans-array.c (working copy)
> *************** gfc_conv_expr_descriptor (gfc_se * se, g
> *** 4147,4153 ****
> tree start;
> tree offset;
> int full;
> - gfc_ref *ref;
>
> gcc_assert (ss != gfc_ss_terminator);
>
> --- 4147,4152 ----
> *************** gfc_conv_expr_descriptor (gfc_se * se, g
> *** 4184,4208 ****
> else if (se->direct_byref)
> full = 0;
> else
> ! {
> ! ref = info->ref;
> ! gcc_assert (ref->u.ar.type == AR_SECTION);
> !
> ! full = 1;
> ! for (n = 0; n < ref->u.ar.dimen; n++)
> ! {
> ! /* Detect passing the full array as a section. This could do
> ! even more checking, but it doesn't seem worth it. */
> ! if (ref->u.ar.start[n]
> ! || ref->u.ar.end[n]
> ! || (ref->u.ar.stride[n]
> ! && !gfc_expr_is_one (ref->u.ar.stride[n], 0)))
> ! {
> ! full = 0;
> ! break;
> ! }
> ! }
> ! }
>
> if (full)
> {
> --- 4183,4189 ----
> else if (se->direct_byref)
> full = 0;
> else
> ! full = gfc_full_array_ref_p (info->ref);
>
> if (full)
> {
More information about the Gcc-patches
mailing list