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 From 6c2ef6e2a6c8f750601c8436d80d5911204fc98d Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 7 Feb 2025 15:01:53 +0000 Subject: cleanup: Remove never executed break Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: I469be66bc4f5efa9a70c5d86b9c04627cc9c5672 --- compiler/optimizing/code_generator.h | 1 - 1 file changed, 1 deletion(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 3919bb0cc1..b118e9a7d0 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -703,7 +703,6 @@ class CodeGenerator : public DeletableArenaObject { return EmitReadBarrier() ? LocationSummary::kCallOnSlowPath : LocationSummary::kNoCall; - break; default: DCHECK(!load->NeedsEnvironment()); return LocationSummary::kNoCall; -- cgit v1.2.3-59-g8ed1b From 78dbd5c6ee09cd459d9eb8c86845b59c271866e7 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 7 Feb 2025 16:41:06 -0800 Subject: SafeMul: avoid UB on signed overflow Bug: http://b/395138850 Test: atest art-run-test-530-checker-loops4 Change-Id: Id7fb236cc4cbc7982de1a8e79f94814f9daf2bd1 --- compiler/optimizing/induction_var_range.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc index 2f5a22ec0e..1fa2724641 100644 --- a/compiler/optimizing/induction_var_range.cc +++ b/compiler/optimizing/induction_var_range.cc @@ -48,10 +48,11 @@ static bool IsSafeDiv(int32_t c1, int32_t c2) { /** Computes a * b for a,b > 0 (at least until first overflow happens). */ static int64_t SafeMul(int64_t a, int64_t b, /*out*/ bool* overflow) { - if (a > 0 && b > 0 && a > (std::numeric_limits::max() / b)) { + int64_t result; + if (__builtin_mul_overflow(a, b, &result)) { *overflow = true; } - return a * b; + return result; } /** Returns b^e for b,e > 0. Sets overflow if arithmetic wrap-around occurred. */ -- cgit v1.2.3-59-g8ed1b