Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift01.java @ 5061:e808627bd16f
Renamed projects.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 19:24:17 +0100 |
parents | graal/com.oracle.max.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift01.java@4ed4295ce15f |
children | 390448a6b535 |
comparison
equal
deleted
inserted
replaced
5060:4ed4295ce15f | 5061:e808627bd16f |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2012, 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.jtt.optimize; | |
24 | |
25 import org.junit.*; | |
26 | |
27 /* | |
28 * Tests optimization of integer operations. | |
29 */ | |
30 public class Reduce_LongShift01 { | |
31 | |
32 public static long test(long arg) { | |
33 if (arg == 0) { | |
34 return shift0(arg + 10); | |
35 } | |
36 if (arg == 1) { | |
37 return shift1(arg + 10); | |
38 } | |
39 if (arg == 2) { | |
40 return shift2(arg + 10); | |
41 } | |
42 if (arg == 3) { | |
43 return shift3(arg + 10); | |
44 } | |
45 if (arg == 4) { | |
46 return shift4(arg + 10); | |
47 } | |
48 if (arg == 5) { | |
49 return shift5(arg + 10); | |
50 } | |
51 return 0; | |
52 } | |
53 | |
54 public static long shift0(long x) { | |
55 return x >> 0; | |
56 } | |
57 | |
58 public static long shift1(long x) { | |
59 return x >>> 0; | |
60 } | |
61 | |
62 public static long shift2(long x) { | |
63 return x << 0; | |
64 } | |
65 | |
66 public static long shift3(long x) { | |
67 return x >> 64; | |
68 } | |
69 | |
70 public static long shift4(long x) { | |
71 return x >>> 64; | |
72 } | |
73 | |
74 public static long shift5(long x) { | |
75 return x << 64; | |
76 } | |
77 | |
78 @Test | |
79 public void run0() throws Throwable { | |
80 Assert.assertEquals(10L, test(0)); | |
81 } | |
82 | |
83 @Test | |
84 public void run1() throws Throwable { | |
85 Assert.assertEquals(11L, test(1)); | |
86 } | |
87 | |
88 @Test | |
89 public void run2() throws Throwable { | |
90 Assert.assertEquals(12L, test(2)); | |
91 } | |
92 | |
93 @Test | |
94 public void run3() throws Throwable { | |
95 Assert.assertEquals(13L, test(3)); | |
96 } | |
97 | |
98 @Test | |
99 public void run4() throws Throwable { | |
100 Assert.assertEquals(14L, test(4)); | |
101 } | |
102 | |
103 @Test | |
104 public void run5() throws Throwable { | |
105 Assert.assertEquals(15L, test(5)); | |
106 } | |
107 | |
108 } |