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