InferStamp01.java revision 12651:6ef01bd40ce2
1/*
2 * Copyright (c) 2013, 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 */
23package org.graalvm.compiler.jtt.optimize;
24
25import org.junit.Test;
26
27import org.graalvm.compiler.jtt.JTTTest;
28
29/**
30 * test some stamps in combination with full loop unrolling and shifts.
31 */
32public class InferStamp01 extends JTTTest {
33
34    public static int testi0(int arg) {
35        int a = arg;
36        for (int i = 0; i < 2; i++) {
37            a = a >> 16;
38        }
39        return a;
40    }
41
42    @Test
43    public void runi0() throws Throwable {
44        runTest("testi0", 0x7788_99aa);
45    }
46
47    @Test
48    public void runi0neg() throws Throwable {
49        runTest("testi0", 0xf788_99aa);
50    }
51
52    public static int testi1(int arg) {
53        int a = arg;
54        for (int i = 0; i < 2; i++) {
55            a = a >>> 16;
56        }
57        return a;
58    }
59
60    @Test
61    public void runi1() throws Throwable {
62        runTest("testi1", 0x7788_99aa);
63    }
64
65    @Test
66    public void runi1neg() throws Throwable {
67        runTest("testi1", 0xf788_99aa);
68    }
69
70    public static int testi2(int arg) {
71        int a = arg;
72        for (int i = 0; i < 2; i++) {
73            a = a << 16;
74        }
75        return a;
76    }
77
78    @Test
79    public void runi2() throws Throwable {
80        runTest("testi2", 0x7788_99aa);
81    }
82
83    @Test
84    public void runi2neg() throws Throwable {
85        runTest("testi2", 0xf788_99aa);
86    }
87
88    public static long testl0(long arg) {
89        long a = arg;
90        for (long i = 0; i < 2; i++) {
91            a = a >> 32;
92        }
93        return a;
94    }
95
96    @Test
97    public void runl0() throws Throwable {
98        runTest("testl0", 0x3344_5566_7788_99aaL);
99    }
100
101    @Test
102    public void runl0neg() throws Throwable {
103        runTest("testl0", 0xf344_5566_7788_99aaL);
104    }
105
106    public static long testl1(long arg) {
107        long a = arg;
108        for (long i = 0; i < 2; i++) {
109            a = a >>> 32;
110        }
111        return a;
112    }
113
114    @Test
115    public void runl1() throws Throwable {
116        runTest("testl1", 0x3344_5566_7788_99aaL);
117    }
118
119    @Test
120    public void runl1neg() throws Throwable {
121        runTest("testl1", 0xf344_5566_7788_99aaL);
122    }
123
124    public static long testl2(long arg) {
125        long a = arg;
126        for (long i = 0; i < 2; i++) {
127            a = a << 32;
128        }
129        return a;
130    }
131
132    @Test
133    public void runl2() throws Throwable {
134        runTest("testl2", 0x3344_5566_7788_99aaL);
135    }
136
137    @Test
138    public void runl2neg() throws Throwable {
139        runTest("testl2", 0xf344_5566_7788_99aaL);
140    }
141}
142