mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
clean() needs to process things in topological order.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37389 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c354334ac4
commit
aa7d3351f0
@ -299,37 +299,30 @@ void GVNPRE::phi_translate(GVNPRE::ValueTable& VN,
|
||||
|
||||
// Remove all expressions whose operands are not themselves in the set
|
||||
void GVNPRE::clean(GVNPRE::ValueTable VN, std::set<GVNPRE::Expression>& set) {
|
||||
unsigned size = set.size();
|
||||
unsigned old = 0;
|
||||
std::vector<Expression> worklist;
|
||||
topo_sort(VN, set, worklist);
|
||||
|
||||
while (size != old) {
|
||||
old = size;
|
||||
|
||||
std::vector<Expression> worklist(set.begin(), set.end());
|
||||
while (!worklist.empty()) {
|
||||
Expression e = worklist.back();
|
||||
worklist.pop_back();
|
||||
while (!worklist.empty()) {
|
||||
Expression e = worklist.back();
|
||||
worklist.pop_back();
|
||||
|
||||
if (e.opcode == 0) // OPAQUE
|
||||
continue;
|
||||
if (e.opcode == 0) // OPAQUE
|
||||
continue;
|
||||
|
||||
bool lhsValid = false;
|
||||
for (std::set<Expression>::iterator I = set.begin(), E = set.end();
|
||||
I != E; ++I)
|
||||
if (VN[*I] == e.lhs);
|
||||
lhsValid = true;
|
||||
bool lhsValid = false;
|
||||
for (std::set<Expression>::iterator I = set.begin(), E = set.end();
|
||||
I != E; ++I)
|
||||
if (VN[*I] == e.lhs);
|
||||
lhsValid = true;
|
||||
|
||||
bool rhsValid = false;
|
||||
for (std::set<Expression>::iterator I = set.begin(), E = set.end();
|
||||
I != E; ++I)
|
||||
if (VN[*I] == e.rhs);
|
||||
rhsValid = true;
|
||||
bool rhsValid = false;
|
||||
for (std::set<Expression>::iterator I = set.begin(), E = set.end();
|
||||
I != E; ++I)
|
||||
if (VN[*I] == e.rhs);
|
||||
rhsValid = true;
|
||||
|
||||
if (!lhsValid || !rhsValid)
|
||||
set.erase(e);
|
||||
}
|
||||
|
||||
size = set.size();
|
||||
if (!lhsValid || !rhsValid)
|
||||
set.erase(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user