OLD | NEW |
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// | 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the Cfg class, including constant pool | 10 // This file implements the Cfg class, including constant pool |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 Var->dump(this); | 277 Var->dump(this); |
278 Str << " live range " << Var->getLiveRange() << "\n"; | 278 Str << " live range " << Var->getLiveRange() << "\n"; |
279 } | 279 } |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 return Valid; | 284 return Valid; |
285 } | 285 } |
286 | 286 |
| 287 // Deletes redundant assignments like "var=var". This includes |
| 288 // architecturally redundant moves like "var1:eax=var2:eax". As such, |
| 289 // this needs to be done very late in the translation to avoid |
| 290 // liveness inconsistencies. |
| 291 void Cfg::deleteRedundantAssignments() { |
| 292 for (CfgNode *Node : Nodes) { |
| 293 // Ignore Phi instructions. |
| 294 for (Inst *I : Node->getInsts()) |
| 295 if (I->isRedundantAssign()) |
| 296 I->setDeleted(); |
| 297 } |
| 298 } |
| 299 |
287 void Cfg::doBranchOpt() { | 300 void Cfg::doBranchOpt() { |
288 TimerMarker T(TimerStack::TT_doBranchOpt, this); | 301 TimerMarker T(TimerStack::TT_doBranchOpt, this); |
289 for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { | 302 for (auto I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { |
290 auto NextNode = I; | 303 auto NextNode = I; |
291 ++NextNode; | 304 ++NextNode; |
292 (*I)->doBranchOpt(NextNode == E ? NULL : *NextNode); | 305 (*I)->doBranchOpt(NextNode == E ? NULL : *NextNode); |
293 } | 306 } |
294 } | 307 } |
295 | 308 |
296 // ======================== Dump routines ======================== // | 309 // ======================== Dump routines ======================== // |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 376 } |
364 } | 377 } |
365 // Print each basic block | 378 // Print each basic block |
366 for (CfgNode *Node : Nodes) | 379 for (CfgNode *Node : Nodes) |
367 Node->dump(this); | 380 Node->dump(this); |
368 if (getContext()->isVerbose(IceV_Instructions)) | 381 if (getContext()->isVerbose(IceV_Instructions)) |
369 Str << "}\n"; | 382 Str << "}\n"; |
370 } | 383 } |
371 | 384 |
372 } // end of namespace Ice | 385 } // end of namespace Ice |
OLD | NEW |