blob: 9c07f3d6920b0933f06b76fba96865f9d733ef7d [file] [log] [blame]
Pavel Vyssotski4c858cd2016-03-16 13:59:53 +06001/*
2 * Copyright (C) 2016 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
17public class Main {
18
19 static boolean doThrow = false;
20 static long longValue;
21
22 public static void assertEquals(float expected, float result) {
23 if (expected != result) {
24 throw new Error("Expected: " + expected + ", found: " + result);
25 }
26 }
27
28 public static void main(String[] args) {
29 assertEquals(1.0F, $noinline$longToFloat());
30 }
31
32 /// CHECK-START: float Main.$noinline$longToFloat() register (after)
33 /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1
34 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const1>>]
35 /// CHECK-DAG: Return [<<Convert>>]
36
37 static float $noinline$longToFloat() {
38 if (doThrow) { throw new Error(); }
39 longValue = $inline$returnConst();
40 return (float) longValue;
41 }
42
43 static long $inline$returnConst() {
44 return 1L;
45 }
46}