# HG changeset patch # User Lukas Stadler # Date 1365441521 -7200 # Node ID 0f18f7d5b39684b9e32176c9fd1802e262e6c5fd # Parent 5075e8f0a38019fa75cf493f8ae8f4e025d633f2 add test for read elimination diff -r 5075e8f0a380 -r 0f18f7d5b396 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Mon Apr 08 19:18:18 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Mon Apr 08 19:18:41 2013 +0200 @@ -143,10 +143,11 @@ } @SuppressWarnings("all") - public static int testBadLoopSnippet(TestObject obj, int a, int b) { + public static int testBadLoopSnippet(TestObject obj, TestObject obj2, int a, int b) { obj.x = a; for (int i = 0; i < 10; i++) { staticField = obj; + obj2.x = 10; obj.x = 0; } return obj.x; @@ -155,6 +156,24 @@ @Test public void testBadLoop() { ValueNode result = getReturn("testBadLoopSnippet").result(); + assertEquals(0, graph.getNodes(LoadFieldNode.class).count()); + assertTrue(result instanceof ProxyNode); + assertTrue(((ProxyNode) result).value() instanceof PhiNode); + } + + @SuppressWarnings("all") + public static int testBadLoop2Snippet(TestObject obj, TestObject obj2, int a, int b) { + obj.x = a; + for (int i = 0; i < 10; i++) { + obj.x = 0; + obj2.x = 10; + } + return obj.x; + } + + @Test + public void testBadLoop2() { + ValueNode result = getReturn("testBadLoop2Snippet").result(); assertEquals(1, graph.getNodes(LoadFieldNode.class).count()); assertTrue(result instanceof LoadFieldNode); }