| OLD | NEW |
| 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===// | 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) 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 CfgNode class, including the complexities | 10 // This file implements the CfgNode class, including the complexities |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // %bar = phi i1 [ %foo, %labelSource ], ... | 157 // %bar = phi i1 [ %foo, %labelSource ], ... |
| 158 // then we actually know the constant i1 value of the Phi operand: | 158 // then we actually know the constant i1 value of the Phi operand: |
| 159 // labelTrue: | 159 // labelTrue: |
| 160 // %bar = phi i1 [ true, %labelSource ], ... | 160 // %bar = phi i1 [ true, %labelSource ], ... |
| 161 // It seems that this optimization should be done by clang or opt, | 161 // It seems that this optimization should be done by clang or opt, |
| 162 // but we could also do it here. | 162 // but we could also do it here. |
| 163 InstList::iterator SafeInsertionPoint = InsertionPoint; | 163 InstList::iterator SafeInsertionPoint = InsertionPoint; |
| 164 // Keep track of the dest variable of a compare instruction, so that | 164 // Keep track of the dest variable of a compare instruction, so that |
| 165 // we insert the new instruction at the SafeInsertionPoint if the | 165 // we insert the new instruction at the SafeInsertionPoint if the |
| 166 // compare's dest matches the Phi-lowered assignment's source. | 166 // compare's dest matches the Phi-lowered assignment's source. |
| 167 Variable *CmpInstDest = NULL; | 167 Variable *CmpInstDest = nullptr; |
| 168 // If the current insertion point is at a conditional branch | 168 // If the current insertion point is at a conditional branch |
| 169 // instruction, and the previous instruction is a compare | 169 // instruction, and the previous instruction is a compare |
| 170 // instruction, then we move the insertion point before the compare | 170 // instruction, then we move the insertion point before the compare |
| 171 // instruction so as not to interfere with compare/branch fusing. | 171 // instruction so as not to interfere with compare/branch fusing. |
| 172 if (InstBr *Branch = llvm::dyn_cast<InstBr>(InsertionPoint)) { | 172 if (InstBr *Branch = llvm::dyn_cast<InstBr>(InsertionPoint)) { |
| 173 if (!Branch->isUnconditional()) { | 173 if (!Branch->isUnconditional()) { |
| 174 if (InsertionPoint != Insts.begin()) { | 174 if (InsertionPoint != Insts.begin()) { |
| 175 --InsertionPoint; | 175 --InsertionPoint; |
| 176 if (llvm::isa<InstIcmp>(InsertionPoint) || | 176 if (llvm::isa<InstIcmp>(InsertionPoint) || |
| 177 llvm::isa<InstFcmp>(InsertionPoint)) { | 177 llvm::isa<InstFcmp>(InsertionPoint)) { |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Performs liveness analysis on the block. Returns true if the | 549 // Performs liveness analysis on the block. Returns true if the |
| 550 // incoming liveness changed from before, false if it stayed the same. | 550 // incoming liveness changed from before, false if it stayed the same. |
| 551 // (If it changes, the node's predecessors need to be processed | 551 // (If it changes, the node's predecessors need to be processed |
| 552 // again.) | 552 // again.) |
| 553 bool CfgNode::liveness(Liveness *Liveness) { | 553 bool CfgNode::liveness(Liveness *Liveness) { |
| 554 SizeT NumVars = Liveness->getNumVarsInNode(this); | 554 SizeT NumVars = Liveness->getNumVarsInNode(this); |
| 555 LivenessBV Live(NumVars); | 555 LivenessBV Live(NumVars); |
| 556 LiveBeginEndMap *LiveBegin = NULL; | 556 LiveBeginEndMap *LiveBegin = nullptr; |
| 557 LiveBeginEndMap *LiveEnd = NULL; | 557 LiveBeginEndMap *LiveEnd = nullptr; |
| 558 // Mark the beginning and ending of each variable's live range | 558 // Mark the beginning and ending of each variable's live range |
| 559 // with the sentinel instruction number 0. | 559 // with the sentinel instruction number 0. |
| 560 if (Liveness->getMode() == Liveness_Intervals) { | 560 if (Liveness->getMode() == Liveness_Intervals) { |
| 561 LiveBegin = Liveness->getLiveBegin(this); | 561 LiveBegin = Liveness->getLiveBegin(this); |
| 562 LiveEnd = Liveness->getLiveEnd(this); | 562 LiveEnd = Liveness->getLiveEnd(this); |
| 563 LiveBegin->clear(); | 563 LiveBegin->clear(); |
| 564 LiveEnd->clear(); | 564 LiveEnd->clear(); |
| 565 // Guess that the number of live ranges beginning is roughly the | 565 // Guess that the number of live ranges beginning is roughly the |
| 566 // number of instructions, and same for live ranges ending. | 566 // number of instructions, and same for live ranges ending. |
| 567 LiveBegin->reserve(getInstCountEstimate()); | 567 LiveBegin->reserve(getInstCountEstimate()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 Var->addLiveRange(FirstInstNum, LastInstNum + 1, 1); | 716 Var->addLiveRange(FirstInstNum, LastInstNum + 1, 1); |
| 717 } | 717 } |
| 718 } | 718 } |
| 719 | 719 |
| 720 // If this node contains only deleted instructions, and ends in an | 720 // If this node contains only deleted instructions, and ends in an |
| 721 // unconditional branch, contract the node by repointing all its | 721 // unconditional branch, contract the node by repointing all its |
| 722 // in-edges to its successor. | 722 // in-edges to its successor. |
| 723 void CfgNode::contractIfEmpty() { | 723 void CfgNode::contractIfEmpty() { |
| 724 if (InEdges.empty()) | 724 if (InEdges.empty()) |
| 725 return; | 725 return; |
| 726 Inst *Branch = NULL; | 726 Inst *Branch = nullptr; |
| 727 for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I) { | 727 for (auto I = Insts.begin(), E = Insts.end(); I != E; ++I) { |
| 728 if (I->isDeleted()) | 728 if (I->isDeleted()) |
| 729 continue; | 729 continue; |
| 730 if (I->isUnconditionalBranch()) | 730 if (I->isUnconditionalBranch()) |
| 731 Branch = I; | 731 Branch = I; |
| 732 else if (!I->isRedundantAssign()) | 732 else if (!I->isRedundantAssign()) |
| 733 return; | 733 return; |
| 734 } | 734 } |
| 735 Branch->setDeleted(); | 735 Branch->setDeleted(); |
| 736 assert(OutEdges.size() == 1); | 736 assert(OutEdges.size() == 1); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 if (!First) | 989 if (!First) |
| 990 Str << ", "; | 990 Str << ", "; |
| 991 First = false; | 991 First = false; |
| 992 Str << "%" << I->getName(); | 992 Str << "%" << I->getName(); |
| 993 } | 993 } |
| 994 Str << "\n"; | 994 Str << "\n"; |
| 995 } | 995 } |
| 996 } | 996 } |
| 997 | 997 |
| 998 } // end of namespace Ice | 998 } // end of namespace Ice |
| OLD | NEW |