From 31f5d9d7ff22417a04fad4035d4a4e0060f24ddb Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Fri, 30 Jan 2026 11:41:42 +1100 Subject: [PATCH 1/3] #3310 Optimised dependency analysis by special handling of comparing simple reference. --- src/psyclone/psyir/tools/dependency_tools.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/psyclone/psyir/tools/dependency_tools.py b/src/psyclone/psyir/tools/dependency_tools.py index c9571c5b2f..12722f049f 100644 --- a/src/psyclone/psyir/tools/dependency_tools.py +++ b/src/psyclone/psyir/tools/dependency_tools.py @@ -657,7 +657,21 @@ def _is_loop_carried_dependency(self, loop_variables, write_access, return True elif len(set_of_vars) == 1: # One loop variable used in both accesses. - # E.g. `a(2*i+3) = a(i*i)` + # E.g. `a(2*i+3) = a(i*i)`. Add a shortcut for + # a very common case - the index is a simple reference + if (isinstance(index_write, Reference) and + isinstance(index_other, Reference) and + index_write == index_other): + if index_write.name == loop_var: + # a(j, ...) and a(j, ...) - these accesses + # will never overlap for different j, independent + # of the expressions in the other dimensions + return True + # The expression does not depend on the loop variable + # at all (dependency distance would return None), + # again no need for an explicit test, we can continue + # the outer loop + continue distance = self._get_dependency_distance(loop_var, index_write, index_other) From fe1b69b51ead7baf39f6372b52aad1770bd17c69 Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Fri, 30 Jan 2026 11:43:31 +1100 Subject: [PATCH 2/3] #3310 Fixed missing import and flake8/pylint. --- src/psyclone/psyir/tools/dependency_tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/psyclone/psyir/tools/dependency_tools.py b/src/psyclone/psyir/tools/dependency_tools.py index 12722f049f..7cf69bcbfb 100644 --- a/src/psyclone/psyir/tools/dependency_tools.py +++ b/src/psyclone/psyir/tools/dependency_tools.py @@ -48,7 +48,7 @@ from psyclone.errors import InternalError, LazyString from psyclone.psyir.backend.sympy_writer import SymPyWriter from psyclone.psyir.backend.visitor import VisitorError -from psyclone.psyir.nodes import Loop, Node, Range +from psyclone.psyir.nodes import Loop, Node, Range, Reference # pylint: disable=too-many-lines @@ -660,8 +660,8 @@ def _is_loop_carried_dependency(self, loop_variables, write_access, # E.g. `a(2*i+3) = a(i*i)`. Add a shortcut for # a very common case - the index is a simple reference if (isinstance(index_write, Reference) and - isinstance(index_other, Reference) and - index_write == index_other): + isinstance(index_other, Reference) and + index_write == index_other): if index_write.name == loop_var: # a(j, ...) and a(j, ...) - these accesses # will never overlap for different j, independent From 9a9815a15f1d57bdf6bcd648e65a276577dce116 Mon Sep 17 00:00:00 2001 From: Andrew Porter Date: Thu, 5 Feb 2026 15:59:18 +0000 Subject: [PATCH 3/3] #3311 update changelog --- changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog b/changelog index 33d7c06f0f..5069a2ec37 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ + 38) PR #3311 for #3310. Small optimisation to the dependence-analysis + functionality for array indices consisting of simple References. + 37) PR #3295 for #3292. Add command-line flag to permit config-file settings to be overridden and extend possible settings for the runtime warnings option.