summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2025-01-23 14:45:35 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2025-01-24 02:34:38 -0800
commitf79077ad9e7b1e5b885466dce7f672130ee7efea (patch)
tree8d7561c808c2b04748fcd5652d8b86da745c0828 /compiler
parent1d173559d4bb675f279a9e90ede3262d2f9350c0 (diff)
Optimizing: Rename `HCodeFlowSimplifier`...
... to `HControlFlowSimplifier` because "control flow" is the correct technical term. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I2607ac699fa33c3e7ca7f54364e1e8497148412b
Diffstat (limited to 'compiler')
-rw-r--r--compiler/Android.bp4
-rw-r--r--compiler/optimizing/control_flow_simplifier.cc (renamed from compiler/optimizing/code_flow_simplifier.cc)16
-rw-r--r--compiler/optimizing/control_flow_simplifier.h (renamed from compiler/optimizing/code_flow_simplifier.h)18
-rw-r--r--compiler/optimizing/control_flow_simplifier_test.cc (renamed from compiler/optimizing/code_flow_simplifier_test.cc)28
-rw-r--r--compiler/optimizing/dead_code_elimination.cc6
-rw-r--r--compiler/optimizing/optimization.cc12
-rw-r--r--compiler/optimizing/optimization.h2
-rw-r--r--compiler/optimizing/optimizing_compiler.cc2
8 files changed, 44 insertions, 44 deletions
diff --git a/compiler/Android.bp b/compiler/Android.bp
index c904746435..67cd48ba42 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -147,13 +147,13 @@ art_cc_defaults {
"optimizing/bounds_check_elimination.cc",
"optimizing/builder.cc",
"optimizing/cha_guard_optimization.cc",
- "optimizing/code_flow_simplifier.cc",
"optimizing/code_generation_data.cc",
"optimizing/code_generator.cc",
"optimizing/code_generator_utils.cc",
"optimizing/code_sinking.cc",
"optimizing/constant_folding.cc",
"optimizing/constructor_fence_redundancy_elimination.cc",
+ "optimizing/control_flow_simplifier.cc",
"optimizing/data_type.cc",
"optimizing/dead_code_elimination.cc",
"optimizing/escape.cc",
@@ -459,8 +459,8 @@ art_cc_defaults {
"linker/output_stream_test.cc",
"oat/jni_stub_hash_map_test.cc",
"optimizing/bounds_check_elimination_test.cc",
- "optimizing/code_flow_simplifier_test.cc",
"optimizing/constant_folding_test.cc",
+ "optimizing/control_flow_simplifier_test.cc",
"optimizing/data_type_test.cc",
"optimizing/dead_code_elimination_test.cc",
"optimizing/dominator_test.cc",
diff --git a/compiler/optimizing/code_flow_simplifier.cc b/compiler/optimizing/control_flow_simplifier.cc
index 855da3e959..3e1c0ac0fc 100644
--- a/compiler/optimizing/code_flow_simplifier.cc
+++ b/compiler/optimizing/control_flow_simplifier.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "code_flow_simplifier.h"
+#include "control_flow_simplifier.h"
#include "optimizing/nodes.h"
#include "reference_type_propagation.h"
@@ -23,9 +23,9 @@ namespace art HIDDEN {
static constexpr size_t kMaxInstructionsInBranch = 1u;
-HCodeFlowSimplifier::HCodeFlowSimplifier(HGraph* graph,
- OptimizingCompilerStats* stats,
- const char* name)
+HControlFlowSimplifier::HControlFlowSimplifier(HGraph* graph,
+ OptimizingCompilerStats* stats,
+ const char* name)
: HOptimization(graph, name, stats) {
}
@@ -95,7 +95,7 @@ static std::pair<bool, HPhi*> HasAtMostOnePhiWithDifferentInputs(HBasicBlock* bl
return {true, select_phi};
}
-bool HCodeFlowSimplifier::TryGenerateSelectSimpleDiamondPattern(
+bool HControlFlowSimplifier::TryGenerateSelectSimpleDiamondPattern(
HBasicBlock* block, ScopedArenaSafeMap<HInstruction*, HSelect*>* cache) {
DCHECK(block->GetLastInstruction()->IsIf());
HIf* if_instruction = block->GetLastInstruction()->AsIf();
@@ -230,7 +230,7 @@ bool HCodeFlowSimplifier::TryGenerateSelectSimpleDiamondPattern(
return true;
}
-HBasicBlock* HCodeFlowSimplifier::TryFixupDoubleDiamondPattern(HBasicBlock* block) {
+HBasicBlock* HControlFlowSimplifier::TryFixupDoubleDiamondPattern(HBasicBlock* block) {
DCHECK(block->GetLastInstruction()->IsIf());
HIf* if_instruction = block->GetLastInstruction()->AsIf();
HBasicBlock* true_block = if_instruction->IfTrueSuccessor();
@@ -323,12 +323,12 @@ HBasicBlock* HCodeFlowSimplifier::TryFixupDoubleDiamondPattern(HBasicBlock* bloc
return inner_if_block;
}
-bool HCodeFlowSimplifier::Run() {
+bool HControlFlowSimplifier::Run() {
bool did_select = false;
// Select cache with local allocator.
ScopedArenaAllocator allocator(graph_->GetArenaStack());
ScopedArenaSafeMap<HInstruction*, HSelect*> cache(
- std::less<HInstruction*>(), allocator.Adapter(kArenaAllocCodeFlowSimplifier));
+ std::less<HInstruction*>(), allocator.Adapter(kArenaAllocControlFlowSimplifier));
// Iterate in post order in the unlikely case that removing one occurrence of
// the selection pattern empties a branch block of another occurrence.
diff --git a/compiler/optimizing/code_flow_simplifier.h b/compiler/optimizing/control_flow_simplifier.h
index 36d8d3d95b..0c74ec299f 100644
--- a/compiler/optimizing/code_flow_simplifier.h
+++ b/compiler/optimizing/control_flow_simplifier.h
@@ -54,8 +54,8 @@
* run after the instruction simplifier has removed redundant suspend checks.
*/
-#ifndef ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_
-#define ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_
+#ifndef ART_COMPILER_OPTIMIZING_CONTROL_FLOW_SIMPLIFIER_H_
+#define ART_COMPILER_OPTIMIZING_CONTROL_FLOW_SIMPLIFIER_H_
#include "base/macros.h"
#include "base/scoped_arena_containers.h"
@@ -64,15 +64,15 @@
namespace art HIDDEN {
-class HCodeFlowSimplifier : public HOptimization {
+class HControlFlowSimplifier : public HOptimization {
public:
- HCodeFlowSimplifier(HGraph* graph,
- OptimizingCompilerStats* stats,
- const char* name = kCodeFlowSimplifierPassName);
+ HControlFlowSimplifier(HGraph* graph,
+ OptimizingCompilerStats* stats,
+ const char* name = kControlFlowSimplifierPassName);
bool Run() override;
- static constexpr const char* kCodeFlowSimplifierPassName = "code_flow_simplifier";
+ static constexpr const char* kControlFlowSimplifierPassName = "control_flow_simplifier";
private:
bool TryGenerateSelectSimpleDiamondPattern(HBasicBlock* block,
@@ -112,9 +112,9 @@ class HCodeFlowSimplifier : public HOptimization {
// when that gets resolved we get another one with the outer if.
HBasicBlock* TryFixupDoubleDiamondPattern(HBasicBlock* block);
- DISALLOW_COPY_AND_ASSIGN(HCodeFlowSimplifier);
+ DISALLOW_COPY_AND_ASSIGN(HControlFlowSimplifier);
};
} // namespace art
-#endif // ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_
+#endif // ART_COMPILER_OPTIMIZING_CONTROL_FLOW_SIMPLIFIER_H_
diff --git a/compiler/optimizing/code_flow_simplifier_test.cc b/compiler/optimizing/control_flow_simplifier_test.cc
index 8945e03619..2e88c6c77b 100644
--- a/compiler/optimizing/code_flow_simplifier_test.cc
+++ b/compiler/optimizing/control_flow_simplifier_test.cc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "code_flow_simplifier.h"
+#include "control_flow_simplifier.h"
#include "base/arena_allocator.h"
#include "base/macros.h"
@@ -25,7 +25,7 @@
namespace art HIDDEN {
-class CodeFlowSimplifierTest : public OptimizingUnitTest {
+class ControlFlowSimplifierTest : public OptimizingUnitTest {
protected:
HPhi* ConstructBasicGraphForSelect(HBasicBlock* return_block, HInstruction* instr) {
HParameterValue* bool_param = MakeParam(DataType::Type::kBool);
@@ -38,18 +38,18 @@ class CodeFlowSimplifierTest : public OptimizingUnitTest {
return phi;
}
- bool CheckGraphAndTryCodeFlowSimplifier() {
+ bool CheckGraphAndTryControlFlowSimplifier() {
graph_->BuildDominatorTree();
EXPECT_TRUE(CheckGraph());
SideEffectsAnalysis side_effects(graph_);
side_effects.Run();
- return HCodeFlowSimplifier(graph_, /*handles*/ nullptr, /*stats*/ nullptr).Run();
+ return HControlFlowSimplifier(graph_, /*handles*/ nullptr, /*stats*/ nullptr).Run();
}
};
// HDivZeroCheck might throw and should not be hoisted from the conditional to an unconditional.
-TEST_F(CodeFlowSimplifierTest, testZeroCheckPreventsSelect) {
+TEST_F(ControlFlowSimplifierTest, testZeroCheckPreventsSelect) {
HBasicBlock* return_block = InitEntryMainExitGraphWithReturnVoid();
HParameterValue* param = MakeParam(DataType::Type::kInt32);
HDivZeroCheck* instr = new (GetAllocator()) HDivZeroCheck(param, 0);
@@ -57,22 +57,22 @@ TEST_F(CodeFlowSimplifierTest, testZeroCheckPreventsSelect) {
ManuallyBuildEnvFor(instr, {param, graph_->GetIntConstant(1)});
- EXPECT_FALSE(CheckGraphAndTryCodeFlowSimplifier());
+ EXPECT_FALSE(CheckGraphAndTryControlFlowSimplifier());
EXPECT_INS_RETAINED(phi);
}
-// Test that CodeFlowSimplifier succeeds with HAdd.
-TEST_F(CodeFlowSimplifierTest, testSelectWithAdd) {
+// Test that ControlFlowSimplifier succeeds with HAdd.
+TEST_F(ControlFlowSimplifierTest, testSelectWithAdd) {
HBasicBlock* return_block = InitEntryMainExitGraphWithReturnVoid();
HParameterValue* param = MakeParam(DataType::Type::kInt32);
HAdd* instr = new (GetAllocator()) HAdd(DataType::Type::kInt32, param, param, /*dex_pc=*/ 0);
HPhi* phi = ConstructBasicGraphForSelect(return_block, instr);
- EXPECT_TRUE(CheckGraphAndTryCodeFlowSimplifier());
+ EXPECT_TRUE(CheckGraphAndTryControlFlowSimplifier());
EXPECT_INS_REMOVED(phi);
}
-// Test that CodeFlowSimplifier succeeds if there is an additional `HPhi` with identical inputs.
-TEST_F(CodeFlowSimplifierTest, testSelectWithAddAndExtraPhi) {
+// Test that ControlFlowSimplifier succeeds if there is an additional `HPhi` with identical inputs.
+TEST_F(ControlFlowSimplifierTest, testSelectWithAddAndExtraPhi) {
// Create a graph with three blocks merging to the `return_block`.
HBasicBlock* return_block = InitEntryMainExitGraphWithReturnVoid();
HParameterValue* bool_param1 = MakeParam(DataType::Type::kBool);
@@ -96,7 +96,7 @@ TEST_F(CodeFlowSimplifierTest, testSelectWithAddAndExtraPhi) {
// Prevent second `HSelect` match. Do not rely on the "instructions per branch" limit.
MakeInvokeStatic(left, DataType::Type::kVoid, {}, {});
- EXPECT_TRUE(CheckGraphAndTryCodeFlowSimplifier());
+ EXPECT_TRUE(CheckGraphAndTryControlFlowSimplifier());
ASSERT_BLOCK_RETAINED(left);
ASSERT_BLOCK_REMOVED(mid);
@@ -110,7 +110,7 @@ TEST_F(CodeFlowSimplifierTest, testSelectWithAddAndExtraPhi) {
}
// Test `HSelect` optimization in an irreducible loop.
-TEST_F(CodeFlowSimplifierTest, testSelectInIrreducibleLoop) {
+TEST_F(ControlFlowSimplifierTest, testSelectInIrreducibleLoop) {
HBasicBlock* return_block = InitEntryMainExitGraphWithReturnVoid();
auto [split, left_header, right_header, body] = CreateIrreducibleLoop(return_block);
@@ -130,7 +130,7 @@ TEST_F(CodeFlowSimplifierTest, testSelectInIrreducibleLoop) {
auto [if_block, then_block, else_block] = CreateDiamondPattern(body, bool_param);
HPhi* phi = MakePhi(body, {const1, const0});
- EXPECT_TRUE(CheckGraphAndTryCodeFlowSimplifier());
+ EXPECT_TRUE(CheckGraphAndTryControlFlowSimplifier());
HLoopInformation* loop_info = left_header->GetLoopInformation();
ASSERT_TRUE(loop_info != nullptr);
ASSERT_TRUE(loop_info->IsIrreducible());
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc
index ede909526d..c5ec0b93b2 100644
--- a/compiler/optimizing/dead_code_elimination.cc
+++ b/compiler/optimizing/dead_code_elimination.cc
@@ -526,10 +526,10 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) {
// |
// 8
// `7` (which would be `block` in this example), and `6` will come from both the true path and
- // the false path of `1`. We bumped into something similar in `HCodeFlowSimplifier`. See
- // `HCodeFlowSimplifier::TryFixupDoubleDiamondPattern()`.
+ // the false path of `1`. We bumped into something similar in `HControlFlowSimplifier`. See
+ // `HControlFlowSimplifier::TryFixupDoubleDiamondPattern()`.
// TODO(solanes): Figure out if we can fix up the graph into a double diamond in a generic way
- // so that `HDeadCodeElimination` and `HCodeFlowSimplifier` can take advantage of it.
+ // so that `HDeadCodeElimination` and `HControlFlowSimplifier` can take advantage of it.
if (!same_input) {
// `1` and `7` having the opposite condition is a case we are missing. We could potentially
diff --git a/compiler/optimizing/optimization.cc b/compiler/optimizing/optimization.cc
index c876254050..31780739bc 100644
--- a/compiler/optimizing/optimization.cc
+++ b/compiler/optimizing/optimization.cc
@@ -40,10 +40,10 @@
#include "bounds_check_elimination.h"
#include "cha_guard_optimization.h"
-#include "code_flow_simplifier.h"
#include "code_sinking.h"
#include "constant_folding.h"
#include "constructor_fence_redundancy_elimination.h"
+#include "control_flow_simplifier.h"
#include "dead_code_elimination.h"
#include "dex/code_item_accessors-inl.h"
#include "driver/compiler_options.h"
@@ -88,8 +88,8 @@ const char* OptimizationPassName(OptimizationPass pass) {
return HDeadCodeElimination::kDeadCodeEliminationPassName;
case OptimizationPass::kInliner:
return HInliner::kInlinerPassName;
- case OptimizationPass::kCodeFlowSimplifier:
- return HCodeFlowSimplifier::kCodeFlowSimplifierPassName;
+ case OptimizationPass::kControlFlowSimplifier:
+ return HControlFlowSimplifier::kControlFlowSimplifierPassName;
case OptimizationPass::kAggressiveInstructionSimplifier:
case OptimizationPass::kInstructionSimplifier:
return InstructionSimplifier::kInstructionSimplifierPassName;
@@ -146,10 +146,10 @@ const char* OptimizationPassName(OptimizationPass pass) {
OptimizationPass OptimizationPassByName(const std::string& pass_name) {
X(OptimizationPass::kBoundsCheckElimination);
X(OptimizationPass::kCHAGuardOptimization);
- X(OptimizationPass::kCodeFlowSimplifier);
X(OptimizationPass::kCodeSinking);
X(OptimizationPass::kConstantFolding);
X(OptimizationPass::kConstructorFenceRedundancyElimination);
+ X(OptimizationPass::kControlFlowSimplifier);
X(OptimizationPass::kDeadCodeElimination);
X(OptimizationPass::kGlobalValueNumbering);
X(OptimizationPass::kInductionVarAnalysis);
@@ -266,8 +266,8 @@ ArenaVector<HOptimization*> ConstructOptimizations(
pass_name);
break;
}
- case OptimizationPass::kCodeFlowSimplifier:
- opt = new (allocator) HCodeFlowSimplifier(graph, stats, pass_name);
+ case OptimizationPass::kControlFlowSimplifier:
+ opt = new (allocator) HControlFlowSimplifier(graph, stats, pass_name);
break;
case OptimizationPass::kInstructionSimplifier:
opt = new (allocator) InstructionSimplifier(graph, codegen, stats, pass_name);
diff --git a/compiler/optimizing/optimization.h b/compiler/optimizing/optimization.h
index 395c45e3f7..0f0a15f7c9 100644
--- a/compiler/optimizing/optimization.h
+++ b/compiler/optimizing/optimization.h
@@ -70,10 +70,10 @@ enum class OptimizationPass {
kAggressiveInstructionSimplifier,
kBoundsCheckElimination,
kCHAGuardOptimization,
- kCodeFlowSimplifier,
kCodeSinking,
kConstantFolding,
kConstructorFenceRedundancyElimination,
+ kControlFlowSimplifier,
kDeadCodeElimination,
kGlobalValueNumbering,
kInductionVarAnalysis,
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 5067872ee4..76c201d6a9 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -666,7 +666,7 @@ void OptimizingCompiler::RunOptimizations(HGraph* graph,
"reference_type_propagation$after_gvn",
OptimizationPass::kGlobalValueNumbering),
// Simplification (TODO: only if GVN occurred).
- OptDef(OptimizationPass::kCodeFlowSimplifier),
+ OptDef(OptimizationPass::kControlFlowSimplifier),
OptDef(OptimizationPass::kConstantFolding,
"constant_folding$after_gvn"),
OptDef(OptimizationPass::kInstructionSimplifier,