Path: blob/master/test/hotspot/jtreg/compiler/intrinsics/bmi/TestAndnI.java
41155 views
/*1* Copyright (c) 2014, 2021, 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* @key randomness26* @bug 803132127* @summary Verify that results of computations are the same w/28* and w/o usage of ANDN instruction29* @library /test/lib /30* @modules java.base/jdk.internal.misc31* java.management32* @build sun.hotspot.WhiteBox33* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox34* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions35* -XX:+WhiteBoxAPI compiler.intrinsics.bmi.TestAndnI36*/3738package compiler.intrinsics.bmi;3940import sun.hotspot.cpuinfo.CPUInfo;4142public class TestAndnI {4344public static void main(String args[]) throws Throwable {45if (!CPUInfo.hasFeature("bmi1")) {46System.out.println("INFO: CPU does not support bmi1 feature.");47}4849BMITestRunner.runTests(AndnIExpr.class, args,50"-XX:+IgnoreUnrecognizedVMOptions",51"-XX:+UseBMI1Instructions");52BMITestRunner.runTests(AndnICommutativeExpr.class, args,53"-XX:+IgnoreUnrecognizedVMOptions",54"-XX:+UseBMI1Instructions");55}5657public static class AndnIExpr extends Expr.BMIBinaryIntExpr {5859public int intExpr(int src1, int src2) {60return ~src1 & src2;61}6263public int intExpr(int src1, Expr.MemI src2) {64if (src2 != null) {65return ~src1 & src2.value;66} else {67return 0;68}69}7071public int intExpr(Expr.MemI src1, int src2) {72if (src1 != null) {73return ~src1.value & src2;74} else {75return 0;76}77}7879public int intExpr(Expr.MemI src1, Expr.MemI src2) {80if (src1 != null && src2 != null) {81return ~src1.value & src2.value;82} else {83return 0;84}85}86}8788public static class AndnICommutativeExpr extends Expr.BMIBinaryIntExpr {8990public int intExpr(int src1, int src2) {91return src1 & ~src2;92}9394public int intExpr(int src1, Expr.MemI src2) {95if (src2 != null) {96return src1 & ~src2.value;97} else {98return 0;99}100}101102public int intExpr(Expr.MemI src1, int src2) {103if (src1 != null) {104return src1.value & ~src2;105} else {106return 0;107}108}109110public int intExpr(Expr.MemI src1, Expr.MemI src2) {111if (src1 != null && src2 != null) {112return src1.value & ~src2.value;113} else {114return 0;115}116}117}118}119120121