From 641e68d74828fbbdd8b496bc9964b152e34bd480 Mon Sep 17 00:00:00 2001 From: xnpster Date: Wed, 1 Oct 2025 19:48:34 +0300 Subject: [PATCH] REMOVE_DIST_ARRAYS_FROM_IO: consider write/read statements with nested loops --- .../replace_dist_arrays_in_io.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp index 248cea2..c40bdba 100644 --- a/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp +++ b/src/Transformations/ReplaceArraysInIO/replace_dist_arrays_in_io.cpp @@ -17,6 +17,14 @@ using std::pair; #define DEBUG_TRACE 0 +static bool hasArrayRef(SgExpression* ex) +{ + if (ex) + return isArrayRef(ex) || hasArrayRef(ex->lhs()) || hasArrayRef(ex->rhs()); + + return false; +} + static inline bool isArrayDeclaration(SgStatement* st) { return isSgDeclarationStatement(st) || isSgVarListDeclStmt(st) || isSgNestedVarListDeclStmt(st); @@ -201,11 +209,15 @@ static bool populateDistributedIoArrays(map>& array if (!arg) return false; - if (!isArrayRef(arg)) + if (hasArrayRef(arg)) + { + if (isArrayRef(arg) && arg->lhs()) + need_replace = true; + } + else + { return false; - - if (arg->lhs()) - need_replace = true; + } } else {