summaryrefslogtreecommitdiff
path: root/compiler/optimizing/constant_folding_test.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2023-04-25 16:40:06 +0000
committer Vladimir Marko <vmarko@google.com> 2023-04-27 10:53:55 +0000
commitcde6497d286337de2ed21c71c85157e2745b742b (patch)
tree087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/constant_folding_test.cc
parent79dc217688a774fc532584f6551a0aec8b45bc4a (diff)
Optimizing: Add `HInstruction::As##type()`.
After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e
Diffstat (limited to 'compiler/optimizing/constant_folding_test.cc')
-rw-r--r--compiler/optimizing/constant_folding_test.cc42
1 files changed, 14 insertions, 28 deletions
diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc
index 4573dce4aa..741fd3f822 100644
--- a/compiler/optimizing/constant_folding_test.cc
+++ b/compiler/optimizing/constant_folding_test.cc
@@ -128,8 +128,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingNegation) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), -1);
+ ASSERT_EQ(inst->AsIntConstant()->GetValue(), -1);
};
// Expected difference after dead code elimination.
@@ -190,8 +189,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingNegation) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), INT64_C(-4294967296));
+ ASSERT_EQ(inst->AsLongConstant()->GetValue(), INT64_C(-4294967296));
};
// Expected difference after dead code elimination.
@@ -252,8 +250,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition1) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 3);
+ ASSERT_EQ(inst->AsIntConstant()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -332,16 +329,13 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition2) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst1 = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst1->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 12);
+ ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 12);
HInstruction* inst2 = inst1->GetPrevious();
ASSERT_TRUE(inst2->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 9);
+ ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 9);
HInstruction* inst3 = inst2->GetPrevious();
ASSERT_TRUE(inst3->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 3);
+ ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -406,8 +400,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnSubtraction) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 1);
+ ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1);
};
// Expected difference after dead code elimination.
@@ -470,8 +463,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnAddition) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 3);
+ ASSERT_EQ(inst->AsLongConstant()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -535,8 +527,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnSubtraction) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 1);
+ ASSERT_EQ(inst->AsLongConstant()->GetValue(), 1);
};
// Expected difference after dead code elimination.
@@ -636,20 +627,16 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingAndJumps) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst1 = graph->GetBlocks()[4]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst1->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 20);
+ ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 20);
HInstruction* inst2 = inst1->GetPrevious();
ASSERT_TRUE(inst2->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 12);
+ ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 12);
HInstruction* inst3 = inst2->GetPrevious();
ASSERT_TRUE(inst3->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 7);
+ ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 7);
HInstruction* inst4 = inst3->GetPrevious();
ASSERT_TRUE(inst4->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst4->AsIntConstantOrNull()->GetValue(), 3);
+ ASSERT_EQ(inst4->AsIntConstant()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -725,8 +712,7 @@ TEST_F(ConstantFoldingTest, ConstantCondition) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- // TODO: Remove "OrNull".
- ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 1);
+ ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1);
};
// Expected graph after dead code elimination.