diff options
Diffstat (limited to 'compiler/optimizing/nodes.cc')
| -rw-r--r-- | compiler/optimizing/nodes.cc | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index ade31380ec..ec53366e19 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -15,6 +15,7 @@ */ #include "nodes.h" + #include "ssa_builder.h" #include "utils/growable_array.h" @@ -60,19 +61,22 @@ void HGraph::RemoveInstructionsAsUsersFromDeadBlocks(const ArenaBitVector& visit } } +void HGraph::RemoveBlock(HBasicBlock* block) const { + for (size_t j = 0; j < block->GetSuccessors().Size(); ++j) { + block->GetSuccessors().Get(j)->RemovePredecessor(block); + } + for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { + block->RemovePhi(it.Current()->AsPhi()); + } + for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { + block->RemoveInstruction(it.Current()); + } +} + void HGraph::RemoveDeadBlocks(const ArenaBitVector& visited) const { for (size_t i = 0; i < blocks_.Size(); ++i) { if (!visited.IsBitSet(i)) { - HBasicBlock* block = blocks_.Get(i); - for (size_t j = 0; j < block->GetSuccessors().Size(); ++j) { - block->GetSuccessors().Get(j)->RemovePredecessor(block); - } - for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - block->RemovePhi(it.Current()->AsPhi()); - } - for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { - block->RemoveInstruction(it.Current()); - } + RemoveBlock(blocks_.Get(i)); } } } @@ -445,7 +449,7 @@ static void RemoveFromUseList(T* user, HUseListNode<T>* current = *list; while (current != nullptr) { if (current->GetUser() == user && current->GetIndex() == input_index) { - if (previous == NULL) { + if (previous == nullptr) { *list = current->GetTail(); } else { previous->SetTail(current->GetTail()); @@ -456,6 +460,22 @@ static void RemoveFromUseList(T* user, } } +HInstruction* HInstruction::GetNextDisregardingMoves() const { + HInstruction* next = GetNext(); + while (next != nullptr && next->IsParallelMove()) { + next = next->GetNext(); + } + return next; +} + +HInstruction* HInstruction::GetPreviousDisregardingMoves() const { + HInstruction* previous = GetPrevious(); + while (previous != nullptr && previous->IsParallelMove()) { + previous = previous->GetPrevious(); + } + return previous; +} + void HInstruction::RemoveUser(HInstruction* user, size_t input_index) { RemoveFromUseList(user, input_index, &uses_); } @@ -646,7 +666,7 @@ HConstant* HBinaryOperation::TryStaticEvaluation() const { if (GetResultType() == Primitive::kPrimLong) { return new(GetBlock()->GetGraph()->GetArena()) HLongConstant(value); } else { - DCHECK(GetResultType() == Primitive::kPrimInt); + DCHECK_EQ(GetResultType(), Primitive::kPrimInt); return new(GetBlock()->GetGraph()->GetArena()) HIntConstant(value); } } @@ -654,11 +674,7 @@ HConstant* HBinaryOperation::TryStaticEvaluation() const { } bool HCondition::IsBeforeWhenDisregardMoves(HIf* if_) const { - HInstruction* previous = if_->GetPrevious(); - while (previous != nullptr && previous->IsParallelMove()) { - previous = previous->GetPrevious(); - } - return previous == this; + return this == if_->GetPreviousDisregardingMoves(); } bool HInstruction::Equals(HInstruction* other) const { |