[Fortran] Yet more array dependence improvements
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Mar 10 16:59:00 GMT 2006
On Thu, Mar 09, 2006 at 11:00:36PM -0700, Roger Sayle wrote:
> On Thu, 9 Mar 2006, Steve Kargl wrote:
> > > + if (gfc_dep_compare_expr (e1->value.op.op1, e2->value.op.op1) == 0
> > > + && gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op2) == 0)
> > > + return 0;
> >
> > This deals with "n + 1" == "n + 1"
> >
> > > + /* TODO Handle commutative binary operators here? */
> > > + return -2;
> >
> > Is this comment for "n + 1" == "1 + n"? Won't the following work?
> >
> > if (gfc_dep_compare_expr (e1->value.op.op1, e2->value.op.op2) == 0
> > && gfc_dep_compare_expr (e1->value.op.op2, e2->value.op.op1) == 0)
> > return 0;
>
> Yes, this is exactly the test to handle commutative operators.
> The only reason I didn't add support for this in this patch, is
> the need to audit and explicitly list the commutative operators.
> i.e. your test above works fine for INTRINSIC_PLUS and INTRINSIC_EQ,
> but isn't applicable for INTRINSIC_DIVIDE and INTRINSIC_MINUS.
> I suspect the number of places where we benefit from identifying
> that "n+1" is the same as "1+n" is fairly limited. However, it
> might be nice if someone added this as a follow-up patch.
Thanks for the explanation. Of course, there was a serious
disconnect between my ears because your comment did include
"commutative binary operators" and division is clearly not
commutative in general.
> > > + /* We should list the "constant" intrinsic functions. Those
> > > + without side-effects that provide equal results given equal
> > > + argument lists. */
> >
> > I don't understand this comment. Intrinsic functions in Fortran 95
> > are pure, so by definition none of the intrinsic functions have
> > side-effects. Is this comment meant for the intrinsics that gfortran
> > inlines/turns-into __convert_* fucntions?
>
> Hmm, this wasn't clear from the gfc_generic_isym_id enumeration.
> For example, the symbols GFC_ISYM_CHDIR, GFC_ISYM_CTIME,
> GFC_ISYM_FGETC, GFC_ISYM_MALLOC, GFC_ISYM_SYSTEM, etc... give
> the impression that gfortran's intrinsic functions can have
> quite significant side-effects.
Whoops, as one of the people who implemented some of these
nonstandard intrinsics procedure, I should have remember that
side-effects might occur. I've been spending too much time
with the Standard.
I'll review the patch tomorrow.
--
Steve
More information about the Fortran
mailing list