diff options
author | 2024-01-30 14:46:54 +0000 | |
---|---|---|
committer | 2024-01-30 16:45:22 +0000 | |
commit | a7c461a767fd6cc3babc41179e0e945e6044ffd1 (patch) | |
tree | baa90b0120c7b33590388f45b43befd02e2eb98c /compiler/optimizing/constant_folding.cc | |
parent | f5307a31f5b67f6184cbb7e8b7fab61be3725fce (diff) |
Speed up HConstantFoldingVisitor::PropagateValue
We can speed it up in two ways:
1) Don't call it if it has exactly one element, as we will never
be able to replace its use in the if clause
2) Lazily compute the dominated blocks when needed
Compiling locally GMS, HConstantFoldingVisitor::VisitIf goes down
from 1.8% of the compile time to 0.7%. Most of this improvement
(90%+) is coming from the `1)` optimization. This is because there
are many cases where we have only one use (the if), which is in the
same block so we compute the domination to always end up not doing
the optimization.
Bug: 278626992
Test: Locally compile gms
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: Ic17b4b44840c7efa0224504031bf635584850ced
Diffstat (limited to 'compiler/optimizing/constant_folding.cc')
-rw-r--r-- | compiler/optimizing/constant_folding.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc index 64ef17898a..b0a65ca64d 100644 --- a/compiler/optimizing/constant_folding.cc +++ b/compiler/optimizing/constant_folding.cc @@ -229,8 +229,10 @@ void HConstantFoldingVisitor::PropagateValue(HBasicBlock* starting_block, uses_before = variable->GetUses().SizeSlow(); } - variable->ReplaceUsesDominatedBy( - starting_block->GetFirstInstruction(), constant, /* strictly_dominated= */ false); + if (!variable->GetUses().HasExactlyOneElement()) { + variable->ReplaceUsesDominatedBy( + starting_block->GetFirstInstruction(), constant, /* strictly_dominated= */ false); + } if (recording_stats) { uses_after = variable->GetUses().SizeSlow(); |