REMOVE_DIST_ARRAYS_FROM_IO: consider write/read statements with nested loops

This commit is contained in:
2025-10-01 19:48:34 +03:00
committed by Egor Mayorov
parent afc88bf056
commit 641e68d748

View File

@@ -17,6 +17,14 @@ using std::pair;
#define DEBUG_TRACE 0 #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) static inline bool isArrayDeclaration(SgStatement* st)
{ {
return isSgDeclarationStatement(st) || isSgVarListDeclStmt(st) || isSgNestedVarListDeclStmt(st); return isSgDeclarationStatement(st) || isSgVarListDeclStmt(st) || isSgNestedVarListDeclStmt(st);
@@ -201,13 +209,17 @@ static bool populateDistributedIoArrays(map<SgSymbol*, set<SgStatement*>>& array
if (!arg) if (!arg)
return false; return false;
if (!isArrayRef(arg)) if (hasArrayRef(arg))
return false; {
if (isArrayRef(arg) && arg->lhs())
if (arg->lhs())
need_replace = true; need_replace = true;
} }
else else
{
return false;
}
}
else
{ {
need_replace = true; need_replace = true;
} }