From 8c3b58afad0c347667991a8849c1b47bf25303ef Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Mon, 15 Aug 2022 13:21:59 +0000 Subject: Reland "Propagating values from if clauses to its successors" This reverts commit fa1034c563b44c4f557814c50e2678e14dcd1d13. Reason for revert: Relanding after float/double fix. In short, don't deal with floats/doubles since they bring a lot of edge cases e.g. if (f == 0.0f) { // f is not guaranteed to be 0.0f, e.g. it could be -0.0f. } Bug: 240543764 Change-Id: I400bdab71dba0934e6f1740538fe6e6c0a7bf5fc --- compiler/optimizing/nodes.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 6ac4e07ca7..4fbb033c2f 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1477,6 +1477,10 @@ bool HInstructionList::FoundBefore(const HInstruction* instruction1, UNREACHABLE(); } +bool HInstruction::Dominates(HInstruction* other_instruction) const { + return other_instruction == this || StrictlyDominates(other_instruction); +} + bool HInstruction::StrictlyDominates(HInstruction* other_instruction) const { if (other_instruction == this) { // An instruction does not strictly dominate itself. @@ -1536,14 +1540,19 @@ void HInstruction::ReplaceWith(HInstruction* other) { DCHECK(env_uses_.empty()); } -void HInstruction::ReplaceUsesDominatedBy(HInstruction* dominator, HInstruction* replacement) { +void HInstruction::ReplaceUsesDominatedBy(HInstruction* dominator, + HInstruction* replacement, + bool strictly_dominated) { const HUseList& uses = GetUses(); for (auto it = uses.begin(), end = uses.end(); it != end; /* ++it below */) { HInstruction* user = it->GetUser(); size_t index = it->GetIndex(); // Increment `it` now because `*it` may disappear thanks to user->ReplaceInput(). ++it; - if (dominator->StrictlyDominates(user)) { + const bool dominated = + strictly_dominated ? dominator->StrictlyDominates(user) : dominator->Dominates(user); + + if (dominated) { user->ReplaceInput(replacement, index); } else if (user->IsPhi() && !user->AsPhi()->IsCatchPhi()) { // If the input flows from a block dominated by `dominator`, we can replace it. -- cgit v1.2.3-59-g8ed1b