diff options
author | 2023-01-17 17:12:30 +0000 | |
---|---|---|
committer | 2023-01-18 08:28:50 +0000 | |
commit | b2a164c5f314386a9eacb1d46b95332d77e5fbb5 (patch) | |
tree | fccdc2f0f5accaf906bc8395a821fc1e69ba88b6 /compiler/optimizing/instruction_simplifier_test.cc | |
parent | 64b0376d4b0f9ccbb044f0bd9f6c56ec44196af5 (diff) |
Clean up `InstructionSimplifierTest`.
Create a helper function for running the simplification pass
and put verbose logging behind a compile-time flag, disabled
by default.
Test: m test-art-host-gtest
Change-Id: I9405436a85cecdcfc151207ca9fcec4a98a920b7
Diffstat (limited to 'compiler/optimizing/instruction_simplifier_test.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier_test.cc | 61 |
1 files changed, 20 insertions, 41 deletions
diff --git a/compiler/optimizing/instruction_simplifier_test.cc b/compiler/optimizing/instruction_simplifier_test.cc index d3609537fd..966f5b91cf 100644 --- a/compiler/optimizing/instruction_simplifier_test.cc +++ b/compiler/optimizing/instruction_simplifier_test.cc @@ -33,6 +33,8 @@ class ClassExt; class Throwable; } // namespace mirror +static constexpr bool kDebugSimplifierTests = false; + template<typename SuperClass> class InstructionSimplifierTestBase : public SuperClass, public OptimizingUnitTestHelper { public: @@ -49,6 +51,19 @@ class InstructionSimplifierTestBase : public SuperClass, public OptimizingUnitTe SuperClass::TearDown(); gLogVerbosity.compiler = false; } + + void PerformSimplification(const AdjacencyListGraph& blks) { + if (kDebugSimplifierTests) { + LOG(INFO) << "Pre simplification " << blks; + } + graph_->ClearDominanceInformation(); + graph_->BuildDominatorTree(); + InstructionSimplifier simp(graph_, /*codegen=*/nullptr); + simp.Run(); + if (kDebugSimplifierTests) { + LOG(INFO) << "Post simplify " << blks; + } + } }; class InstructionSimplifierTest : public InstructionSimplifierTestBase<CommonCompilerTest> {}; @@ -197,13 +212,7 @@ TEST_F(InstructionSimplifierTest, SimplifyPredicatedFieldGetNoMerge) { SetupExit(exit); - LOG(INFO) << "Pre simplification " << blks; - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); - InstructionSimplifier simp(graph_, /*codegen=*/nullptr); - simp.Run(); - - LOG(INFO) << "Post simplify " << blks; + PerformSimplification(blks); EXPECT_INS_RETAINED(read_end); @@ -289,13 +298,7 @@ TEST_F(InstructionSimplifierTest, SimplifyPredicatedFieldGetMerge) { SetupExit(exit); - LOG(INFO) << "Pre simplification " << blks; - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); - InstructionSimplifier simp(graph_, /*codegen=*/nullptr); - simp.Run(); - - LOG(INFO) << "Post simplify " << blks; + PerformSimplification(blks); EXPECT_FALSE(obj3->CanBeNull()); EXPECT_INS_RETAINED(read_end); @@ -373,13 +376,7 @@ TEST_F(InstructionSimplifierTest, SimplifyPredicatedFieldGetNoNull) { SetupExit(exit); - LOG(INFO) << "Pre simplification " << blks; - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); - InstructionSimplifier simp(graph_, /*codegen=*/nullptr); - simp.Run(); - - LOG(INFO) << "Post simplify " << blks; + PerformSimplification(blks); EXPECT_FALSE(obj1->CanBeNull()); EXPECT_FALSE(obj2->CanBeNull()); @@ -464,16 +461,7 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassInstanceOfOther) { SetupExit(exit); - // PerformLSE expects this to be empty. - graph_->ClearDominanceInformation(); - - LOG(INFO) << "Pre simplification " << blks; - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); - InstructionSimplifier simp(graph_, /*codegen=*/nullptr); - simp.Run(); - - LOG(INFO) << "Post simplify " << blks; + PerformSimplification(blks); if (!GetConstantResult() || GetParam() == InstanceOfKind::kSelf) { EXPECT_INS_RETAINED(target_klass); @@ -532,16 +520,7 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassCheckCastOther) { SetupExit(exit); - // PerformLSE expects this to be empty. - graph_->ClearDominanceInformation(); - - LOG(INFO) << "Pre simplification " << blks; - graph_->ClearDominanceInformation(); - graph_->BuildDominatorTree(); - InstructionSimplifier simp(graph_, /*codegen=*/nullptr); - simp.Run(); - - LOG(INFO) << "Post simplify " << blks; + PerformSimplification(blks); if (!GetConstantResult() || GetParam() == InstanceOfKind::kSelf) { EXPECT_INS_RETAINED(target_klass); |