hotspot/test/compiler/codegen/BMI1.java
author iveresov
Wed, 12 Mar 2014 11:24:26 -0700
changeset 23220 fc827339dc37
child 40059 c2304140ed64
permissions -rw-r--r--
8031321: Support Intel bit manipulation instructions Summary: Add support for BMI1 instructions Reviewed-by: kvn, roland
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
 * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:CompileCommand=compileonly,BMITests.* BMI1
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    29
 *
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    30
 */
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    31
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    32
class MemI {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    33
  public int x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    34
  public MemI(int x) { this.x = x; }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    35
}
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    36
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    37
class MemL {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    38
  public long x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    39
  public MemL(long x) { this.x = x; }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    40
}
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    41
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    42
class BMITests {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    43
  static int andnl(int src1, int src2) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    44
    return ~src1 & src2;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    45
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    46
  static long andnq(long src1, long src2) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    47
    return ~src1 & src2;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    48
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    49
  static int andnl(int src1, MemI src2) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    50
    return ~src1 & src2.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    51
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    52
  static long andnq(long src1, MemL src2) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    53
    return ~src1 & src2.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    54
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    55
  static int blsil(int src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    56
    return src1 & -src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    57
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    58
  static long blsiq(long src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    59
    return src1 & -src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    60
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    61
  static int blsil(MemI src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    62
    return src1.x & -src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    63
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    64
  static long blsiq(MemL src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    65
    return src1.x & -src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    66
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    67
  static int blsmskl(int src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    68
    return (src1 - 1) ^ src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    69
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    70
  static long blsmskq(long src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    71
    return (src1 - 1) ^ src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    72
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    73
  static int blsmskl(MemI src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    74
    return (src1.x - 1) ^ src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    75
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    76
  static long blsmskq(MemL src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    77
    return (src1.x - 1) ^ src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    78
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    79
  static int blsrl(int src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    80
    return (src1 - 1) & src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    81
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    82
  static long blsrq(long src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    83
    return (src1 - 1) & src1;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    84
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    85
  static int blsrl(MemI src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    86
    return (src1.x - 1) & src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    87
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    88
  static long blsrq(MemL src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    89
    return (src1.x - 1) & src1.x;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    90
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    91
  static int lzcntl(int src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    92
    return Integer.numberOfLeadingZeros(src1);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    93
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    94
  static int lzcntq(long src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    95
    return Long.numberOfLeadingZeros(src1);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    96
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    97
  static int tzcntl(int src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    98
    return Integer.numberOfTrailingZeros(src1);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
    99
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   100
  static int tzcntq(long src1) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   101
    return Long.numberOfTrailingZeros(src1);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   102
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   103
}
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   104
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   105
public class BMI1 {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   106
  private final static int ITERATIONS = 1000000;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   107
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   108
  public static void main(String[] args) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   109
    int ix = 0x01234567;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   110
    int iy = 0x89abcdef;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   111
    MemI imy = new MemI(iy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   112
    long lx = 0x0123456701234567L;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   113
    long ly = 0x89abcdef89abcdefL;
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   114
    MemL lmy = new MemL(ly);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   115
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   116
    { // match(Set dst (AndI (XorI src1 minus_1) src2))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   117
      int z = BMITests.andnl(ix, iy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   118
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   119
        int ii = BMITests.andnl(ix, iy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   120
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   121
          throw new Error("andnl with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   122
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   123
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   124
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   125
    { // match(Set dst (AndL (XorL src1 minus_1) src2))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   126
      long z = BMITests.andnq(lx, ly);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   127
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   128
        long ll = BMITests.andnq(lx, ly);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   129
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   130
          throw new Error("andnq with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   131
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   132
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   133
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   134
    { // match(Set dst (AndI (XorI src1 minus_1) (LoadI src2)))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   135
      int z = BMITests.andnl(ix, imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   136
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   137
        int ii = BMITests.andnl(ix, imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   138
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   139
          throw new Error("andnl with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   140
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   141
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   142
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   143
    { // match(Set dst (AndL (XorL src1 minus_1) (LoadL src2)))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   144
      long z = BMITests.andnq(lx, lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   145
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   146
        long ll = BMITests.andnq(lx, lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   147
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   148
          throw new Error("andnq with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   149
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   150
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   151
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   152
    { // match(Set dst (AndI (SubI imm_zero src) src))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   153
      int z = BMITests.blsil(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   154
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   155
        int ii = BMITests.blsil(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   156
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   157
          throw new Error("blsil with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   158
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   159
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   160
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   161
    { // match(Set dst (AndL (SubL imm_zero src) src))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   162
      long z = BMITests.blsiq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   163
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   164
        long ll = BMITests.blsiq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   165
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   166
          throw new Error("blsiq with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   167
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   168
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   169
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   170
    { // match(Set dst (AndI (SubI imm_zero (LoadI src) ) (LoadI src) ))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   171
      int z = BMITests.blsil(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   172
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   173
        int ii = BMITests.blsil(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   174
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   175
          throw new Error("blsil with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   176
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   177
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   178
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   179
    { // match(Set dst (AndL (SubL imm_zero (LoadL src) ) (LoadL src) ))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   180
      long z = BMITests.blsiq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   181
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   182
        long ll = BMITests.blsiq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   183
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   184
          throw new Error("blsiq with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   185
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   186
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   187
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   188
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   189
    { // match(Set dst (XorI (AddI src minus_1) src))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   190
      int z = BMITests.blsmskl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   191
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   192
        int ii = BMITests.blsmskl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   193
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   194
          throw new Error("blsmskl with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   195
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   196
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   197
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   198
    { // match(Set dst (XorL (AddL src minus_1) src))
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   199
      long z = BMITests.blsmskq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   200
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   201
        long ll = BMITests.blsmskq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   202
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   203
          throw new Error("blsmskq with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   204
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   205
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   206
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   207
    { // match(Set dst (XorI (AddI (LoadI src) minus_1) (LoadI src) ) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   208
      int z = BMITests.blsmskl(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   209
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   210
        int ii = BMITests.blsmskl(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   211
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   212
          throw new Error("blsmskl with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   213
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   214
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   215
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   216
    {  // match(Set dst (XorL (AddL (LoadL src) minus_1) (LoadL src) ) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   217
      long z = BMITests.blsmskq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   218
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   219
        long ll = BMITests.blsmskq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   220
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   221
          throw new Error("blsmskq with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   222
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   223
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   224
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   225
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   226
    { //  match(Set dst (AndI (AddI src minus_1) src) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   227
      int z = BMITests.blsrl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   228
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   229
        int ii = BMITests.blsrl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   230
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   231
          throw new Error("blsrl with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   232
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   233
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   234
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   235
    { // match(Set dst (AndL (AddL src minus_1) src) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   236
      long z = BMITests.blsrq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   237
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   238
        long ll = BMITests.blsrq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   239
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   240
          throw new Error("blsrq with register failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   241
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   242
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   243
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   244
    { // match(Set dst (AndI (AddI (LoadI src) minus_1) (LoadI src) ) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   245
      int z = BMITests.blsrl(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   246
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   247
        int ii = BMITests.blsrl(imy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   248
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   249
          throw new Error("blsrl with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   250
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   251
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   252
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   253
    { // match(Set dst (AndL (AddL (LoadL src) minus_1) (LoadL src)) )
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   254
      long z = BMITests.blsrq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   255
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   256
        long ll = BMITests.blsrq(lmy);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   257
        if (ll != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   258
          throw new Error("blsrq with memory failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   259
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   260
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   261
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   262
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   263
    {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   264
      int z = BMITests.lzcntl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   265
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   266
        int ii = BMITests.lzcntl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   267
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   268
          throw new Error("lzcntl failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   269
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   270
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   271
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   272
    {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   273
      int z = BMITests.lzcntq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   274
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   275
        int ii = BMITests.lzcntq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   276
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   277
          throw new Error("lzcntq failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   278
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   279
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   280
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   281
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   282
    {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   283
      int z = BMITests.tzcntl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   284
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   285
        int ii = BMITests.tzcntl(ix);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   286
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   287
          throw new Error("tzcntl failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   288
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   289
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   290
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   291
    {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   292
      int z = BMITests.tzcntq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   293
      for (int i = 0; i < ITERATIONS; i++) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   294
        int ii = BMITests.tzcntq(lx);
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   295
        if (ii != z) {
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   296
          throw new Error("tzcntq failed");
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   297
        }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   298
      }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   299
    }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   300
  }
fc827339dc37 8031321: Support Intel bit manipulation instructions
iveresov
parents:
diff changeset
   301
}