Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6378821/Test6378821.java
32285 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 637882126* @summary where available, bitCount() should use POPC on SPARC processors and AMD+10h27*28* @run main/othervm -Xcomp -XX:CompileOnly=Test6378821.fcomp Test637882129*/3031public class Test6378821 {32static final int[] ia = new int[] { 0x12345678 };33static final long[] la = new long[] { 0x12345678abcdefL };3435public static void main(String [] args) {36// Resolve the class and the method.37Integer.bitCount(1);38Long.bitCount(1);3940sub(ia[0]);41sub(la[0]);42sub(ia);43sub(la);44}4546static void check(int i, int expected, int result) {47if (result != expected) {48throw new InternalError("Wrong population count for " + i + ": " + result + " != " + expected);49}50}5152static void check(long l, int expected, int result) {53if (result != expected) {54throw new InternalError("Wrong population count for " + l + ": " + result + " != " + expected);55}56}5758static void sub(int i) { check(i, fint(i), fcomp(i) ); }59static void sub(int[] ia) { check(ia[0], fint(ia), fcomp(ia)); }60static void sub(long l) { check(l, fint(l), fcomp(l) ); }61static void sub(long[] la) { check(la[0], fint(la), fcomp(la)); }6263static int fint (int i) { return Integer.bitCount(i); }64static int fcomp(int i) { return Integer.bitCount(i); }6566static int fint (int[] ia) { return Integer.bitCount(ia[0]); }67static int fcomp(int[] ia) { return Integer.bitCount(ia[0]); }6869static int fint (long l) { return Long.bitCount(l); }70static int fcomp(long l) { return Long.bitCount(l); }7172static int fint (long[] la) { return Long.bitCount(la[0]); }73static int fcomp(long[] la) { return Long.bitCount(la[0]); }74}757677