diff options
author | 2018-08-05 12:05:01 +0100 | |
---|---|---|
committer | 2018-08-06 13:09:41 +0100 | |
commit | 1c8605e7e2f9a42ec0569ed60e02256b4ae356de (patch) | |
tree | 96b932eba5e5c8d382589b776854925012ff7b8e /compiler/optimizing/nodes.cc | |
parent | 8031b3e8a35c49a1ad7dcd8a0779aec430f28414 (diff) |
Look at phis in ReplaceUsesDominatedBy.
When the instruction does not dominate the phi, but the instruction
that it is replacing does by being an input, do the replacement.
It was a missed improvement opportunity before, but the String.<init>
handling in the builder needs it for correctness.
bug: 111758226
Test: 563-checker-fakestring
Change-Id: I37f01e1aabc2a1f60e21fc57728f07248adbc946
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r-- | compiler/optimizing/nodes.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 8f822cce5a..79a7e2c858 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1301,6 +1301,15 @@ void HInstruction::ReplaceUsesDominatedBy(HInstruction* dominator, HInstruction* ++it; if (dominator->StrictlyDominates(user)) { 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. + // We do not perform this for catch phis as we don't have control flow support + // for their inputs. + const ArenaVector<HBasicBlock*>& predecessors = user->GetBlock()->GetPredecessors(); + HBasicBlock* predecessor = predecessors[index]; + if (dominator->GetBlock()->Dominates(predecessor)) { + user->ReplaceInput(replacement, index); + } } } } |