1 /* 2 * Copyright (C) 2022 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 static long count; 19 20 // Simplified version: Removed both outer loops from `$noinline$mainTest()`. $noinline$verySimpleTest()21 static int $noinline$verySimpleTest() { 22 int i1 = 10, i17, i20, i21 = -2; 23 for (i17 = 2; i17 > 1; i17--) { 24 i1 += i17; 25 count = i1; 26 } 27 for (i20 = 1; i20 < 2; ++i20) { 28 i21 += i17; 29 } 30 return i21; 31 } 32 33 // Simplified version: Removed outer loop from `$noinline$mainTest()`. $noinline$simpleTest()34 static int $noinline$simpleTest() { 35 int i1 = 10, i15, i17, i20, i21 = -2; 36 for (i15 = 11; i15 < 188; ++i15) { 37 for (i17 = 2; i17 > 1; i17--) { 38 i1 += i17; 39 count = i1; 40 } 41 for (i20 = 1; i20 < 2; ++i20) { 42 i21 += i17; 43 } 44 } 45 return i21; 46 } 47 $noinline$mainTest()48 static int $noinline$mainTest() { 49 int i, i1 = 10, i15 = 49099, i17, i20, i21 = -2; 50 for (i = 5; i < 138; i++) 51 for (i15 = 11; i15 < 188; ++i15) { 52 for (i17 = 2; i17 > 1; i17--) { 53 i1 += i17; 54 count = i1; 55 } 56 for (i20 = 1; i20 < 2; ++i20) { 57 i21 += i17; 58 } 59 } 60 return i21; 61 } 62 assertEquals(int expected, int actual)63 public static void assertEquals(int expected, int actual) { 64 if (expected != actual) { 65 throw new Error("Expected " + expected + ", got " + actual); 66 } 67 } 68 main(String[] strArr)69 public static void main(String[] strArr) { 70 assertEquals(-1, $noinline$verySimpleTest()); 71 assertEquals(175, $noinline$simpleTest()); 72 assertEquals(23539, $noinline$mainTest()); 73 } 74 } 75