5 Commits

Author SHA1 Message Date
Egor Mayorov
3058882793 fix files usage 2026-03-26 14:10:05 +03:00
ALEXks
63615ae50e fixed function prototype 2026-03-20 15:49:08 +03:00
ALEXks
746bdf29b2 Merge branch 'master' into egormayorov 2026-03-20 15:33:38 +03:00
ALEXks
16f0560c8e updated 2026-03-20 15:33:33 +03:00
Egor Mayorov
8cae169131 Add swith to file usage 2026-03-18 00:44:22 +03:00
3 changed files with 16 additions and 40 deletions

View File

@@ -470,8 +470,6 @@ static bool reorderOperatorsInBasicBlockUsingDeps(SAPFOR::BasicBlock* bb, const
// as close as possible after its last dependency (if any). // as close as possible after its last dependency (if any).
const auto depsMap = analyzeBasicBlockIntraDependencies(bb); const auto depsMap = analyzeBasicBlockIntraDependencies(bb);
vector<SgStatement*> order = ops; vector<SgStatement*> order = ops;
const vector<SgStatement*> originalOrder = ops;
const int nOrig = (int)originalOrder.size();
auto indexIn = [](const vector<SgStatement*>& v, SgStatement* s) -> int auto indexIn = [](const vector<SgStatement*>& v, SgStatement* s) -> int
{ {
@@ -481,59 +479,37 @@ static bool reorderOperatorsInBasicBlockUsingDeps(SAPFOR::BasicBlock* bb, const
return -1; return -1;
}; };
auto indexInOriginal = [&](SgStatement* s) -> int
{
return indexIn(originalOrder, s);
};
for (SgStatement* s : ops) for (SgStatement* s : ops)
{ {
auto itDeps = depsMap.find(s); auto itDeps = depsMap.find(s);
if (itDeps == depsMap.end() || itDeps->second.empty()) if (itDeps == depsMap.end() || itDeps->second.empty())
continue; continue;
int lastDepOrigIdx = -1;
for (SgStatement* dep : itDeps->second)
{
const int j = indexInOriginal(dep);
if (j >= 0)
lastDepOrigIdx = max(lastDepOrigIdx, j);
}
if (lastDepOrigIdx < 0)
continue;
SgStatement* successor = nullptr;
if (lastDepOrigIdx + 1 < nOrig)
successor = originalOrder[lastDepOrigIdx + 1];
int posS = indexIn(order, s); int posS = indexIn(order, s);
if (posS < 0) if (posS < 0)
continue; continue;
if (successor == nullptr) int lastDepIdx = -1;
for (SgStatement* dep : itDeps->second)
{ {
if (posS == (int)order.size() - 1) const int j = indexIn(order, dep);
continue; if (j >= 0)
order.erase(order.begin() + posS); lastDepIdx = max(lastDepIdx, j);
order.push_back(s);
continue;
} }
if (lastDepIdx < 0)
if (successor == s)
continue; continue;
const int posSucc = indexIn(order, successor); if (posS == lastDepIdx + 1)
if (posSucc < 0)
continue;
if (posS + 1 == posSucc)
continue; continue;
order.erase(order.begin() + posS); order.erase(order.begin() + posS);
const int posSucc2 = indexIn(order, successor);
if (posSucc2 < 0) int lp = lastDepIdx;
printInternalError(convertFileName(__FILE__).c_str(), __LINE__); if (posS < lastDepIdx)
order.insert(order.begin() + posSucc2, s); lp = lastDepIdx - 1;
const int insertAt = lp + 1;
order.insert(order.begin() + insertAt, s);
} }
bool changed = false; bool changed = false;