65 for (byte c : testValues) { |
65 for (byte c : testValues) { |
66 values[2] = c; |
66 values[2] = c; |
67 for (byte d : testValues) { |
67 for (byte d : testValues) { |
68 values[3] = d; |
68 values[3] = d; |
69 value = 2; |
69 value = 2; |
70 super.test("testSnippet1", values, true); |
70 super.test("testSnippet1", values); |
71 super.test("testSnippet1", values, false); |
|
72 } |
71 } |
73 } |
72 } |
74 } |
73 } |
75 } |
74 } |
76 } |
75 } |
77 |
76 |
78 public int testSnippet1(byte[] values, boolean test) { |
77 public int testSnippet1(byte[] values) { |
79 int v = values[0] - values[1]; |
78 int v = values[0] - values[1]; |
80 if (test) { |
79 if (v < 0) { |
81 v = values[2] - values[3]; |
80 value = 2; |
82 } |
81 } |
|
82 v = values[3] - values[2]; |
83 if (v < 0) { |
83 if (v < 0) { |
84 value = 1; |
84 value = 1; |
85 } |
85 } |
86 return value; |
86 return value; |
87 } |
87 } |
154 |
154 |
155 public void test(String name, Class<? extends Node> expectedClass, int expectedCount) { |
155 public void test(String name, Class<? extends Node> expectedClass, int expectedCount) { |
156 StructuredGraph graph = parseEager(name, AllowAssumptions.YES); |
156 StructuredGraph graph = parseEager(name, AllowAssumptions.YES); |
157 |
157 |
158 CoreProviders context = getProviders(); |
158 CoreProviders context = getProviders(); |
159 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(); |
159 CanonicalizerPhase canonicalizer = createCanonicalizerPhase(); |
160 new ConvertDeoptimizeToGuardPhase().apply(graph, context); |
160 new ConvertDeoptimizeToGuardPhase().apply(graph, context); |
161 graph.clearAllStateAfter(); |
161 graph.clearAllStateAfter(); |
162 graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA); |
162 graph.setGuardsStage(StructuredGraph.GuardsStage.AFTER_FSA); |
163 canonicalizer.apply(graph, context); |
163 canonicalizer.apply(graph, context); |
164 |
164 |
165 // new DominatorConditionalEliminationPhase(true).apply(graph, context); |
|
166 new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context); |
165 new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context); |
167 canonicalizer.apply(graph, context); |
166 canonicalizer.apply(graph, context); |
168 canonicalizer.apply(graph, context); |
167 canonicalizer.apply(graph, context); |
169 |
168 |
170 Assert.assertEquals(expectedCount, graph.getNodes().filter(expectedClass).count()); |
169 Assert.assertEquals(expectedCount, graph.getNodes().filter(expectedClass).count()); |