Path: blob/master/test/hotspot/jtreg/compiler/codegen/Test6814842.java
41149 views
/*1* Copyright (c) 2009, 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 681484226* @summary Load shortening optimizations27*28* @run main/othervm -Xcomp29* -XX:CompileCommand=compileonly,compiler.codegen.Test6814842::load*30* compiler.codegen.Test681484231*/3233package compiler.codegen;3435public class Test6814842 {36static final short[] sa = new short[] { (short) 0xF1F2 };37static final char[] ca = new char[] { (char) 0xF3F4 };38static final int[] ia = new int[] { 0xF1F2F3F4 };3940public static void main(String[] args)41{42byte s2b = loadS2B(sa);43if (s2b != (byte) 0xF2)44throw new InternalError("loadS2B failed: " + s2b + " != " + (byte) 0xF2);4546byte s2bmask255 = loadS2Bmask255(sa);47if (s2bmask255 != (byte) 0xF2)48throw new InternalError("loadS2Bmask255 failed: " + s2bmask255 + " != " + (byte) 0xF2);4950byte us2b = loadUS2B(ca);51if (us2b != (byte) 0xF4)52throw new InternalError("loadUS2B failed: " + us2b + " != " + (byte) 0xF4);5354byte us2bmask255 = loadUS2Bmask255(ca);55if (us2bmask255 != (byte) 0xF4)56throw new InternalError("loadUS2Bmask255 failed: " + us2bmask255 + " != " + (byte) 0xF4);5758byte i2b = loadI2B(ia);59if (i2b != (byte) 0xF4)60throw new InternalError("loadI2B failed: " + i2b + " != " + (byte) 0xF4);6162byte i2bmask255 = loadI2Bmask255(ia);63if (i2bmask255 != (byte) 0xF4)64throw new InternalError("loadI2Bmask255 failed: " + i2bmask255 + " != " + (byte) 0xF4);6566short i2s = loadI2S(ia);67if (i2s != (short) 0xF3F4)68throw new InternalError("loadI2S failed: " + i2s + " != " + (short) 0xF3F4);6970short i2smask255 = loadI2Smask255(ia);71if (i2smask255 != (short) 0xF4)72throw new InternalError("loadI2Smask255 failed: " + i2smask255 + " != " + (short) 0xF4);7374short i2smask65535 = loadI2Smask65535(ia);75if (i2smask65535 != (short) 0xF3F4)76throw new InternalError("loadI2Smask65535 failed: " + i2smask65535 + " != " + (short) 0xF3F4);7778char i2us = loadI2US(ia);79if (i2us != (char) 0xF3F4)80throw new InternalError("loadI2US failed: " + (int) i2us + " != " + (char) 0xF3F4);8182char i2usmask255 = loadI2USmask255(ia);83if (i2usmask255 != (char) 0xF4)84throw new InternalError("loadI2USmask255 failed: " + (int) i2usmask255 + " != " + (char) 0xF4);8586char i2usmask65535 = loadI2USmask65535(ia);87if (i2usmask65535 != (char) 0xF3F4)88throw new InternalError("loadI2USmask65535 failed: " + (int) i2usmask65535 + " != " + (char) 0xF3F4);89}9091static byte loadS2B (short[] sa) { return (byte) (sa[0] ); }92static byte loadS2Bmask255 (short[] sa) { return (byte) (sa[0] & 0xFF ); }9394static byte loadUS2B (char[] ca) { return (byte) (ca[0] ); }95static byte loadUS2Bmask255 (char[] ca) { return (byte) (ca[0] & 0xFF ); }9697static byte loadI2B (int[] ia) { return (byte) (ia[0] ); }98static byte loadI2Bmask255 (int[] ia) { return (byte) (ia[0] & 0xFF ); }99100static short loadI2S (int[] ia) { return (short) (ia[0] ); }101static short loadI2Smask255 (int[] ia) { return (short) (ia[0] & 0xFF ); }102static short loadI2Smask65535 (int[] ia) { return (short) (ia[0] & 0xFFFF); }103104static char loadI2US (int[] ia) { return (char) (ia[0] ); }105static char loadI2USmask255 (int[] ia) { return (char) (ia[0] & 0xFF ); }106static char loadI2USmask65535(int[] ia) { return (char) (ia[0] & 0xFFFF); }107}108109110