1 /* 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 17 public class Main { 18 19 static boolean doThrow = false; 20 static long longValue; 21 assertEquals(float expected, float result)22 public static void assertEquals(float expected, float result) { 23 if (expected != result) { 24 throw new Error("Expected: " + expected + ", found: " + result); 25 } 26 } 27 main(String[] args)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 $noinline$longToFloat()37 static float $noinline$longToFloat() { 38 if (doThrow) { throw new Error(); } 39 longValue = $inline$returnConst(); 40 return (float) longValue; 41 } 42 $inline$returnConst()43 static long $inline$returnConst() { 44 return 1L; 45 } 46 } 47