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/collapse.
28  * VM Testbase keywords: [jit, quick]
29  *
30  * @library /vmTestbase
31  *          /test/lib
32  * @run driver jdk.test.lib.FileInstaller . .
33  * @build jit.collapse.collapse
34  * @run driver ExecDriver --java jit.collapse.collapse
35  */
36 
37 package jit.collapse;
38 
39 import nsk.share.TestFailure;
40 import nsk.share.GoldChecker;
41 
42 class collapse {
43         public static final GoldChecker goldChecker = new GoldChecker( "collapse" );
44 
main( String[] argv )45         public static void main( String[] argv )
46         {
47                 int i;
48                 int j=0, k=0;
49                 long lj=0L, lk=0L;
50                 float fj=0.0F, fk=0.0F;
51                 double dj=0.0D, dk=0.0D;
52                 int n = 4;
53                 boolean boolPass = true;
54                 for (i=1; i<n; i++) {
55                         j = j + 6;
56                         j = j + 6;
57                         j = j + 6;
58                         j = j + 6;
59                 }
60                 for (i=1; i<n; i++) {
61                         k = k + 24;
62                 }
63                 boolPass &= j==k;
64                 collapse.goldChecker.println("int + test: "+j+" should equal "+k);
65                 for (i=1; i<n; i++) {
66                         lj = lj + 6L;
67                         lj = lj + 6L;
68                         lj = lj + 6L;
69                         lj = lj + 6L;
70                 }
71                 for (i=1; i<n; i++) {
72                         lk = lk + 24L;
73                 }
74                 boolPass &= lj==lk;
75                 collapse.goldChecker.println("long + test: "+lj+" should equal "+lk);
76                 for (i=1; i<n; i++) {
77                         dj = dj + 6;
78                         dj = dj + 6;
79                         dj = dj + 6;
80                         dj = dj + 6;
81                 }
82                 for (i=1; i<n; i++) {
83                         dk = dk + 24;
84                 }
85                 boolPass &= dj==dk;
86                 collapse.goldChecker.println("double + test: "+dj+" should equal "+dk);
87                 for (i=1; i<n; i++) {
88                         fj = fj + 6;
89                         fj = fj + 6;
90                         fj = fj + 6;
91                         fj = fj + 6;
92                 }
93                 for (i=1; i<n; i++) {
94                         fk = fk + 24;
95                 }
96                 boolPass &= fj==fk;
97                 collapse.goldChecker.println("float + test: "+fj+" should equal "+fk);
98                 j=0; k=0;
99                 lj=0L; lk=0L;
100                 fj=0.0F; fk=0.0F;
101                 dj=0.0D; dk=0.0D;
102                 for (i=1; i<n; i++) {
103                         j += 6;
104                         j += 6;
105                         j += 6;
106                         j += 6;
107                 }
108                 for (i=1; i<n; i++) {
109                         k += 24;
110                 }
111                 boolPass &= j==k;
112                 collapse.goldChecker.println("int += test: "+j+" should equal "+k);
113                 for (i=1; i<n; i++) {
114                         lj += 6;
115                         lj += 6;
116                         lj += 6;
117                         lj += 6;
118                 }
119                 for (i=1; i<n; i++) {
120                         lk += 24;
121                 }
122                 boolPass &= lj==lk;
123                 collapse.goldChecker.println("long += test: "+lj+" should equal "+lk);
124                 for (i=1; i<n; i++) {
125                         dj += 6;
126                         dj += 6;
127                         dj += 6;
128                         dj += 6;
129                 }
130                 for (i=1; i<n; i++) {
131                         dk += 24;
132                 }
133                 boolPass &= dj==dk;
134                 collapse.goldChecker.println("double += test: "+dj+" should equal "+dk);
135                 for (i=1; i<n; i++) {
136                         fj += 6;
137                         fj += 6;
138                         fj += 6;
139                         fj += 6;
140                 }
141                 for (i=1; i<n; i++) {
142                         fk += 24;
143                 }
144                 boolPass &= fj==fk;
145                 collapse.goldChecker.println("float += test: "+fj+" should equal "+fk);
146 
147                 if (!boolPass)
148                     throw new TestFailure("Test failed.");
149                 collapse.goldChecker.check();
150         }
151 }
152