Path: blob/master/test/hotspot/jtreg/compiler/codegen/Test6378821.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 637882126* @summary where available, bitCount() should use POPC on SPARC processors and AMD+10h27*28* @run main/othervm -Xcomp29* -XX:CompileCommand=compileonly,compiler.codegen.Test6378821::fcomp30* compiler.codegen.Test637882131*/3233package compiler.codegen;3435public class Test6378821 {36static final int[] ia = new int[] { 0x12345678 };37static final long[] la = new long[] { 0x12345678abcdefL };3839public static void main(String [] args) {40// Resolve the class and the method.41Integer.bitCount(1);42Long.bitCount(1);4344sub(ia[0]);45sub(la[0]);46sub(ia);47sub(la);48}4950static void check(int i, int expected, int result) {51if (result != expected) {52throw new InternalError("Wrong population count for " + i + ": " + result + " != " + expected);53}54}5556static void check(long l, int expected, int result) {57if (result != expected) {58throw new InternalError("Wrong population count for " + l + ": " + result + " != " + expected);59}60}6162static void sub(int i) { check(i, fint(i), fcomp(i) ); }63static void sub(int[] ia) { check(ia[0], fint(ia), fcomp(ia)); }64static void sub(long l) { check(l, fint(l), fcomp(l) ); }65static void sub(long[] la) { check(la[0], fint(la), fcomp(la)); }6667static int fint (int i) { return Integer.bitCount(i); }68static int fcomp(int i) { return Integer.bitCount(i); }6970static int fint (int[] ia) { return Integer.bitCount(ia[0]); }71static int fcomp(int[] ia) { return Integer.bitCount(ia[0]); }7273static int fint (long l) { return Long.bitCount(l); }74static int fcomp(long l) { return Long.bitCount(l); }7576static int fint (long[] la) { return Long.bitCount(la[0]); }77static int fcomp(long[] la) { return Long.bitCount(la[0]); }78}798081