Chromium Code Reviews| Index: src/IceCfg.cpp |
| diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
| index 23c363fa7791938a5a05a0edfc6adaf72167f48b..c20b9fc303dcdca399d24cdd2a6687a7f4622912 100644 |
| --- a/src/IceCfg.cpp |
| +++ b/src/IceCfg.cpp |
| @@ -572,7 +572,7 @@ void Cfg::localCSE() { |
| return true; |
| } |
| }; |
| - |
| + bool NoSSA = getFlags().getLocalCSENoSSA(); |
|
John
2016/07/28 14:21:50
const bool
manasijm
2016/07/28 19:43:34
Done.
|
| for (CfgNode *Node : getNodes()) { |
| CfgUnorderedSet<Inst *, InstHash, InstEq> Seen; |
| @@ -581,8 +581,7 @@ void Cfg::localCSE() { |
| // memory but will be slower i.e map of Instruction -> Set of Variables |
| CfgUnorderedMap<Variable *, std::vector<Inst *>, VariableHash> Dependency; |
| - // Not necessary for SSA, still keeping it in case this pass is not run at |
| - // the beginning. Remove to improve performace. |
| + // Not necessary for SSA |
| int IterCount = getFlags().getLocalCseMaxIterations(); |
| @@ -591,25 +590,24 @@ void Cfg::localCSE() { |
| for (Inst &Instr : Node->getInsts()) { |
| if (Instr.isDeleted() || !llvm::isa<InstArithmetic>(&Instr)) |
| continue; |
| + if (NoSSA) { |
|
John
2016/07/28 14:21:50
document what's going on here. why is this needed
manasijm
2016/07/28 15:24:44
This is needed if this pass is moved to a point la
manasijm
2016/07/28 19:43:33
Done.
|
| + // Invalidate replacements |
| + auto Iter = Replacements.find(Instr.getDest()); |
| + if (Iter != Replacements.end()) { |
| + Replacements.erase(Iter); |
| + } |
| - // Invalidate replacements |
| - auto Iter = Replacements.find(Instr.getDest()); |
| - if (Iter != Replacements.end()) { |
| - Replacements.erase(Iter); |
| - } |
| - |
| - // Invalidate 'seen' instructions whose operands were just updated. |
| - auto DepIter = Dependency.find(Instr.getDest()); |
| - if (DepIter != Dependency.end()) { |
| - for (auto DepInst : DepIter->second) { |
| - Seen.erase(DepInst); |
| + // Invalidate 'seen' instructions whose operands were just updated. |
| + auto DepIter = Dependency.find(Instr.getDest()); |
| + if (DepIter != Dependency.end()) { |
| + for (auto DepInst : DepIter->second) { |
|
John
2016/07/28 14:21:50
auto *
manasijm
2016/07/28 19:43:34
Done.
|
| + Seen.erase(DepInst); |
| + } |
| } |
| } |
| - // The above two can be removed if SSA is assumed. |
| // Replace - doing this before checking for repetitions might enable |
| - // more |
| - // optimizations |
| + // more optimizations |
| for (SizeT i = 0; i < Instr.getSrcSize(); ++i) { |
| auto *Opnd = Instr.getSrc(i); |
| if (auto *Var = llvm::dyn_cast<Variable>(Opnd)) { |
| @@ -627,11 +625,13 @@ void Cfg::localCSE() { |
| } else { // new |
| Seen.insert(&Instr); |
| - // Update dependencies |
| - for (SizeT i = 0; i < Instr.getSrcSize(); ++i) { |
| - auto *Opnd = Instr.getSrc(i); |
| - if (auto *Var = llvm::dyn_cast<Variable>(Opnd)) { |
| - Dependency[Var].push_back(&Instr); |
| + if (NoSSA) { |
| + // Update dependencies |
| + for (SizeT i = 0; i < Instr.getSrcSize(); ++i) { |
| + auto *Opnd = Instr.getSrc(i); |
| + if (auto *Var = llvm::dyn_cast<Variable>(Opnd)) { |
| + Dependency[Var].push_back(&Instr); |
| + } |
| } |
| } |
| } |