diff options
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/code_flow_simplifier.cc (renamed from compiler/optimizing/select_generator.cc) | 18 | ||||
| -rw-r--r-- | compiler/optimizing/code_flow_simplifier.h (renamed from compiler/optimizing/select_generator.h) | 18 | ||||
| -rw-r--r-- | compiler/optimizing/code_flow_simplifier_test.cc (renamed from compiler/optimizing/select_generator_test.cc) | 18 | ||||
| -rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 6 | ||||
| -rw-r--r-- | compiler/optimizing/optimization.cc | 12 | ||||
| -rw-r--r-- | compiler/optimizing/optimization.h | 2 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 4 |
7 files changed, 38 insertions, 40 deletions
diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/code_flow_simplifier.cc index d5781c8d38..b32a4a5c4c 100644 --- a/compiler/optimizing/select_generator.cc +++ b/compiler/optimizing/code_flow_simplifier.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "select_generator.h" +#include "code_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; -HSelectGenerator::HSelectGenerator(HGraph* graph, - OptimizingCompilerStats* stats, - const char* name) +HCodeFlowSimplifier::HCodeFlowSimplifier(HGraph* graph, + OptimizingCompilerStats* stats, + const char* name) : HOptimization(graph, name, stats) { } @@ -87,7 +87,7 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) { return select_phi; } -bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( +bool HCodeFlowSimplifier::TryGenerateSelectSimpleDiamondPattern( HBasicBlock* block, ScopedArenaSafeMap<HInstruction*, HSelect*>* cache) { DCHECK(block->GetLastInstruction()->IsIf()); HIf* if_instruction = block->GetLastInstruction()->AsIf(); @@ -214,7 +214,7 @@ bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( return true; } -HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) { +HBasicBlock* HCodeFlowSimplifier::TryFixupDoubleDiamondPattern(HBasicBlock* block) { DCHECK(block->GetLastInstruction()->IsIf()); HIf* if_instruction = block->GetLastInstruction()->AsIf(); HBasicBlock* true_block = if_instruction->IfTrueSuccessor(); @@ -307,12 +307,12 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) return inner_if_block; } -bool HSelectGenerator::Run() { +bool HCodeFlowSimplifier::Run() { bool did_select = false; // Select cache with local allocator. ScopedArenaAllocator allocator(graph_->GetArenaStack()); - ScopedArenaSafeMap<HInstruction*, HSelect*> cache(std::less<HInstruction*>(), - allocator.Adapter(kArenaAllocSelectGenerator)); + ScopedArenaSafeMap<HInstruction*, HSelect*> cache( + std::less<HInstruction*>(), allocator.Adapter(kArenaAllocCodeFlowSimplifier)); // 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/select_generator.h b/compiler/optimizing/code_flow_simplifier.h index 7aa0803d89..36d8d3d95b 100644 --- a/compiler/optimizing/select_generator.h +++ b/compiler/optimizing/code_flow_simplifier.h @@ -54,8 +54,8 @@ * run after the instruction simplifier has removed redundant suspend checks. */ -#ifndef ART_COMPILER_OPTIMIZING_SELECT_GENERATOR_H_ -#define ART_COMPILER_OPTIMIZING_SELECT_GENERATOR_H_ +#ifndef ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_ +#define ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_ #include "base/macros.h" #include "base/scoped_arena_containers.h" @@ -64,15 +64,15 @@ namespace art HIDDEN { -class HSelectGenerator : public HOptimization { +class HCodeFlowSimplifier : public HOptimization { public: - HSelectGenerator(HGraph* graph, - OptimizingCompilerStats* stats, - const char* name = kSelectGeneratorPassName); + HCodeFlowSimplifier(HGraph* graph, + OptimizingCompilerStats* stats, + const char* name = kCodeFlowSimplifierPassName); bool Run() override; - static constexpr const char* kSelectGeneratorPassName = "select_generator"; + static constexpr const char* kCodeFlowSimplifierPassName = "code_flow_simplifier"; private: bool TryGenerateSelectSimpleDiamondPattern(HBasicBlock* block, @@ -112,9 +112,9 @@ class HSelectGenerator : public HOptimization { // when that gets resolved we get another one with the outer if. HBasicBlock* TryFixupDoubleDiamondPattern(HBasicBlock* block); - DISALLOW_COPY_AND_ASSIGN(HSelectGenerator); + DISALLOW_COPY_AND_ASSIGN(HCodeFlowSimplifier); }; } // namespace art -#endif // ART_COMPILER_OPTIMIZING_SELECT_GENERATOR_H_ +#endif // ART_COMPILER_OPTIMIZING_CODE_FLOW_SIMPLIFIER_H_ diff --git a/compiler/optimizing/select_generator_test.cc b/compiler/optimizing/code_flow_simplifier_test.cc index 9cd6604d34..dc4268a0aa 100644 --- a/compiler/optimizing/select_generator_test.cc +++ b/compiler/optimizing/code_flow_simplifier_test.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "select_generator.h" +#include "code_flow_simplifier.h" #include "base/arena_allocator.h" #include "base/macros.h" @@ -25,7 +25,7 @@ namespace art HIDDEN { -class SelectGeneratorTest : public OptimizingUnitTest { +class CodeFlowSimplifierTest : public OptimizingUnitTest { protected: HPhi* ConstructBasicGraphForSelect(HBasicBlock* return_block, HInstruction* instr) { HParameterValue* bool_param = MakeParam(DataType::Type::kBool); @@ -38,18 +38,18 @@ class SelectGeneratorTest : public OptimizingUnitTest { return phi; } - bool CheckGraphAndTrySelectGenerator() { + bool CheckGraphAndTryCodeFlowSimplifier() { graph_->BuildDominatorTree(); EXPECT_TRUE(CheckGraph()); SideEffectsAnalysis side_effects(graph_); side_effects.Run(); - return HSelectGenerator(graph_, /*handles*/ nullptr, /*stats*/ nullptr).Run(); + return HCodeFlowSimplifier(graph_, /*handles*/ nullptr, /*stats*/ nullptr).Run(); } }; // HDivZeroCheck might throw and should not be hoisted from the conditional to an unconditional. -TEST_F(SelectGeneratorTest, testZeroCheck) { +TEST_F(CodeFlowSimplifierTest, testZeroCheckPreventsSelect) { HBasicBlock* return_block = InitEntryMainExitGraphWithReturnVoid(); HParameterValue* param = MakeParam(DataType::Type::kInt32); HDivZeroCheck* instr = new (GetAllocator()) HDivZeroCheck(param, 0); @@ -57,17 +57,17 @@ TEST_F(SelectGeneratorTest, testZeroCheck) { ManuallyBuildEnvFor(instr, {param, graph_->GetIntConstant(1)}); - EXPECT_FALSE(CheckGraphAndTrySelectGenerator()); + EXPECT_FALSE(CheckGraphAndTryCodeFlowSimplifier()); EXPECT_FALSE(phi->GetBlock() == nullptr); } -// Test that SelectGenerator succeeds with HAdd. -TEST_F(SelectGeneratorTest, testAdd) { +// Test that CodeFlowSimplifier succeeds with HAdd. +TEST_F(CodeFlowSimplifierTest, 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(CheckGraphAndTrySelectGenerator()); + EXPECT_TRUE(CheckGraphAndTryCodeFlowSimplifier()); EXPECT_TRUE(phi->GetBlock() == nullptr); } diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index f44f4b577b..ede909526d 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 SelectGenerator. See - // HSelectGenerator::TryFixupDoubleDiamondPattern. + // the false path of `1`. We bumped into something similar in `HCodeFlowSimplifier`. See + // `HCodeFlowSimplifier::TryFixupDoubleDiamondPattern()`. // TODO(solanes): Figure out if we can fix up the graph into a double diamond in a generic way - // so that DeadCodeElimination and SelectGenerator can take advantage of it. + // so that `HDeadCodeElimination` and `HCodeFlowSimplifier` 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 bd8fbdf1d2..c876254050 100644 --- a/compiler/optimizing/optimization.cc +++ b/compiler/optimizing/optimization.cc @@ -40,6 +40,7 @@ #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" @@ -57,7 +58,6 @@ #include "loop_optimization.h" #include "reference_type_propagation.h" #include "scheduler.h" -#include "select_generator.h" #include "sharpening.h" #include "side_effects_analysis.h" #include "write_barrier_elimination.h" @@ -88,8 +88,8 @@ const char* OptimizationPassName(OptimizationPass pass) { return HDeadCodeElimination::kDeadCodeEliminationPassName; case OptimizationPass::kInliner: return HInliner::kInlinerPassName; - case OptimizationPass::kSelectGenerator: - return HSelectGenerator::kSelectGeneratorPassName; + case OptimizationPass::kCodeFlowSimplifier: + return HCodeFlowSimplifier::kCodeFlowSimplifierPassName; case OptimizationPass::kAggressiveInstructionSimplifier: case OptimizationPass::kInstructionSimplifier: return InstructionSimplifier::kInstructionSimplifierPassName; @@ -146,6 +146,7 @@ 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); @@ -159,7 +160,6 @@ OptimizationPass OptimizationPassByName(const std::string& pass_name) { X(OptimizationPass::kLoopOptimization); X(OptimizationPass::kReferenceTypePropagation); X(OptimizationPass::kScheduling); - X(OptimizationPass::kSelectGenerator); X(OptimizationPass::kSideEffectsAnalysis); #ifdef ART_ENABLE_CODEGEN_arm X(OptimizationPass::kInstructionSimplifierArm); @@ -266,8 +266,8 @@ ArenaVector<HOptimization*> ConstructOptimizations( pass_name); break; } - case OptimizationPass::kSelectGenerator: - opt = new (allocator) HSelectGenerator(graph, stats, pass_name); + case OptimizationPass::kCodeFlowSimplifier: + opt = new (allocator) HCodeFlowSimplifier(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 abc4361b44..395c45e3f7 100644 --- a/compiler/optimizing/optimization.h +++ b/compiler/optimizing/optimization.h @@ -70,6 +70,7 @@ enum class OptimizationPass { kAggressiveInstructionSimplifier, kBoundsCheckElimination, kCHAGuardOptimization, + kCodeFlowSimplifier, kCodeSinking, kConstantFolding, kConstructorFenceRedundancyElimination, @@ -83,7 +84,6 @@ enum class OptimizationPass { kLoopOptimization, kReferenceTypePropagation, kScheduling, - kSelectGenerator, kSideEffectsAnalysis, kWriteBarrierElimination, #ifdef ART_ENABLE_CODEGEN_arm diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index cb9933c9c0..5067872ee4 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -57,10 +57,8 @@ #include "profiling_info_builder.h" #include "reference_type_propagation.h" #include "register_allocator_linear_scan.h" -#include "select_generator.h" #include "ssa_builder.h" #include "ssa_liveness_analysis.h" -#include "ssa_phi_elimination.h" #include "stack_map_stream.h" #include "utils/assembler.h" @@ -668,7 +666,7 @@ void OptimizingCompiler::RunOptimizations(HGraph* graph, "reference_type_propagation$after_gvn", OptimizationPass::kGlobalValueNumbering), // Simplification (TODO: only if GVN occurred). - OptDef(OptimizationPass::kSelectGenerator), + OptDef(OptimizationPass::kCodeFlowSimplifier), OptDef(OptimizationPass::kConstantFolding, "constant_folding$after_gvn"), OptDef(OptimizationPass::kInstructionSimplifier, |