2 Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 /* dependency.c -- Expression dependency analysis code. */
23 /* There's probably quite a bit of duplication in this file. We currently
24 have different dependency checking functions for different types
25 if dependencies. Ideally these would probably be merged. */
30 #include "dependency.h"
32 /* static declarations */
34 enum range
{LHS
, RHS
, MID
};
36 /* Dependency types. These must be in reverse order of priority. */
40 GFC_DEP_EQUAL
, /* Identical Ranges. */
41 GFC_DEP_FORWARD
, /* eg. a(1:3), a(2:4). */
42 GFC_DEP_OVERLAP
, /* May overlap in some other way. */
43 GFC_DEP_NODEP
/* Distinct ranges. */
48 #define IS_ARRAY_EXPLICIT(as) ((as->type == AS_EXPLICIT ? 1 : 0))
51 /* Returns 1 if the expr is an integer constant value 1, 0 if it is not or
52 def if the value could not be determined. */
55 gfc_expr_is_one (gfc_expr
* expr
, int def
)
57 gcc_assert (expr
!= NULL
);
59 if (expr
->expr_type
!= EXPR_CONSTANT
)
62 if (expr
->ts
.type
!= BT_INTEGER
)
65 return mpz_cmp_si (expr
->value
.integer
, 1) == 0;
69 /* Compare two values. Returns 0 if e1 == e2, -1 if e1 < e2, +1 if e1 > e2,
70 and -2 if the relationship could not be determined. */
73 gfc_dep_compare_expr (gfc_expr
* e1
, gfc_expr
* e2
)
77 if (e1
->expr_type
!= e2
->expr_type
)
80 switch (e1
->expr_type
)
83 if (e1
->ts
.type
!= BT_INTEGER
|| e2
->ts
.type
!= BT_INTEGER
)
86 i
= mpz_cmp (e1
->value
.integer
, e2
->value
.integer
);
94 if (e1
->ref
|| e2
->ref
)
96 if (e1
->symtree
->n
.sym
== e2
->symtree
->n
.sym
)
101 /* Intrinsic operators are the same if their operands are the same. */
102 if (e1
->value
.op
.operator != e2
->value
.op
.operator)
104 if (e1
->value
.op
.op2
== 0)
106 i
= gfc_dep_compare_expr (e1
->value
.op
.op1
, e2
->value
.op
.op1
);
107 return i
== 0 ? 0 : -2;
109 if (gfc_dep_compare_expr (e1
->value
.op
.op1
, e2
->value
.op
.op1
) == 0
110 && gfc_dep_compare_expr (e1
->value
.op
.op2
, e2
->value
.op
.op2
) == 0)
112 /* TODO Handle commutative binary operators here? */
116 /* We can only compare calls to the same intrinsic function. */
117 if (e1
->value
.function
.isym
== 0
118 || e2
->value
.function
.isym
== 0
119 || e1
->value
.function
.isym
!= e2
->value
.function
.isym
)
122 /* We should list the "constant" intrinsic functions. Those
123 without side-effects that provide equal results given equal
125 switch (e1
->value
.function
.isym
->generic_id
)
127 case GFC_ISYM_CONVERSION
:
129 case GFC_ISYM_LOGICAL
:
137 /* Compare the argument lists for equality. */
139 gfc_actual_arglist
*args1
= e1
->value
.function
.actual
;
140 gfc_actual_arglist
*args2
= e2
->value
.function
.actual
;
141 while (args1
&& args2
)
143 if (gfc_dep_compare_expr (args1
->expr
, args2
->expr
) != 0)
148 return (args1
|| args2
) ? -2 : 0;
157 /* Returns 1 if the two ranges are the same, 0 if they are not, and def
158 if the results are indeterminate. N is the dimension to compare. */
161 gfc_is_same_range (gfc_array_ref
* ar1
, gfc_array_ref
* ar2
, int n
, int def
)
167 /* TODO: More sophisticated range comparison. */
168 gcc_assert (ar1
&& ar2
);
170 gcc_assert (ar1
->dimen_type
[n
] == ar2
->dimen_type
[n
]);
174 /* Check for mismatching strides. A NULL stride means a stride of 1. */
177 i
= gfc_expr_is_one (e1
, -1);
185 i
= gfc_expr_is_one (e2
, -1);
193 i
= gfc_dep_compare_expr (e1
, e2
);
199 /* The strides match. */
201 /* Check the range start. */
206 /* Use the bound of the array if no bound is specified. */
208 e1
= ar1
->as
->lower
[n
];
211 e2
= ar2
->as
->lower
[n
];
213 /* Check we have values for both. */
217 i
= gfc_dep_compare_expr (e1
, e2
);
224 /* Check the range end. */
229 /* Use the bound of the array if no bound is specified. */
231 e1
= ar1
->as
->upper
[n
];
234 e2
= ar2
->as
->upper
[n
];
236 /* Check we have values for both. */
240 i
= gfc_dep_compare_expr (e1
, e2
);
251 /* Some array-returning intrinsics can be implemented by reusing the
252 data from one of the array arguments. For example, TRANSPOSE does
253 not necessarily need to allocate new data: it can be implemented
254 by copying the original array's descriptor and simply swapping the
255 two dimension specifications.
257 If EXPR is a call to such an intrinsic, return the argument
258 whose data can be reused, otherwise return NULL. */
261 gfc_get_noncopying_intrinsic_argument (gfc_expr
* expr
)
263 if (expr
->expr_type
!= EXPR_FUNCTION
|| !expr
->value
.function
.isym
)
266 switch (expr
->value
.function
.isym
->generic_id
)
268 case GFC_ISYM_TRANSPOSE
:
269 return expr
->value
.function
.actual
->expr
;
277 /* Return true if the result of reference REF can only be constructed
278 using a temporary array. */
281 gfc_ref_needs_temporary_p (gfc_ref
*ref
)
287 for (; ref
; ref
= ref
->next
)
291 /* Vector dimensions are generally not monotonic and must be
292 handled using a temporary. */
293 if (ref
->u
.ar
.type
== AR_SECTION
)
294 for (n
= 0; n
< ref
->u
.ar
.dimen
; n
++)
295 if (ref
->u
.ar
.dimen_type
[n
] == DIMEN_VECTOR
)
302 /* Within an array reference, character substrings generally
303 need a temporary. Character array strides are expressed as
304 multiples of the element size (consistent with other array
305 types), not in characters. */
316 /* Return true if array variable VAR could be passed to the same function
317 as argument EXPR without interfering with EXPR. INTENT is the intent
320 This is considerably less conservative than other dependencies
321 because many function arguments will already be copied into a
325 gfc_check_argument_var_dependency (gfc_expr
* var
, sym_intent intent
,
328 gcc_assert (var
->expr_type
== EXPR_VARIABLE
);
329 gcc_assert (var
->rank
> 0);
331 switch (expr
->expr_type
)
334 return (gfc_ref_needs_temporary_p (expr
->ref
)
335 || gfc_check_dependency (var
, expr
, 1));
338 return gfc_check_dependency (var
, expr
, 1);
341 if (intent
!= INTENT_IN
&& expr
->inline_noncopying_intrinsic
)
343 expr
= gfc_get_noncopying_intrinsic_argument (expr
);
344 return gfc_check_argument_var_dependency (var
, intent
, expr
);
354 /* Like gfc_check_argument_var_dependency, but extended to any
355 array expression OTHER, not just variables. */
358 gfc_check_argument_dependency (gfc_expr
* other
, sym_intent intent
,
361 switch (other
->expr_type
)
364 return gfc_check_argument_var_dependency (other
, intent
, expr
);
367 if (other
->inline_noncopying_intrinsic
)
369 other
= gfc_get_noncopying_intrinsic_argument (other
);
370 return gfc_check_argument_dependency (other
, INTENT_IN
, expr
);
380 /* Like gfc_check_argument_dependency, but check all the arguments in ACTUAL.
381 FNSYM is the function being called, or NULL if not known. */
384 gfc_check_fncall_dependency (gfc_expr
* other
, sym_intent intent
,
385 gfc_symbol
* fnsym
, gfc_actual_arglist
* actual
)
387 gfc_formal_arglist
*formal
;
390 formal
= fnsym
? fnsym
->formal
: NULL
;
391 for (; actual
; actual
= actual
->next
, formal
= formal
? formal
->next
: NULL
)
395 /* Skip args which are not present. */
399 /* Skip intent(in) arguments if OTHER itself is intent(in). */
401 && intent
== INTENT_IN
402 && formal
->sym
->attr
.intent
== INTENT_IN
)
405 if (gfc_check_argument_dependency (other
, intent
, expr
))
413 /* Return 1 if e1 and e2 are equivalenced arrays, either
414 directly or indirectly; ie. equivalence (a,b) for a and b
415 or equivalence (a,c),(b,c). This function uses the equiv_
416 lists, generated in trans-common(add_equivalences), that are
417 guaranteed to pick up indirect equivalences. We explicitly
418 check for overlap using the offset and length of the equivalence.
419 This function is symmetric.
420 TODO: This function only checks whether the full top-level
421 symbols overlap. An improved implementation could inspect
422 e1->ref and e2->ref to determine whether the actually accessed
423 portions of these variables/arrays potentially overlap. */
426 gfc_are_equivalenced_arrays (gfc_expr
*e1
, gfc_expr
*e2
)
429 gfc_equiv_info
*s
, *fl1
, *fl2
;
431 gcc_assert (e1
->expr_type
== EXPR_VARIABLE
432 && e2
->expr_type
== EXPR_VARIABLE
);
434 if (!e1
->symtree
->n
.sym
->attr
.in_equivalence
435 || !e2
->symtree
->n
.sym
->attr
.in_equivalence
440 /* Go through the equiv_lists and return 1 if the variables
441 e1 and e2 are members of the same group and satisfy the
442 requirement on their relative offsets. */
443 for (l
= gfc_current_ns
->equiv_lists
; l
; l
= l
->next
)
447 for (s
= l
->equiv
; s
; s
= s
->next
)
449 if (s
->sym
== e1
->symtree
->n
.sym
)
455 if (s
->sym
== e2
->symtree
->n
.sym
)
465 /* Can these lengths be zero? */
466 if (fl1
->length
<= 0 || fl2
->length
<= 0)
468 /* These can't overlap if [f11,fl1+length] is before
469 [fl2,fl2+length], or [fl2,fl2+length] is before
470 [fl1,fl1+length], otherwise they do overlap. */
471 if (fl1
->offset
+ fl1
->length
> fl2
->offset
472 && fl2
->offset
+ fl2
->length
> fl1
->offset
)
480 /* Return true if the statement body redefines the condition. Returns
481 true if expr2 depends on expr1. expr1 should be a single term
482 suitable for the lhs of an assignment. The IDENTICAL flag indicates
483 whether array references to the same symbol with identical range
484 references count as a dependency or not. Used for forall and where
485 statements. Also used with functions returning arrays without a
489 gfc_check_dependency (gfc_expr
* expr1
, gfc_expr
* expr2
, bool identical
)
493 gfc_actual_arglist
*actual
;
495 gcc_assert (expr1
->expr_type
== EXPR_VARIABLE
);
497 switch (expr2
->expr_type
)
500 n
= gfc_check_dependency (expr1
, expr2
->value
.op
.op1
, identical
);
503 if (expr2
->value
.op
.op2
)
504 return gfc_check_dependency (expr1
, expr2
->value
.op
.op2
, identical
);
508 /* The interesting cases are when the symbols don't match. */
509 if (expr1
->symtree
->n
.sym
!= expr2
->symtree
->n
.sym
)
511 gfc_typespec
*ts1
= &expr1
->symtree
->n
.sym
->ts
;
512 gfc_typespec
*ts2
= &expr2
->symtree
->n
.sym
->ts
;
514 /* Return 1 if expr1 and expr2 are equivalenced arrays. */
515 if (gfc_are_equivalenced_arrays (expr1
, expr2
))
518 /* Symbols can only alias if they have the same type. */
519 if (ts1
->type
!= BT_UNKNOWN
520 && ts2
->type
!= BT_UNKNOWN
521 && ts1
->type
!= BT_DERIVED
522 && ts2
->type
!= BT_DERIVED
)
524 if (ts1
->type
!= ts2
->type
525 || ts1
->kind
!= ts2
->kind
)
529 /* If either variable is a pointer, assume the worst. */
530 /* TODO: -fassume-no-pointer-aliasing */
531 if (expr1
->symtree
->n
.sym
->attr
.pointer
)
533 for (ref
= expr1
->ref
; ref
; ref
= ref
->next
)
534 if (ref
->type
== REF_COMPONENT
&& ref
->u
.c
.component
->pointer
)
537 if (expr2
->symtree
->n
.sym
->attr
.pointer
)
539 for (ref
= expr2
->ref
; ref
; ref
= ref
->next
)
540 if (ref
->type
== REF_COMPONENT
&& ref
->u
.c
.component
->pointer
)
543 /* Otherwise distinct symbols have no dependencies. */
550 /* Identical and disjoint ranges return 0,
551 overlapping ranges return 1. */
552 /* Return zero if we refer to the same full arrays. */
553 if (expr1
->ref
->type
== REF_ARRAY
&& expr2
->ref
->type
== REF_ARRAY
)
554 return gfc_dep_resolver (expr1
->ref
, expr2
->ref
);
559 if (expr2
->inline_noncopying_intrinsic
)
561 /* Remember possible differences between elemental and
562 transformational functions. All functions inside a FORALL
564 for (actual
= expr2
->value
.function
.actual
;
565 actual
; actual
= actual
->next
)
569 n
= gfc_check_dependency (expr1
, actual
->expr
, identical
);
579 /* Probably ok in the majority of (constant) cases. */
588 /* Calculates size of the array reference using lower bound, upper bound
592 get_no_of_elements(mpz_t ele
, gfc_expr
* u1
, gfc_expr
* l1
, gfc_expr
* s1
)
594 /* nNoOfEle = (u1-l1)/s1 */
596 mpz_sub (ele
, u1
->value
.integer
, l1
->value
.integer
);
599 mpz_tdiv_q (ele
, ele
, s1
->value
.integer
);
603 /* Returns if the ranges ((0..Y), (X1..X2)) overlap. */
605 static gfc_dependency
606 get_deps (mpz_t x1
, mpz_t x2
, mpz_t y
)
611 start
= mpz_cmp_ui (x1
, 0);
612 end
= mpz_cmp (x2
, y
);
614 /* Both ranges the same. */
615 if (start
== 0 && end
== 0)
616 return GFC_DEP_EQUAL
;
618 /* Distinct ranges. */
619 if ((start
< 0 && mpz_cmp_ui (x2
, 0) < 0)
620 || (mpz_cmp (x1
, y
) > 0 && end
> 0))
621 return GFC_DEP_NODEP
;
623 /* Overlapping, but with corresponding elements of the second range
624 greater than the first. */
625 if (start
> 0 && end
> 0)
626 return GFC_DEP_FORWARD
;
628 /* Overlapping in some other way. */
629 return GFC_DEP_OVERLAP
;
633 /* Perform the same linear transformation on sections l and r such that
634 (l_start:l_end:l_stride) -> (0:no_of_elements)
635 (r_start:r_end:r_stride) -> (X1:X2)
636 Where r_end is implicit as both sections must have the same number of
638 Returns 0 on success, 1 of the transformation failed. */
639 /* TODO: Should this be (0:no_of_elements-1) */
642 transform_sections (mpz_t X1
, mpz_t X2
, mpz_t no_of_elements
,
643 gfc_expr
* l_start
, gfc_expr
* l_end
, gfc_expr
* l_stride
,
644 gfc_expr
* r_start
, gfc_expr
* r_stride
)
646 if (NULL
== l_start
|| NULL
== l_end
|| NULL
== r_start
)
649 /* TODO : Currently we check the dependency only when start, end and stride
650 are constant. We could also check for equal (variable) values, and
651 common subexpressions, eg. x vs. x+1. */
653 if (l_end
->expr_type
!= EXPR_CONSTANT
654 || l_start
->expr_type
!= EXPR_CONSTANT
655 || r_start
->expr_type
!= EXPR_CONSTANT
656 || ((NULL
!= l_stride
) && (l_stride
->expr_type
!= EXPR_CONSTANT
))
657 || ((NULL
!= r_stride
) && (r_stride
->expr_type
!= EXPR_CONSTANT
)))
663 get_no_of_elements (no_of_elements
, l_end
, l_start
, l_stride
);
665 mpz_sub (X1
, r_start
->value
.integer
, l_start
->value
.integer
);
666 if (l_stride
!= NULL
)
667 mpz_cdiv_q (X1
, X1
, l_stride
->value
.integer
);
669 if (r_stride
== NULL
)
670 mpz_set (X2
, no_of_elements
);
672 mpz_mul (X2
, no_of_elements
, r_stride
->value
.integer
);
674 if (l_stride
!= NULL
)
675 mpz_cdiv_q (X2
, X2
, l_stride
->value
.integer
);
676 mpz_add (X2
, X2
, X1
);
682 /* Determines overlapping for two array sections. */
684 static gfc_dependency
685 gfc_check_section_vs_section (gfc_ref
* lref
, gfc_ref
* rref
, int n
)
697 mpz_t no_of_elements
;
704 /* If they are the same range, return without more ado. */
705 if (gfc_is_same_range (&l_ar
, &r_ar
, n
, 0))
706 return GFC_DEP_EQUAL
;
708 l_start
= l_ar
.start
[n
];
710 l_stride
= l_ar
.stride
[n
];
711 r_start
= r_ar
.start
[n
];
712 r_stride
= r_ar
.stride
[n
];
714 /* if l_start is NULL take it from array specifier */
715 if (NULL
== l_start
&& IS_ARRAY_EXPLICIT(l_ar
.as
))
716 l_start
= l_ar
.as
->lower
[n
];
718 /* if l_end is NULL take it from array specifier */
719 if (NULL
== l_end
&& IS_ARRAY_EXPLICIT(l_ar
.as
))
720 l_end
= l_ar
.as
->upper
[n
];
722 /* if r_start is NULL take it from array specifier */
723 if (NULL
== r_start
&& IS_ARRAY_EXPLICIT(r_ar
.as
))
724 r_start
= r_ar
.as
->lower
[n
];
728 mpz_init (no_of_elements
);
730 if (transform_sections (X1
, X2
, no_of_elements
,
731 l_start
, l_end
, l_stride
,
733 dep
= GFC_DEP_OVERLAP
;
735 dep
= get_deps (X1
, X2
, no_of_elements
);
737 mpz_clear (no_of_elements
);
744 /* Checks if the expr chk is inside the range left-right.
745 Returns GFC_DEP_NODEP if chk is outside the range,
746 GFC_DEP_OVERLAP otherwise.
747 Assumes left<=right. */
749 static gfc_dependency
750 gfc_is_inside_range (gfc_expr
* chk
, gfc_expr
* left
, gfc_expr
* right
)
756 s
= gfc_dep_compare_expr (left
, right
);
758 return GFC_DEP_OVERLAP
;
760 l
= gfc_dep_compare_expr (chk
, left
);
761 r
= gfc_dep_compare_expr (chk
, right
);
763 /* Check for indeterminate relationships. */
764 if (l
== -2 || r
== -2 || s
== -2)
765 return GFC_DEP_OVERLAP
;
769 /* When left>right we want to check for right <= chk <= left. */
770 if (l
<= 0 || r
>= 0)
771 return GFC_DEP_OVERLAP
;
775 /* Otherwise check for left <= chk <= right. */
776 if (l
>= 0 || r
<= 0)
777 return GFC_DEP_OVERLAP
;
780 return GFC_DEP_NODEP
;
784 /* Determines overlapping for a single element and a section. */
786 static gfc_dependency
787 gfc_check_element_vs_section( gfc_ref
* lref
, gfc_ref
* rref
, int n
)
797 l_start
= l_ar
.start
[n
] ;
798 r_start
= r_ar
.start
[n
] ;
799 r_end
= r_ar
.end
[n
] ;
800 if (NULL
== r_start
&& IS_ARRAY_EXPLICIT (r_ar
.as
))
801 r_start
= r_ar
.as
->lower
[n
];
802 if (NULL
== r_end
&& IS_ARRAY_EXPLICIT (r_ar
.as
))
803 r_end
= r_ar
.as
->upper
[n
];
804 if (NULL
== r_start
|| NULL
== r_end
|| l_start
== NULL
)
805 return GFC_DEP_OVERLAP
;
807 return gfc_is_inside_range (l_start
, r_end
, r_start
);
811 /* Traverse expr, checking all EXPR_VARIABLE symbols for their
812 forall_index attribute. Return true if any variable may be
813 being used as a FORALL index. Its safe to pessimistically
814 return true, and assume a dependency. */
817 contains_forall_index_p (gfc_expr
* expr
)
819 gfc_actual_arglist
*arg
;
827 switch (expr
->expr_type
)
830 if (expr
->symtree
->n
.sym
->forall_index
)
835 if (contains_forall_index_p (expr
->value
.op
.op1
)
836 || contains_forall_index_p (expr
->value
.op
.op2
))
841 for (arg
= expr
->value
.function
.actual
; arg
; arg
= arg
->next
)
842 if (contains_forall_index_p (arg
->expr
))
853 for (c
= expr
->value
.constructor
; c
; c
= c
->next
)
854 if (contains_forall_index_p (c
->expr
))
862 for (ref
= expr
->ref
; ref
; ref
= ref
->next
)
866 for (i
= 0; i
< ref
->u
.ar
.dimen
; i
++)
867 if (contains_forall_index_p (ref
->u
.ar
.start
[i
])
868 || contains_forall_index_p (ref
->u
.ar
.end
[i
])
869 || contains_forall_index_p (ref
->u
.ar
.stride
[i
]))
877 if (contains_forall_index_p (ref
->u
.ss
.start
)
878 || contains_forall_index_p (ref
->u
.ss
.end
))
889 /* Determines overlapping for two single element array references. */
891 static gfc_dependency
892 gfc_check_element_vs_element (gfc_ref
* lref
, gfc_ref
* rref
, int n
)
902 l_start
= l_ar
.start
[n
] ;
903 r_start
= r_ar
.start
[n
] ;
904 i
= gfc_dep_compare_expr (r_start
, l_start
);
906 return GFC_DEP_EQUAL
;
908 return GFC_DEP_NODEP
;
910 /* Treat two scalar variables as potentially equal. This allows
911 us to prove that a(i,:) and a(j,:) have no dependency. See
912 Gerald Roth, "Evaluation of Array Syntax Dependence Analysis",
913 Proceedings of the International Conference on Parallel and
914 Distributed Processing Techniques and Applications (PDPTA2001),
915 Las Vegas, Nevada, June 2001. */
916 /* However, we need to be careful when either scalar expression
917 contains a FORALL index, as these can potentially change value
918 during the scalarization/traversal of this array reference. */
919 if (contains_forall_index_p (r_start
)
920 || contains_forall_index_p (l_start
))
921 return GFC_DEP_OVERLAP
;
923 return GFC_DEP_EQUAL
;
927 /* Finds if two array references are overlapping or not.
929 1 : array references are overlapping.
930 0 : array references are identical or not overlapping. */
933 gfc_dep_resolver (gfc_ref
* lref
, gfc_ref
* rref
)
936 gfc_dependency fin_dep
;
937 gfc_dependency this_dep
;
940 fin_dep
= GFC_DEP_ERROR
;
941 /* Dependencies due to pointers should already have been identified.
942 We only need to check for overlapping array references. */
946 /* We're resolving from the same base symbol, so both refs should be
947 the same type. We traverse the reference chain intil we find ranges
948 that are not equal. */
949 gcc_assert (lref
->type
== rref
->type
);
953 /* The two ranges can't overlap if they are from different
955 if (lref
->u
.c
.component
!= rref
->u
.c
.component
)
960 /* Substring overlaps are handled by the string assignment code. */
964 for (n
=0; n
< lref
->u
.ar
.dimen
; n
++)
966 /* Assume dependency when either of array reference is vector
968 if (lref
->u
.ar
.dimen_type
[n
] == DIMEN_VECTOR
969 || rref
->u
.ar
.dimen_type
[n
] == DIMEN_VECTOR
)
971 if (lref
->u
.ar
.dimen_type
[n
] == DIMEN_RANGE
972 && rref
->u
.ar
.dimen_type
[n
] == DIMEN_RANGE
)
973 this_dep
= gfc_check_section_vs_section (lref
, rref
, n
);
974 else if (lref
->u
.ar
.dimen_type
[n
] == DIMEN_ELEMENT
975 && rref
->u
.ar
.dimen_type
[n
] == DIMEN_RANGE
)
976 this_dep
= gfc_check_element_vs_section (lref
, rref
, n
);
977 else if (rref
->u
.ar
.dimen_type
[n
] == DIMEN_ELEMENT
978 && lref
->u
.ar
.dimen_type
[n
] == DIMEN_RANGE
)
979 this_dep
= gfc_check_element_vs_section (rref
, lref
, n
);
982 gcc_assert (rref
->u
.ar
.dimen_type
[n
] == DIMEN_ELEMENT
983 && lref
->u
.ar
.dimen_type
[n
] == DIMEN_ELEMENT
);
984 this_dep
= gfc_check_element_vs_element (rref
, lref
, n
);
987 /* If any dimension doesn't overlap, we have no dependency. */
988 if (this_dep
== GFC_DEP_NODEP
)
991 /* Overlap codes are in order of priority. We only need to
992 know the worst one.*/
993 if (this_dep
> fin_dep
)
996 /* Exactly matching and forward overlapping ranges don't cause a
998 if (fin_dep
< GFC_DEP_OVERLAP
)
1001 /* Keep checking. We only have a dependency if
1002 subsequent references also overlap. */
1012 /* If we haven't seen any array refs then something went wrong. */
1013 gcc_assert (fin_dep
!= GFC_DEP_ERROR
);
1015 /* Assume the worst if we nest to different depths. */
1019 return fin_dep
== GFC_DEP_OVERLAP
;