From c08fb725b561ead05dc120f2e92ea5228d14eec0 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 15 Aug 2024 07:40:38 +0000 Subject: Change `MakeCondition()` to take `IfCondition`... ... instead of the instruction type argument. And continue with loop construction cleanup in gtests. Test: m test-art-host-gtest Change-Id: I8cb83ae0c6d3cdb2a2ee4da0608cfeb69df722eb --- compiler/optimizing/codegen_test.cc | 48 +++++++++---------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) (limited to 'compiler/optimizing/codegen_test.cc') diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index e3366760ca..7365f0fb7f 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -424,7 +424,7 @@ TEST_F(CodegenTest, NonMaterializedCondition) { entry->AddSuccessor(first_block); HIntConstant* constant0 = graph->GetIntConstant(0); HIntConstant* constant1 = graph->GetIntConstant(1); - HEqual* equal = MakeCondition(first_block, constant0, constant0); + HInstruction* equal = MakeCondition(first_block, kCondEQ, constant0, constant0); MakeIf(first_block, equal); HBasicBlock* then_block = new (GetAllocator()) HBasicBlock(graph); @@ -491,7 +491,7 @@ TEST_F(CodegenTest, MaterializedCondition1) { HIntConstant* cst_lhs = graph->GetIntConstant(lhs[i]); HIntConstant* cst_rhs = graph->GetIntConstant(rhs[i]); - HInstruction* cmp_lt = MakeCondition(code_block, cst_lhs, cst_rhs); + HInstruction* cmp_lt = MakeCondition(code_block, kCondLT, cst_lhs, cst_rhs); MakeReturn(code_block, cmp_lt); graph->BuildDominatorTree(); @@ -547,7 +547,7 @@ TEST_F(CodegenTest, MaterializedCondition2) { HIntConstant* cst_lhs = graph->GetIntConstant(lhs[i]); HIntConstant* cst_rhs = graph->GetIntConstant(rhs[i]); - HInstruction* cmp_lt = MakeCondition(if_block, cst_lhs, cst_rhs); + HInstruction* cmp_lt = MakeCondition(if_block, kCondLT, cst_lhs, cst_rhs); // We insert a fake instruction to separate the HIf from the HLessThan // and force the materialization of the condition. HInstruction* force_materialization = @@ -599,87 +599,61 @@ void CodegenTest::TestComparison(IfCondition condition, int64_t j, DataType::Type type, const CodegenTargetConfig target_config) { - HGraph* graph = CreateGraph(); - - HBasicBlock* entry_block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(entry_block); - graph->SetEntryBlock(entry_block); - MakeGoto(entry_block); - - HBasicBlock* block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(block); - - HBasicBlock* exit_block = new (GetAllocator()) HBasicBlock(graph); - graph->AddBlock(exit_block); - graph->SetExitBlock(exit_block); - MakeExit(exit_block); - - entry_block->AddSuccessor(block); - block->AddSuccessor(exit_block); + HBasicBlock* block = InitEntryMainExitGraph(); HInstruction* op1; HInstruction* op2; if (type == DataType::Type::kInt32) { - op1 = graph->GetIntConstant(i); - op2 = graph->GetIntConstant(j); + op1 = graph_->GetIntConstant(i); + op2 = graph_->GetIntConstant(j); } else { DCHECK_EQ(type, DataType::Type::kInt64); - op1 = graph->GetLongConstant(i); - op2 = graph->GetLongConstant(j); + op1 = graph_->GetLongConstant(i); + op2 = graph_->GetLongConstant(j); } - HInstruction* comparison = nullptr; bool expected_result = false; const uint64_t x = i; const uint64_t y = j; switch (condition) { case kCondEQ: - comparison = MakeCondition(block, op1, op2); expected_result = (i == j); break; case kCondNE: - comparison = MakeCondition(block, op1, op2); expected_result = (i != j); break; case kCondLT: - comparison = MakeCondition(block, op1, op2); expected_result = (i < j); break; case kCondLE: - comparison = MakeCondition(block, op1, op2); expected_result = (i <= j); break; case kCondGT: - comparison = MakeCondition(block, op1, op2); expected_result = (i > j); break; case kCondGE: - comparison = MakeCondition(block, op1, op2); expected_result = (i >= j); break; case kCondB: - comparison = MakeCondition(block, op1, op2); expected_result = (x < y); break; case kCondBE: - comparison = MakeCondition(block, op1, op2); expected_result = (x <= y); break; case kCondA: - comparison = MakeCondition(block, op1, op2); expected_result = (x > y); break; case kCondAE: - comparison = MakeCondition(block, op1, op2); expected_result = (x >= y); break; } + HInstruction* comparison = MakeCondition(block, condition, op1, op2); MakeReturn(block, comparison); - graph->BuildDominatorTree(); + graph_->BuildDominatorTree(); std::unique_ptr compiler_options = CommonCompilerTest::CreateCompilerOptions(target_config.GetInstructionSet(), "default"); - RunCode(target_config, *compiler_options, graph, [](HGraph*) {}, true, expected_result); + RunCode(target_config, *compiler_options, graph_, [](HGraph*) {}, true, expected_result); } TEST_F(CodegenTest, ComparisonsInt) { -- cgit v1.2.3-59-g8ed1b