diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-06-04 12:12:08 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-06-04 13:39:37 +0100 |
commit | 7c3560f2ce0ec9484004d05a94bfaa6e02f5a96a (patch) | |
tree | 44544a733178fe7416264e064477c681f08ae562 /compiler/optimizing/ssa_test.cc | |
parent | 57795db7d44bcd6d106481fa192691400b2358c8 (diff) | |
download | art-7c3560f2ce0ec9484004d05a94bfaa6e02f5a96a.zip art-7c3560f2ce0ec9484004d05a94bfaa6e02f5a96a.tar.gz art-7c3560f2ce0ec9484004d05a94bfaa6e02f5a96a.tar.bz2 |
Fix a bug in SSA construction.
If a join block does not have an incoming value for a local
from a predecessor block, we should not create a phi. The
verifier has made sure the local is updated before any
following reads after this block.
Change-Id: Id2785efc73c9fb3224826fff2f4b4ad215905ff4
Diffstat (limited to 'compiler/optimizing/ssa_test.cc')
-rw-r--r-- | compiler/optimizing/ssa_test.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/compiler/optimizing/ssa_test.cc b/compiler/optimizing/ssa_test.cc index d104619..485ea27 100644 --- a/compiler/optimizing/ssa_test.cc +++ b/compiler/optimizing/ssa_test.cc @@ -459,4 +459,34 @@ TEST(SsaTest, DeadLocal) { TestCode(data, expected); } +TEST(SsaTest, LocalInIf) { + // Test that we do not create a phi in the join block when one predecessor + // does not update the local. + const char* expected = + "BasicBlock 0, succ: 1\n" + " 0: IntConstant 0 [3, 3]\n" + " 1: IntConstant 4\n" + " 2: Goto\n" + "BasicBlock 1, pred: 0, succ: 2, 5\n" + " 3: Equal(0, 0) [4]\n" + " 4: If(3)\n" + "BasicBlock 2, pred: 1, succ: 3\n" + " 5: Goto\n" + "BasicBlock 3, pred: 2, 5, succ: 4\n" + " 6: ReturnVoid\n" + "BasicBlock 4, pred: 3\n" + " 7: Exit\n" + // Synthesized block to avoid critical edge. + "BasicBlock 5, pred: 1, succ: 3\n" + " 8: Goto\n"; + + const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( + Instruction::CONST_4 | 0 | 0, + Instruction::IF_EQ, 3, + Instruction::CONST_4 | 4 << 12 | 1 << 8, + Instruction::RETURN_VOID); + + TestCode(data, expected); +} + } // namespace art |