1 /* 2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * 27 * @summary converted from VM Testbase jit/FloatingPoint/gen_math/Loops07. 28 * VM Testbase keywords: [jit, quick] 29 * 30 * @library /vmTestbase 31 * /test/lib 32 * @run driver jdk.test.lib.FileInstaller . . 33 * @build jit.FloatingPoint.gen_math.Loops07.Loops07 34 * @run driver ExecDriver --java jit.FloatingPoint.gen_math.Loops07.Loops07 35 */ 36 37 package jit.FloatingPoint.gen_math.Loops07; 38 39 // Test working with nested loops. 40 // Code is subject to different types of optimization 41 // and parallelization - empty loops, dead code, etc. 42 43 import nsk.share.TestFailure; 44 45 class Loops07 46 { 47 48 public static void main (String args[]) 49 { 50 51 int N = 8; 52 double Error = 1; 53 double r1, r2, r3, r4, r5, r6; 54 55 double xx[][]; 56 double z1, z2, z3; 57 58 xx = new double[N][N]; 59 60 Loops07 ll; 61 ll = new Loops07(); 62 63 for(int i = 0; i < N; i++) 64 { 65 for(int j = 0; j < N; j++) 66 { 67 r1 = i * i + j * j; 68 r2 = Math.sqrt(r1); 69 r3 = 1 / r2 ; 70 r4 = i + j ; 71 r5 = r4 / r3 ; 72 73 xx[i][j] = r5; 74 } 75 } 76 77 // main loop --------------------------- 78 z1 = 0; 79 for(int m1 = 0; m1 < N; m1++) 80 { 81 for(int m2 = 0; m2 < N; m2++) 82 { 83 z1 = z1 - 0.5 * xx[m1][m2]; 84 for(int m3 = 0; m3 < N; m3++) 85 { 86 for(int m4 = 0; m4 < N; m4++) 87 { 88 z1 = z1 + xx[m3][m4]; 89 90 for(int m5 = 0; m5 < N; m5++) 91 { 92 for(int m6 = 0; m6 < N; m6++) 93 { 94 for(int m7 = 0; m7 < N; m7++) 95 { 96 z2 = Math.abs(1 + Math.sin(2 + Math.cos(3 + 97 Math.sqrt(4 - Math.cos(5))))); 98 99 } 100 } 101 } 102 } 103 } 104 } 105 } 106 107 // --------------------------------------- 108 double er = Math.abs(184401 - z1); 109 110 if( er < Error) 111 System.out.println("test PASS"); 112 else 113 throw new TestFailure("test FAIL"); 114 115 } 116 117 118 119 120 121 }