blob: cd9703943d043a5920d0d8c0f39d68eba8df288b [file] [log] [blame]
Roland Levillain232ade02015-04-20 15:14:36 +01001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Note that $opt$ is a marker for the optimizing compiler to ensure
18// it does compile the method.
19public class Main {
20
21 public static void assertFloatEquals(float expected, float result) {
22 if (expected != result) {
23 throw new Error("Expected: " + expected + ", found: " + result);
24 }
25 }
26
27 public static void main(String[] args) {
28 // Generate, compile and check long-to-float Dex instructions.
29 longToFloat();
30 }
31
32 private static void longToFloat() {
Roland Levillain5b3ee562015-04-14 16:02:41 +010033 // The result for this test case used to be slightly less accurate
34 // on ARM (both in Quick and Optimizing).
Roland Levillain232ade02015-04-20 15:14:36 +010035 assertFloatEquals(Float.intBitsToFloat(-555858671), $opt$LongToFloat(-8008112895877447681L));
36 }
37
38 // This method produces a long-to-float Dex instruction.
39 static float $opt$LongToFloat(long a) { return (float)a; }
40}