hotspot/test/compiler/codegen/BMI1.java
author hseigel
Wed, 01 Mar 2017 08:00:02 -0500
changeset 46194 5596e6f63072
parent 40059 c2304140ed64
permissions -rw-r--r--
8172307: Remove ununsed JVM API JVM_GetModuleByPackageName() Summary: Remove get_module_by_package_name() etc., and unneeded test. Reviewed-by: sspitsyn, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     1
/*
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     4
 *
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     8
 *
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    13
 * accompanied this code).
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    14
 *
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    18
 *
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    21
 * questions.
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    22
 */
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    23
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    24
/*
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    25
 * @test
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    26
 * @bug 8031321
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    27
 * @summary Support BMI1 instructions on x86/x64
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    29
 * @run main/othervm -Xbatch -XX:-TieredCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    30
 *      -XX:CompileCommand=compileonly,compiler.codegen.BMI1$BMITests::*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    31
 *      compiler.codegen.BMI1
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    32
 */
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    33
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    34
package compiler.codegen;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    35
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    36
public class BMI1 {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    37
    private final static int ITERATIONS = 1000000;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    38
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    39
    public static void main(String[] args) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    40
        int ix = 0x01234567;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    41
        int iy = 0x89abcdef;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    42
        MemI imy = new MemI(iy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    43
        long lx = 0x0123456701234567L;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    44
        long ly = 0x89abcdef89abcdefL;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    45
        MemL lmy = new MemL(ly);
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    46
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    47
        { // match(Set dst (AndI (XorI src1 minus_1) src2))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    48
            int z = BMITests.andnl(ix, iy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    49
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    50
                int ii = BMITests.andnl(ix, iy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    51
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    52
                    throw new Error("andnl with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    53
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    54
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    55
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    56
        { // match(Set dst (AndL (XorL src1 minus_1) src2))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    57
            long z = BMITests.andnq(lx, ly);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    58
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    59
                long ll = BMITests.andnq(lx, ly);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    60
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    61
                    throw new Error("andnq with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    62
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    63
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    64
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    65
        { // match(Set dst (AndI (XorI src1 minus_1) (LoadI src2)))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    66
            int z = BMITests.andnl(ix, imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    67
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    68
                int ii = BMITests.andnl(ix, imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    69
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    70
                    throw new Error("andnl with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    71
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    72
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    73
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    74
        { // match(Set dst (AndL (XorL src1 minus_1) (LoadL src2)))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    75
            long z = BMITests.andnq(lx, lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    76
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    77
                long ll = BMITests.andnq(lx, lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    78
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    79
                    throw new Error("andnq with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    80
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    81
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    82
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    83
        { // match(Set dst (AndI (SubI imm_zero src) src))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    84
            int z = BMITests.blsil(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    85
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    86
                int ii = BMITests.blsil(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    87
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    88
                    throw new Error("blsil with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    89
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    90
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    91
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    92
        { // match(Set dst (AndL (SubL imm_zero src) src))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    93
            long z = BMITests.blsiq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    94
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    95
                long ll = BMITests.blsiq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    96
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    97
                    throw new Error("blsiq with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    98
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
    99
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   100
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   101
        { // match(Set dst (AndI (SubI imm_zero (LoadI src) ) (LoadI src) ))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   102
            int z = BMITests.blsil(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   103
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   104
                int ii = BMITests.blsil(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   105
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   106
                    throw new Error("blsil with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   107
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   108
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   109
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   110
        { // match(Set dst (AndL (SubL imm_zero (LoadL src) ) (LoadL src) ))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   111
            long z = BMITests.blsiq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   112
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   113
                long ll = BMITests.blsiq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   114
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   115
                    throw new Error("blsiq with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   116
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   117
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   118
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   119
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   120
        { // match(Set dst (XorI (AddI src minus_1) src))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   121
            int z = BMITests.blsmskl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   122
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   123
                int ii = BMITests.blsmskl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   124
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   125
                    throw new Error("blsmskl with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   126
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   127
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   128
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   129
        { // match(Set dst (XorL (AddL src minus_1) src))
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   130
            long z = BMITests.blsmskq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   131
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   132
                long ll = BMITests.blsmskq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   133
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   134
                    throw new Error("blsmskq with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   135
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   136
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   137
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   138
        { // match(Set dst (XorI (AddI (LoadI src) minus_1) (LoadI src) ) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   139
            int z = BMITests.blsmskl(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   140
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   141
                int ii = BMITests.blsmskl(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   142
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   143
                    throw new Error("blsmskl with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   144
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   145
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   146
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   147
        {  // match(Set dst (XorL (AddL (LoadL src) minus_1) (LoadL src) ) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   148
            long z = BMITests.blsmskq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   149
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   150
                long ll = BMITests.blsmskq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   151
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   152
                    throw new Error("blsmskq with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   153
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   154
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   155
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   156
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   157
        { //  match(Set dst (AndI (AddI src minus_1) src) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   158
            int z = BMITests.blsrl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   159
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   160
                int ii = BMITests.blsrl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   161
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   162
                    throw new Error("blsrl with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   163
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   164
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   165
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   166
        { // match(Set dst (AndL (AddL src minus_1) src) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   167
            long z = BMITests.blsrq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   168
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   169
                long ll = BMITests.blsrq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   170
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   171
                    throw new Error("blsrq with register failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   172
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   173
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   174
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   175
        { // match(Set dst (AndI (AddI (LoadI src) minus_1) (LoadI src) ) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   176
            int z = BMITests.blsrl(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   177
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   178
                int ii = BMITests.blsrl(imy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   179
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   180
                    throw new Error("blsrl with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   181
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   182
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   183
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   184
        { // match(Set dst (AndL (AddL (LoadL src) minus_1) (LoadL src)) )
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   185
            long z = BMITests.blsrq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   186
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   187
                long ll = BMITests.blsrq(lmy);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   188
                if (ll != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   189
                    throw new Error("blsrq with memory failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   190
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   191
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   192
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   193
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   194
        {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   195
            int z = BMITests.lzcntl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   196
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   197
                int ii = BMITests.lzcntl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   198
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   199
                    throw new Error("lzcntl failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   200
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   201
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   202
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   203
        {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   204
            int z = BMITests.lzcntq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   205
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   206
                int ii = BMITests.lzcntq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   207
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   208
                    throw new Error("lzcntq failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   209
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   210
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   211
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   212
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   213
        {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   214
            int z = BMITests.tzcntl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   215
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   216
                int ii = BMITests.tzcntl(ix);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   217
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   218
                    throw new Error("tzcntl failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   219
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   220
            }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   221
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   222
        {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   223
            int z = BMITests.tzcntq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   224
            for (int i = 0; i < ITERATIONS; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   225
                int ii = BMITests.tzcntq(lx);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   226
                if (ii != z) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   227
                    throw new Error("tzcntq failed");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   228
                }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   229
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   230
        }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   231
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   232
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   233
    static class MemI {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   234
        public int x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   235
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   236
        public MemI(int x) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   237
            this.x = x;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   238
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   239
    }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   240
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   241
    static class MemL {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   242
        public long x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   243
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   244
        public MemL(long x) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   245
            this.x = x;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   246
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   247
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   248
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   249
    static class BMITests {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   250
        static int andnl(int src1, int src2) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   251
            return ~src1 & src2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   252
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   253
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   254
        static long andnq(long src1, long src2) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   255
            return ~src1 & src2;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   256
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   257
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   258
        static int andnl(int src1, MemI src2) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   259
            return ~src1 & src2.x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   260
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   261
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   262
        static long andnq(long src1, MemL src2) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   263
            return ~src1 & src2.x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   264
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   265
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   266
        static int blsil(int src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   267
            return src1 & -src1;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   268
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   269
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   270
        static long blsiq(long src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   271
            return src1 & -src1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   272
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   273
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   274
        static int blsil(MemI src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   275
            return src1.x & -src1.x;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   276
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   277
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   278
        static long blsiq(MemL src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   279
            return src1.x & -src1.x;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   280
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   281
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   282
        static int blsmskl(int src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   283
            return (src1 - 1) ^ src1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   284
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   285
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   286
        static long blsmskq(long src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   287
            return (src1 - 1) ^ src1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   288
        }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   289
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   290
        static int blsmskl(MemI src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   291
            return (src1.x - 1) ^ src1.x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   292
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   293
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   294
        static long blsmskq(MemL src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   295
            return (src1.x - 1) ^ src1.x;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   296
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   297
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   298
        static int blsrl(int src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   299
            return (src1 - 1) & src1;
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   300
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   301
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   302
        static long blsrq(long src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   303
            return (src1 - 1) & src1;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   304
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   305
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   306
        static int blsrl(MemI src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   307
            return (src1.x - 1) & src1.x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   308
        }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   309
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   310
        static long blsrq(MemL src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   311
            return (src1.x - 1) & src1.x;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   312
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   313
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   314
        static int lzcntl(int src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   315
            return Integer.numberOfLeadingZeros(src1);
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   316
        }
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   317
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   318
        static int lzcntq(long src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   319
            return Long.numberOfLeadingZeros(src1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   320
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   321
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   322
        static int tzcntl(int src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   323
            return Integer.numberOfTrailingZeros(src1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   324
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   325
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   326
        static int tzcntq(long src1) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   327
            return Long.numberOfTrailingZeros(src1);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23220
diff changeset
   328
        }
23220
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   329
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   330
}