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/t/t048.
  28  * VM Testbase keywords: [jit, quick]
  29  *
  30  * @library /vmTestbase
  31  *          /test/lib
  32  * @run driver jdk.test.lib.FileInstaller . .
  33  * @build jit.t.t048.t048
  34  * @run driver ExecDriver --java jit.t.t048.t048
  35  */
  36 
  37 package jit.t.t048;
  38 
  39 import nsk.share.TestFailure;
  40 import nsk.share.GoldChecker;
  41 
  42 // Register jams and spills
  43 
  44 class t048
  45 {
  46     public static final GoldChecker goldChecker = new GoldChecker( "t048" );
  47 
  48     static int idiv(int i, int j)
  49     {
  50         int res = i / j;
  51         t048.goldChecker.println("i: " + i + ", j: " + j + ", res: " + res);
  52         return res;
  53     }
  54 
  55     static void intDivs()
  56     {
  57         int a, b, c, d, e, f, g, h, i, j, k, l, z;
  58         int t1, t2, t3, t4, t5, t6, t7;
  59 
  60         a=13; b=12; c=11; d=10; e=9; f=8; g=7; h=6; i=5; j=4; k=3; l=2;
  61 
  62         t1 = a/b;
  63         t2 = c/d;
  64         t3 = e/f;
  65         t4 = g/h;
  66         t5 = i/j;
  67         t6 = k/l;
  68         t048.goldChecker.println("t6 = " + t6);
  69         t048.goldChecker.println("t5 = " + t5);
  70         t5 /= t6;
  71         t048.goldChecker.println("t5 = " + t5);
  72         t048.goldChecker.println("t4 = " + t4);
  73         t4 /= t5;
  74         t3 /= t4;
  75         t2 /= t3;
  76         t1 /= t2;
  77 
  78         t048.goldChecker.println("t1 == " + t1);
  79         z = idiv
  80         (
  81             idiv(a,b),
  82             idiv
  83             (
  84                 idiv(c,d),
  85                 idiv
  86                 (
  87                     idiv(e,f),
  88                     idiv
  89                     (
  90                         idiv(g,h),
  91                         idiv
  92                         (
  93                             idiv(i,j),
  94                             idiv(k, l)
  95                         )
  96                     )
  97                 )
  98             )
  99         );
 100         z = (a/b) /
 101             ((c/d) /
 102             ((e/f) /
 103             ((g/h) /
 104             ((i/j) / (k/l)))));
 105         t048.goldChecker.println("Int: " + z);
 106     }
 107 
 108     static void longDivs()
 109     {
 110         long a, b, c, d, e, f, g, h, i, j, k, l, z;
 111 
 112         a=13; b=12; c=11; d=10; e=9; f=8; g=7; h=6; i=5; j=4; k=3; l=2;
 113 
 114         z = (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / (k/l)))));
 115         t048.goldChecker.println("Long: " + z);
 116     }
 117 
 118     static void floatDivs()
 119     {
 120         float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, z;
 121 
 122         a=1; b=2; c=3; d=4; e=5; f=6; g=7; h=8; i=9; j=10; k=11; l=12;
 123         m=13; n=14; o=15; p=16; q=17; r=18; s=19; t=20;
 124         z = (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 125             ((o/p) / ((q/r) / (s/t)))))))));
 126         t048.goldChecker.println("Float: " + z);
 127         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 128             ((o/p) / ((q/r) / (s/t)))))))));
 129         t048.goldChecker.println("Float: " + z);
 130         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 131             ((o/p) / ((q/r) / (s/t)))))))));
 132         t048.goldChecker.println("Float: " + z);
 133         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 134             ((o/p) / ((q/r) / (s/t)))))))));
 135         t048.goldChecker.println("Float: " + z);
 136         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 137             ((o/p) / ((q/r) / (s/t)))))))));
 138         t048.goldChecker.println("Float: " + z);
 139         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 140             ((o/p) / ((q/r) / (s/t)))))))));
 141         t048.goldChecker.println("Float: " + z);
 142         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 143             ((o/p) / ((q/r) / (s/t)))))))));
 144         t048.goldChecker.println("Float: " + z);
 145         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 146             ((o/p) / ((q/r) / (s/t)))))))));
 147         t048.goldChecker.println("Float: " + z);
 148         z /= (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 149             ((o/p) / ((q/r) / (s/t)))))))));
 150         t048.goldChecker.println("Float: " + z);
 151     }
 152 
 153     static void doubleDivs()
 154     {
 155         double a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, z;
 156 
 157         a=1; b=2; c=3; d=4; e=5; f=6; g=7; h=8; i=9; j=10; k=11; l=12;
 158         m=13; n=14; o=15; p=16; q=17; r=18; s=19; t=20;
 159         z = (a/b) / ((c/d) / ((e/f) / ((g/h) / ((i/j) / ((k/l) / ((m/n) /
 160             ((o/p) / ((q/r) / (s/t)))))))));
 161         t048.goldChecker.println("Double: " + z);
 162     }
 163 
 164     public static void main(String argv[])
 165     {
 166         intDivs();
 167         longDivs();
 168         floatDivs();
 169         doubleDivs();
 170         t048.goldChecker.check();
 171     }
 172 }