From 1c2039372b49e31a2d0558d1ce4934eba9c6f221 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 7 Feb 2025 14:25:40 +0000 Subject: Optimize RemoveInstruction We can skip two ifs as they are implied from previous ifs. Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: Ia6088887832117791b82b07a2c31d2f9b8bf8b58 --- compiler/optimizing/nodes.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index ece11435db..8044a86338 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1332,17 +1332,19 @@ void HInstructionList::InsertInstructionAfter(HInstruction* instruction, HInstru } void HInstructionList::RemoveInstruction(HInstruction* instruction) { - if (instruction->previous_ != nullptr) { - instruction->previous_->next_ = instruction->next_; - } - if (instruction->next_ != nullptr) { - instruction->next_->previous_ = instruction->previous_; - } + DCHECK_EQ(instruction->previous_ == nullptr, instruction == first_instruction_); + DCHECK_EQ(instruction->next_ == nullptr, instruction == last_instruction_); + if (instruction == first_instruction_) { first_instruction_ = instruction->next_; + } else { + instruction->previous_->next_ = instruction->next_; } + if (instruction == last_instruction_) { last_instruction_ = instruction->previous_; + } else { + instruction->next_->previous_ = instruction->previous_; } } -- cgit v1.2.3-59-g8ed1b