test/compiler/codegen/BMI1.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

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

mercurial