comparison graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest5.java @ 19716:2fd45bb25118

Initial version of new dominator-based conditional elimination phase.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 08 Mar 2015 21:58:34 +0100
parents
children dde8a89e7f92
comparison
equal deleted inserted replaced
19715:8f21e30a29c2 19716:2fd45bb25118
1 /*
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.oracle.graal.compiler.test;
24
25 import org.junit.*;
26
27 /**
28 * Collection of tests for
29 * {@link com.oracle.graal.phases.common.DominatorConditionalEliminationPhase} including those that
30 * triggered bugs in this phase.
31 */
32 public class ConditionalEliminationTest5 extends ConditionalEliminationTestBase {
33
34 interface A {
35 }
36
37 interface B extends A {
38 }
39
40 @SuppressWarnings("all")
41 public static int reference1Snippet(A a, B b) {
42 if (a instanceof B) {
43 return 1;
44 }
45 return 2;
46 }
47
48 @SuppressWarnings("all")
49 public static int test1Snippet(A a, B b) {
50 if (a instanceof B) {
51 if (a instanceof A) {
52 return 1;
53 }
54 }
55 return 2;
56 }
57
58 @Test
59 public void test1() {
60 test("test1Snippet", "reference1Snippet");
61 }
62
63 @SuppressWarnings("all")
64 public static int reference2Snippet(A a, B b) {
65 if (a instanceof B) {
66 return 1;
67 }
68 return 2;
69 }
70
71 @SuppressWarnings("all")
72 public static int test2Snippet(A a, B b) {
73 if (a instanceof B) {
74 B newVal = (B) a;
75 if (newVal != null) {
76 return 1;
77 }
78 }
79 return 2;
80 }
81
82 @Test
83 public void test2() {
84 test("test2Snippet", "reference2Snippet");
85 }
86 }