Mercurial > hg > truffle
annotate graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConvertCompare.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | c7c9624f8ca2 |
children |
rev | line source |
---|---|
13195
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.jtt.optimize; |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14010
diff
changeset
|
25 import org.junit.*; |
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14010
diff
changeset
|
26 |
13195
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
27 import com.oracle.graal.jtt.*; |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 public class ConvertCompare extends JTTTest { |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
30 public static boolean test(int a, float d) { |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 return a == (double) d; |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
32 } |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
33 |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
34 @Test |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
35 public void run0() throws Throwable { |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 runTest("test", 0, 2.87f); |
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 } |
14008
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
38 |
14010
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
39 public static boolean testChar42(int x) { |
14008
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
40 return ((char) x) == 42; |
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
41 } |
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
42 |
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
43 @Test |
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
44 public void run1() { |
14010
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
45 runTest("testChar42", 42); |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
46 } |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
47 |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
48 @Test |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
49 public void run2() { |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
50 runTest("testChar42", (int) Character.MAX_VALUE); |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
51 } |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
52 |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
53 public static boolean testCharMax(int x) { |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
54 return ((char) x) == Character.MAX_VALUE; |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
55 } |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
56 |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
57 @Test |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
58 public void run3() { |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
59 runTest("testCharMax", 42); |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
60 } |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
61 |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
62 @Test |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
63 public void run4() { |
c7c9624f8ca2
Fix corner case in stamp computation of zero extension.
Roland Schatz <roland.schatz@oracle.com>
parents:
14008
diff
changeset
|
64 runTest("testCharMax", (int) Character.MAX_VALUE); |
14008
1658d30cd273
Fix type error in compare convert-constant optimization.
Roland Schatz <roland.schatz@oracle.com>
parents:
13195
diff
changeset
|
65 } |
13195
bb992a44734e
Fix Compare Canonicalization with 2 converts from different kinds as input
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 } |