summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/ssa_test.cc
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-06-06 11:24:33 +0100
committerNicolas Geoffray <ngeoffray@google.com>2014-06-09 08:59:02 +0100
commitec7e4727e99aa1416398ac5a684f5024817a25c7 (patch)
tree3ad51887c890b5cbebf1ae8e4afec8d93b485168 /compiler/optimizing/ssa_test.cc
parent7a6b77f9a694ea4569fbf44493fdcaeea237a8be (diff)
downloadart-ec7e4727e99aa1416398ac5a684f5024817a25c7.zip
art-ec7e4727e99aa1416398ac5a684f5024817a25c7.tar.gz
art-ec7e4727e99aa1416398ac5a684f5024817a25c7.tar.bz2
Fix some bugs in graph construction/simplification methods.
Also fix a brano during SSA construction. The code should not have been commented out. Added a test to cover what the code intends. Change-Id: Ia00ae79dcf75eb0d412f07649d73e7f94dbfb6f0
Diffstat (limited to 'compiler/optimizing/ssa_test.cc')
-rw-r--r--compiler/optimizing/ssa_test.cc47
1 files changed, 43 insertions, 4 deletions
diff --git a/compiler/optimizing/ssa_test.cc b/compiler/optimizing/ssa_test.cc
index 485ea27..3b354f1 100644
--- a/compiler/optimizing/ssa_test.cc
+++ b/compiler/optimizing/ssa_test.cc
@@ -99,7 +99,7 @@ TEST(SsaTest, CFG1) {
"BasicBlock 0, succ: 1\n"
" 0: IntConstant 0 [2, 2]\n"
" 1: Goto\n"
- "BasicBlock 1, pred: 0, succ: 2, 5\n"
+ "BasicBlock 1, pred: 0, succ: 5, 2\n"
" 2: Equal(0, 0) [3]\n"
" 3: If(2)\n"
"BasicBlock 2, pred: 1, succ: 3\n"
@@ -129,7 +129,7 @@ TEST(SsaTest, CFG2) {
" 0: IntConstant 0 [6, 3, 3]\n"
" 1: IntConstant 4 [6]\n"
" 2: Goto\n"
- "BasicBlock 1, pred: 0, succ: 2, 5\n"
+ "BasicBlock 1, pred: 0, succ: 5, 2\n"
" 3: Equal(0, 0) [4]\n"
" 4: If(3)\n"
"BasicBlock 2, pred: 1, succ: 3\n"
@@ -409,7 +409,7 @@ TEST(SsaTest, Loop7) {
" 3: Goto\n"
"BasicBlock 1, pred: 0, succ: 2\n"
" 4: Goto\n"
- "BasicBlock 2, pred: 1, 5, succ: 3, 8\n"
+ "BasicBlock 2, pred: 1, 5, succ: 8, 3\n"
" 5: Phi(0, 1) [12, 6, 6]\n"
" 6: Equal(5, 5) [7]\n"
" 7: If(6)\n"
@@ -467,7 +467,7 @@ TEST(SsaTest, LocalInIf) {
" 0: IntConstant 0 [3, 3]\n"
" 1: IntConstant 4\n"
" 2: Goto\n"
- "BasicBlock 1, pred: 0, succ: 2, 5\n"
+ "BasicBlock 1, pred: 0, succ: 5, 2\n"
" 3: Equal(0, 0) [4]\n"
" 4: If(3)\n"
"BasicBlock 2, pred: 1, succ: 3\n"
@@ -489,4 +489,43 @@ TEST(SsaTest, LocalInIf) {
TestCode(data, expected);
}
+TEST(SsaTest, MultiplePredecessors) {
+ // Test that we do not create a phi when one predecessor
+ // does not update the local.
+ const char* expected =
+ "BasicBlock 0, succ: 1\n"
+ " 0: IntConstant 0 [4, 8, 6, 6, 2, 2, 8, 4]\n"
+ " 1: Goto\n"
+ "BasicBlock 1, pred: 0, succ: 3, 2\n"
+ " 2: Equal(0, 0) [3]\n"
+ " 3: If(2)\n"
+ "BasicBlock 2, pred: 1, succ: 5\n"
+ " 4: Add(0, 0)\n"
+ " 5: Goto\n"
+ "BasicBlock 3, pred: 1, succ: 7, 4\n"
+ " 6: Equal(0, 0) [7]\n"
+ " 7: If(6)\n"
+ "BasicBlock 4, pred: 3, succ: 5\n"
+ " 8: Add(0, 0)\n"
+ " 9: Goto\n"
+ // This block should not get a phi for local 1.
+ "BasicBlock 5, pred: 2, 4, 7, succ: 6\n"
+ " 10: ReturnVoid\n"
+ "BasicBlock 6, pred: 5\n"
+ " 11: Exit\n"
+ "BasicBlock 7, pred: 3, succ: 5\n"
+ " 12: Goto\n";
+
+ const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ Instruction::CONST_4 | 0 | 0,
+ Instruction::IF_EQ, 5,
+ Instruction::ADD_INT_LIT8 | 1 << 8, 0 << 8,
+ Instruction::GOTO | 0x0500,
+ Instruction::IF_EQ, 4,
+ Instruction::ADD_INT_LIT8 | 1 << 8, 0 << 8,
+ Instruction::RETURN_VOID);
+
+ TestCode(data, expected);
+}
+
} // namespace art