Loading src/passes/simplifyAssumes.cpp +21 −9 Original line number Diff line number Diff line Loading @@ -131,11 +131,11 @@ class SamePathBlocks { } for (auto& [BB1, candidates] : samePathAndLoopCont) { outs() << BB1->getName() << ": "; for (auto& c : candidates) { outs() << c->getName() << ", "; } outs() << '\n'; // outs() << BB1->getName() << ": "; // for (auto& c : candidates) { // outs() << c->getName() << ", "; // } // outs() << '\n'; if (earliestOnSamePathAndLoop.find(BB1) != earliestOnSamePathAndLoop.end()) { continue; } Loading Loading @@ -385,8 +385,16 @@ private: bool canBeReplaced(Value* toBeReplaced, Value* replacedWith) { // outs() << *toBeReplaced << " " << *replacedWith << '\n'; if (auto* I1 = dyn_cast<Instruction>(toBeReplaced)) { // if (I1->getParent() != origAssume->getParent() && I1->getParent() != currentBB) { // return false; // } if (auto* I2 = dyn_cast<Instruction>(replacedWith)) { if (I1->getParent() != I2->getParent() && DT.dominates(I1, I2)) { return false; // do not want to replace older values with newer ones } if (isOnSameOrLessLoops(I2->getParent(), I1->getParent())) { return true; // the replacing value must change less often than the one being // replaced Loading Loading @@ -447,8 +455,12 @@ private: if (auto* inst = dyn_cast<Instruction>(use.getUser())) { auto* currentBB = inst->getParent(); if (assumeHasEffect(origAssume, currentBB, valToReplace)) { // outs() << "REPLACING USE " << *use << " BY " << *replaceWith << " IN " << *inst // << '\n'; if (auto* useI = dyn_cast<Instruction>(use)) { // outs() << "REPLACING USE " << *use << " DEFINED IN " << useI->getParent()->getName() // << " BY " << *replaceWith << " IN " << currentBB->getName() // << " WITH ASSUME IN " << origAssume->getParent()->getName() << '\n'; } return true; } return false; Loading Loading @@ -993,8 +1005,8 @@ void simplifyAssumesInFunction(ReversedModule& mod, Function* revFunction, Funct SimplifyAssumeVisitor simplifyAssumeVisitor(mod, revFunction, assumei1, DT, PDT, LI, samePathBlocks, VDT); // outs() << *revFunction; // simplifyAssumeVisitor.visit(revFunction); // simplifyAssumeVisitor.handle(); simplifyAssumeVisitor.visit(revFunction); simplifyAssumeVisitor.handle(); MoveUpAssumeVisitor moveUpAssumeVisitor(mod, *revFunction, DT, PDT, LI, samePathBlocks); Loading Loading
src/passes/simplifyAssumes.cpp +21 −9 Original line number Diff line number Diff line Loading @@ -131,11 +131,11 @@ class SamePathBlocks { } for (auto& [BB1, candidates] : samePathAndLoopCont) { outs() << BB1->getName() << ": "; for (auto& c : candidates) { outs() << c->getName() << ", "; } outs() << '\n'; // outs() << BB1->getName() << ": "; // for (auto& c : candidates) { // outs() << c->getName() << ", "; // } // outs() << '\n'; if (earliestOnSamePathAndLoop.find(BB1) != earliestOnSamePathAndLoop.end()) { continue; } Loading Loading @@ -385,8 +385,16 @@ private: bool canBeReplaced(Value* toBeReplaced, Value* replacedWith) { // outs() << *toBeReplaced << " " << *replacedWith << '\n'; if (auto* I1 = dyn_cast<Instruction>(toBeReplaced)) { // if (I1->getParent() != origAssume->getParent() && I1->getParent() != currentBB) { // return false; // } if (auto* I2 = dyn_cast<Instruction>(replacedWith)) { if (I1->getParent() != I2->getParent() && DT.dominates(I1, I2)) { return false; // do not want to replace older values with newer ones } if (isOnSameOrLessLoops(I2->getParent(), I1->getParent())) { return true; // the replacing value must change less often than the one being // replaced Loading Loading @@ -447,8 +455,12 @@ private: if (auto* inst = dyn_cast<Instruction>(use.getUser())) { auto* currentBB = inst->getParent(); if (assumeHasEffect(origAssume, currentBB, valToReplace)) { // outs() << "REPLACING USE " << *use << " BY " << *replaceWith << " IN " << *inst // << '\n'; if (auto* useI = dyn_cast<Instruction>(use)) { // outs() << "REPLACING USE " << *use << " DEFINED IN " << useI->getParent()->getName() // << " BY " << *replaceWith << " IN " << currentBB->getName() // << " WITH ASSUME IN " << origAssume->getParent()->getName() << '\n'; } return true; } return false; Loading Loading @@ -993,8 +1005,8 @@ void simplifyAssumesInFunction(ReversedModule& mod, Function* revFunction, Funct SimplifyAssumeVisitor simplifyAssumeVisitor(mod, revFunction, assumei1, DT, PDT, LI, samePathBlocks, VDT); // outs() << *revFunction; // simplifyAssumeVisitor.visit(revFunction); // simplifyAssumeVisitor.handle(); simplifyAssumeVisitor.visit(revFunction); simplifyAssumeVisitor.handle(); MoveUpAssumeVisitor moveUpAssumeVisitor(mod, *revFunction, DT, PDT, LI, samePathBlocks); Loading