summaryrefslogtreecommitdiff
path: root/compiler/optimizing/constant_folding.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2024-01-12 18:40:49 +0000
committer Santiago Aboy Solanes <solanes@google.com> 2024-01-15 17:20:00 +0000
commitf0a31e107973f3bde7dd54cd7610082b104922db (patch)
treebca251e08f48f03d3ff127ea1a00765a66a0bc8d /compiler/optimizing/constant_folding.cc
parentde9364ce93135d021b1a26a3f2d0b611dd0d8527 (diff)
Revert "Restrict the use of ConstantFolding's VisitIf"
This reverts commit 5eb1fd0dae3832ceee2102613bb08c291daca6f3. Reason for revert: In aosp/2903248 we implemented a faster way of doing `ReplaceUsesDominatedBy` which is used by `VisitIf`. The impact of `VisitIf` is now small enough that running VisitIf in all passes is faster that the previous implementation running some of the time. This CLs re-enables the optimization in all constant folding passes because: A) Lets this optimization (and others that can use the result) kick in earlier B) Run it for callee graphs in the inliner (which has been disabled as of CL aosp/2543831) C) Consistency of the ConstantFolding pass, which helps to have a simpler mental model Bug: 278626992 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: Locally compiled GMS and compared time to compile Change-Id: I5dc5f591557c8de0bc4d23dbfd0b91b5b7e56ab5
Diffstat (limited to 'compiler/optimizing/constant_folding.cc')
-rw-r--r--compiler/optimizing/constant_folding.cc20
1 files changed, 3 insertions, 17 deletions
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc
index 66bbf548bb..64ef17898a 100644
--- a/compiler/optimizing/constant_folding.cc
+++ b/compiler/optimizing/constant_folding.cc
@@ -32,8 +32,8 @@ namespace art HIDDEN {
// as constants.
class HConstantFoldingVisitor final : public HGraphDelegateVisitor {
public:
- HConstantFoldingVisitor(HGraph* graph, OptimizingCompilerStats* stats, bool use_all_optimizations)
- : HGraphDelegateVisitor(graph, stats), use_all_optimizations_(use_all_optimizations) {}
+ explicit HConstantFoldingVisitor(HGraph* graph, OptimizingCompilerStats* stats)
+ : HGraphDelegateVisitor(graph, stats) {}
private:
void VisitBasicBlock(HBasicBlock* block) override;
@@ -66,9 +66,6 @@ class HConstantFoldingVisitor final : public HGraphDelegateVisitor {
void FoldNumberOfLeadingZerosIntrinsic(HInvoke* invoke);
void FoldNumberOfTrailingZerosIntrinsic(HInvoke* invoke);
- // Use all optimizations without restrictions.
- bool use_all_optimizations_;
-
DISALLOW_COPY_AND_ASSIGN(HConstantFoldingVisitor);
};
@@ -109,7 +106,7 @@ class InstructionWithAbsorbingInputSimplifier : public HGraphVisitor {
bool HConstantFolding::Run() {
- HConstantFoldingVisitor visitor(graph_, stats_, use_all_optimizations_);
+ HConstantFoldingVisitor visitor(graph_, stats_);
// Process basic blocks in reverse post-order in the dominator tree,
// so that an instruction turned into a constant, used as input of
// another instruction, may possibly be used to turn that second
@@ -232,11 +229,6 @@ void HConstantFoldingVisitor::PropagateValue(HBasicBlock* starting_block,
uses_before = variable->GetUses().SizeSlow();
}
- if (variable->GetUses().HasExactlyOneElement()) {
- // Nothing to do, since we only have the `if (variable)` use or the `condition` use.
- return;
- }
-
variable->ReplaceUsesDominatedBy(
starting_block->GetFirstInstruction(), constant, /* strictly_dominated= */ false);
@@ -249,12 +241,6 @@ void HConstantFoldingVisitor::PropagateValue(HBasicBlock* starting_block,
}
void HConstantFoldingVisitor::VisitIf(HIf* inst) {
- // This optimization can take a lot of compile time since we have a lot of If instructions in
- // graphs.
- if (!use_all_optimizations_) {
- return;
- }
-
// Consistency check: the true and false successors do not dominate each other.
DCHECK(!inst->IfTrueSuccessor()->Dominates(inst->IfFalseSuccessor()) &&
!inst->IfFalseSuccessor()->Dominates(inst->IfTrueSuccessor()));