static gfc_dependency check_section_vs_section (gfc_array_ref *,
gfc_array_ref *, int);
+static gfc_dependency dep_ref (gfc_ref *, gfc_ref *, gfc_reverse *);
+
/* Returns 1 if the expr is an integer constant value 1, 0 if it is not or
def if the value could not be determined. */
return 0;
}
- if (identical)
- return 1;
-
/* Identical and disjoint ranges return 0,
overlapping ranges return 1. */
if (expr1->ref && expr2->ref)
- return gfc_dep_resolver (expr1->ref, expr2->ref, NULL);
+ {
+ gfc_dependency dep;
+ dep = dep_ref (expr1->ref, expr2->ref, NULL);
+ switch (dep)
+ {
+ case GFC_DEP_EQUAL:
+ return identical;
+
+ case GFC_DEP_FORWARD:
+ return 0;
+
+ case GFC_DEP_BACKWARD:
+ return 1;
+
+ case GFC_DEP_OVERLAP:
+ return 1;
+
+ case GFC_DEP_NODEP:
+ return 0;
+
+ default:
+ gcc_unreachable();
+ }
+ }
return 1;
2 : array references are overlapping but reversal of one or
more dimensions will clear the dependency.
1 : array references are overlapping.
- 0 : array references are identical or not overlapping. */
+ 0 : array references are identical or can be handled in a forward loop. */
int
gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
+{
+ enum gfc_dependency dep;
+ dep = dep_ref (lref, rref, reverse);
+ switch (dep)
+ {
+ case GFC_DEP_EQUAL:
+ return 0;
+
+ case GFC_DEP_FORWARD:
+ return 0;
+
+ case GFC_DEP_BACKWARD:
+ return 2;
+
+ case GFC_DEP_OVERLAP:
+ return 1;
+
+ case GFC_DEP_NODEP:
+ return 0;
+
+ default:
+ gcc_unreachable();
+ }
+}
+
+
+static gfc_dependency
+dep_ref (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
{
int n;
int m;
/* The two ranges can't overlap if they are from different
components. */
if (lref->u.c.component != rref->u.c.component)
- return 0;
+ return GFC_DEP_NODEP;
break;
case REF_SUBSTRING:
/* Substring overlaps are handled by the string assignment code
if there is not an underlying dependency. */
- return (fin_dep == GFC_DEP_OVERLAP) ? 1 : 0;
+
+ return fin_dep == GFC_DEP_ERROR ? GFC_DEP_NODEP : fin_dep;
case REF_ARRAY:
if (ref_same_as_full_array (lref, rref))
- return 0;
+ return GFC_DEP_EQUAL;
if (ref_same_as_full_array (rref, lref))
- return 0;
+ return GFC_DEP_EQUAL;
if (lref->u.ar.dimen != rref->u.ar.dimen)
{
fin_dep = gfc_full_array_ref_p (lref, NULL) ? GFC_DEP_EQUAL
: GFC_DEP_OVERLAP;
else
- return 1;
+ return GFC_DEP_OVERLAP;
break;
}
/* If any dimension doesn't overlap, we have no dependency. */
if (this_dep == GFC_DEP_NODEP)
- return 0;
+ return GFC_DEP_NODEP;
/* Now deal with the loop reversal logic: This only works on
ranges and is activated by setting
/* Exactly matching and forward overlapping ranges don't cause a
dependency. */
if (fin_dep < GFC_DEP_BACKWARD)
- return 0;
+ return fin_dep == GFC_DEP_ERROR ? GFC_DEP_NODEP : fin_dep;
/* Keep checking. We only have a dependency if
subsequent references also overlap. */
/* Assume the worst if we nest to different depths. */
if (lref || rref)
- return 1;
+ return GFC_DEP_OVERLAP;
- return fin_dep == GFC_DEP_OVERLAP;
+ return fin_dep;
}