hotspot/test/compiler/intrinsics/bmi/TestAndnI.java
author stsmirno
Mon, 17 Oct 2016 18:54:12 -0400
changeset 41705 332239c052cc
parent 40631 ed82623d7831
permissions -rw-r--r--
8165687: Fix license and copyright headers in jd9 under hotspot/test Summary: Legal notices and Oracle copyrights were updated (white and blank space, commas) in tests files for uniformity to meet Oracle requirements. Reviewed-by: dholmes, iris Contributed-by: Stanislav Smirnov <stanislav.smirnov@oracle.com>, Vassili Igouchkine <vassili.igouchkine@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     4
 *
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     8
 *
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    14
 *
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    18
 *
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    21
 * questions.
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    22
 */
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    23
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    24
/**
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    25
 * @test
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    26
 * @bug 8031321
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    27
 * @summary Verify that results of computations are the same w/
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    28
 *          and w/o usage of ANDN instruction
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    29
 * @library /test/lib /
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 34199
diff changeset
    30
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28190
diff changeset
    31
 *          java.management
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    32
 * @build sun.hotspot.WhiteBox
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 36851
diff changeset
    33
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
25958
8dc85547d6d6 8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents: 23493
diff changeset
    34
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    35
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
    36
 *                   -XX:+WhiteBoxAPI compiler.intrinsics.bmi.TestAndnI
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    37
 */
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    38
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
    39
package compiler.intrinsics.bmi;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
    40
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    41
import sun.hotspot.cpuinfo.CPUInfo;
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    42
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    43
public class TestAndnI {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    44
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    45
    public static void main(String args[]) throws Throwable {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    46
        if (!CPUInfo.hasFeature("bmi1")) {
27425
8689c0c3824a 8043674: Update compiler/intrinsic/bmi tests to run it on all platforms
fzhinkin
parents: 25958
diff changeset
    47
            System.out.println("INFO: CPU does not support bmi1 feature.");
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    48
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    49
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    50
        BMITestRunner.runTests(AndnIExpr.class, args,
27425
8689c0c3824a 8043674: Update compiler/intrinsic/bmi tests to run it on all platforms
fzhinkin
parents: 25958
diff changeset
    51
                               "-XX:+IgnoreUnrecognizedVMOptions",
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    52
                               "-XX:+UseBMI1Instructions");
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    53
        BMITestRunner.runTests(AndnICommutativeExpr.class, args,
27425
8689c0c3824a 8043674: Update compiler/intrinsic/bmi tests to run it on all platforms
fzhinkin
parents: 25958
diff changeset
    54
                               "-XX:+IgnoreUnrecognizedVMOptions",
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    55
                               "-XX:+UseBMI1Instructions");
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    56
    }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    57
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    58
    public static class AndnIExpr extends Expr.BMIBinaryIntExpr {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    59
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    60
        public int intExpr(int src1, int src2) {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    61
            return ~src1 & src2;
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    62
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    63
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    64
        public int intExpr(int src1, Expr.MemI src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    65
            if (src2 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    66
                return ~src1 & src2.value;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    67
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    68
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    69
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    70
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    71
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    72
        public int intExpr(Expr.MemI src1, int src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    73
            if (src1 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    74
                return ~src1.value & src2;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    75
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    76
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    77
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    78
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    79
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    80
        public int intExpr(Expr.MemI src1, Expr.MemI src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    81
            if (src1 != null && src2 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    82
                return ~src1.value & src2.value;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    83
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    84
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    85
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    86
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    87
    }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    88
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    89
    public static class AndnICommutativeExpr extends Expr.BMIBinaryIntExpr {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    90
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    91
        public int intExpr(int src1, int src2) {
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    92
            return src1 & ~src2;
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    93
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    94
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
    95
        public int intExpr(int src1, Expr.MemI src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    96
            if (src2 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    97
                return src1 & ~src2.value;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    98
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
    99
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   100
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   101
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   102
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   103
        public int intExpr(Expr.MemI src1, int src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   104
            if (src1 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   105
                return src1.value & ~src2;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   106
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   107
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   108
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   109
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   110
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   111
        public int intExpr(Expr.MemI src1, Expr.MemI src2) {
34199
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   112
            if (src1 != null && src2 != null) {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   113
                return src1.value & ~src2.value;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   114
            } else {
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   115
                return 0;
ae7dbc401221 8134579: [TESTBUG] Some bmi tests fail if can_access_local_variables is on.
goetz
parents: 33730
diff changeset
   116
            }
23493
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   117
        }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   118
    }
170c77c1103a 8035857: Add tests to verify correctness of operations with BMI1 and LZCNT instructions
iignatyev
parents:
diff changeset
   119
}