Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/partialpeel/Do.java
41161 views
/*1* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package vm.compiler.optimizations.partialpeel;2324import nsk.share.GoldChecker;25import vm.compiler.share.CompilerTest;26import vm.compiler.share.CompilerTestLauncher;27import vm.compiler.share.Random;2829import java.util.Arrays;30import java.util.List;3132public class Do {333435public static void main(String[] args) {36GoldChecker goldChecker = new GoldChecker("Do");3738for(CompilerTest test: doTests) {39goldChecker.println(test + " = " + CompilerTestLauncher.launch(test));40}4142goldChecker.check();43}4445private final static int N = 1000;46private final static int x0 = 232;47private final static int x1 = 562;48private final static int x2 = 526;49private final static int x3 = 774;5051public static final List<CompilerTest<Integer>> doTests = Arrays.asList(52new CompilerTest<Integer>("do1") {53@Override54public Integer execute(Random random) {55int s = random.nextInt(1000);56int i = 0;57do {58if (s * i > x0) {59break;60}61s++;62i++;63} while (i < N);64return s + i;65}66},6768//do + break on sum of inductive vars69new CompilerTest<Integer>("do2") {70@Override71public Integer execute(Random random) {72int s = random.nextInt(1000);73int i = 0;74do {75if (s + i > x0) {76break;77}78s++;79i++;80} while (i < N);81return s + i;82}83},8485//do + break on shifted inductive vars86new CompilerTest<Integer>("do3") {87@Override88public Integer execute(Random random) {89int s = random.nextInt(1000);90int i = 0;91do {92if (x3 + s < x0) {93break;94}95s += i;96i++;97} while (i < N);98return s + i;99}100},101102//do + break on shifted inductive vars + invariant condition103new CompilerTest<Integer>("do4") {104@Override105public Integer execute(Random random) {106int i = x0 + random.nextInt(1000);107int j = x1;108int k = x2;109110do {111if (x3 + k < x0) {112break;113}114i++;115k++;116if (x2 > x1) {117j += i;118k += j;119}120121} while (i < N);122return k + i;123}124},125126//do + break on shifted inductive vars + invariant condition127new CompilerTest<Integer>("do5") {128@Override129public Integer execute(Random random) {130int i = x0 + random.nextInt(1000);131int j = x1;132int k = x2;133134do {135if (k < x0) {136break;137}138i++;139if (x2 > x1) {140j += i;141k += j;142}143144} while (i < N);145return k + i;146}147},148149//do + break on hidden inductive vars + invariant condition150new CompilerTest<Integer>("do6") {151@Override152public Integer execute(Random random) {153int i = x0;154int j = x1 + random.nextInt(1000);155int k = x2;156157do {158if (k < x0) {159break;160}161i++;162k++;163if (k > x1) {164j += i;165k += j + i;166}167168} while (i < N);169return k + i;170}171}172173);174}175176177