2 Commits

Author SHA1 Message Date
1c39001e28 small fix 2025-12-23 16:29:10 +03:00
7802f538e8 add whole array assign 2025-12-23 02:03:57 +03:00
2 changed files with 26 additions and 15 deletions

View File

@@ -72,8 +72,7 @@ static void Collapse(Region* region)
for (auto& [arrayName, arrayRanges] : byBlock->array_use)
useUnion[arrayName] = useUnion[arrayName].Union(byBlock->array_use[arrayName]);
for (auto& [arrayName, arrayRanges] : useUnion)
region->array_priv[arrayName] = useUnion[arrayName].Diff(region->array_use[arrayName]);
region->array_priv = region->array_use;
for (Region* prevBlock : region->getHeader()->getPrevRegions())
prevBlock->replaceInNextRegions(region, region->getHeader());
@@ -153,19 +152,6 @@ static void SolveDataFlow(Region* DFG)
Collapse(DFG);
}
/*unsigned long long CalculateLength(const AccessingSet& array)
{
if (array.GetElements().empty())
return 0;
unsigned long long result = 1;
for (const auto& range : array.GetElements())
for (const auto& dim : range)
result *= (dim.step * dim.tripCount);
return result;
}*/
static void AddPrivateArraysToLoop(LoopGraph* loop, const ArrayAccessingIndexes& privates, set<SgStatement*>& insertedPrivates)
{
SgStatement* spfStat = new SgStatement(SPF_ANALYSIS_DIR);

View File

@@ -105,6 +105,31 @@ static int GetDefUseArray(SAPFOR::BasicBlock* block, LoopGraph* loop, ArrayAcces
auto operation = instruction->getInstruction()->getOperation();
auto type = instruction->getInstruction()->getArg1()->getType();
if (operation == SAPFOR::CFG_OP::ASSIGN && instruction->getInstruction()->getResult()->getType() == SAPFOR::CFG_ARG_TYPE::ARRAY)
{
SgStatement* op = instruction->getInstruction()->getOperator();
if (op && op->expr(0) && isArrayRef(op->expr(0)) && op->expr(0)->symbol() && op->expr(0)->type())
{
if (isSgArrayType(op->expr(0)->symbol()->type()))
{
SgArrayType* arrayType = (SgArrayType*)op->expr(0)->symbol()->type();
int dimCount = ((SgArrayType*)op->expr(0)->symbol()->type())->dimension();
vector<ArrayDimension> point;
for (int i = 0; i < dimCount; i++)
{
string strDimLength = arrayType->sizeInDim(i)->unparse();
if (arrayType->sizeInDim(i)->variant() == INT_VAL && strDimLength != "0")
{
point.push_back({ 1ULL, 1ULL, (uint64_t)stoi(strDimLength), (SgArrayRefExp*)op->expr(0) });
}
}
if (point.size() == dimCount)
{
def[instruction->getInstruction()->getResult()->getValue()] = AccessingSet({point});
}
}
}
}
if ((operation == SAPFOR::CFG_OP::STORE || operation == SAPFOR::CFG_OP::LOAD) && type == SAPFOR::CFG_ARG_TYPE::ARRAY)
{
vector<SAPFOR::Argument*> index_vars;