Path: blob/master/test/hotspot/jtreg/compiler/loopopts/Test7044738.java
41149 views
/*1* Copyright (c) 2011, 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*/2223/**24* @test25* @bug 704473826* @summary Loop unroll optimization causes incorrect result27*28* @run main/othervm -Xbatch compiler.loopopts.Test704473829*/3031package compiler.loopopts;3233public class Test7044738 {3435private static final int INITSIZE = 10000;36public int d[] = {1, 2, 3, 4};37public int i, size;3839private static int iter = 5;4041boolean done() {42return (--iter > 0);43}4445public static void main(String args[]) {46Test7044738 t = new Test7044738();47t.test();48}4950int test() {5152while (done()) {53size = INITSIZE;5455for (i = 0; i < size; i++) {56d[0] = d[1]; // 257d[1] = d[2]; // 358d[2] = d[3]; // 459d[3] = d[0]; // 26061d[0] = d[1]; // 362d[1] = d[2]; // 463d[2] = d[3]; // 264d[3] = d[0]; // 36566d[0] = d[1]; // 467d[1] = d[2]; // 268d[2] = d[3]; // 369d[3] = d[0]; // 47071d[0] = d[1]; // 272d[1] = d[2]; // 373d[2] = d[3]; // 474d[3] = d[0]; // 27576d[0] = d[1]; // 377d[1] = d[2]; // 478d[2] = d[3]; // 279d[3] = d[0]; // 38081d[0] = d[1]; // 482d[1] = d[2]; // 283d[2] = d[3]; // 384d[3] = d[0]; // 48586d[0] = d[1]; // 287d[1] = d[2]; // 388d[2] = d[3]; // 489d[3] = d[0]; // 29091d[0] = d[1]; // 392d[1] = d[2]; // 493d[2] = d[3]; // 294d[3] = d[0]; // 395}9697// try to defeat dead code elimination98if (d[0] == d[1]) {99System.out.println("test failed: iter=" + iter + " i=" + i + " d[] = { " + d[0] + ", " + d[1] + ", " + d[2] + ", " + d[3] + " } ");100System.exit(97);101}102}103return d[3];104}105}106107108