1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 
  27 import java.nio.ByteBuffer;
  28 import java.nio.ByteOrder;
  29 import java.nio.ReadOnlyBufferException;
  30 import java.util.Arrays;
  31 import java.util.Objects;
  32 import java.util.function.IntUnaryOperator;
  33 
  34 import jdk.internal.misc.Unsafe;
  35 import jdk.internal.vm.annotation.ForceInline;
  36 import static jdk.incubator.vector.VectorIntrinsics.*;
  37 
  38 @SuppressWarnings("cast")
  39 final class Byte64Vector extends ByteVector {
  40     static final Byte64Species SPECIES = new Byte64Species();
  41 
  42     static final Byte64Vector ZERO = new Byte64Vector();
  43 
  44     static final int LENGTH = SPECIES.length();
  45 
  46     private final byte[] vec; // Don't access directly, use getElements() instead.
  47 
  48     private byte[] getElements() {
  49         return VectorIntrinsics.maybeRebox(this).vec;
  50     }
  51 
  52     Byte64Vector() {
  53         vec = new byte[SPECIES.length()];
  54     }
  55 
  56     Byte64Vector(byte[] v) {
  57         vec = v;
  58     }
  59 
  60     @Override
  61     public int length() { return LENGTH; }
  62 
  63     // Unary operator
  64 
  65     @Override
  66     Byte64Vector uOp(FUnOp f) {
  67         byte[] vec = getElements();
  68         byte[] res = new byte[length()];
  69         for (int i = 0; i < length(); i++) {
  70             res[i] = f.apply(i, vec[i]);
  71         }
  72         return new Byte64Vector(res);
  73     }
  74 
  75     @Override
  76     Byte64Vector uOp(Mask<Byte> o, FUnOp f) {
  77         byte[] vec = getElements();
  78         byte[] res = new byte[length()];
  79         boolean[] mbits = ((Byte64Mask)o).getBits();
  80         for (int i = 0; i < length(); i++) {
  81             res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i];
  82         }
  83         return new Byte64Vector(res);
  84     }
  85 
  86     // Binary operator
  87 
  88     @Override
  89     Byte64Vector bOp(Vector<Byte> o, FBinOp f) {
  90         byte[] res = new byte[length()];
  91         byte[] vec1 = this.getElements();
  92         byte[] vec2 = ((Byte64Vector)o).getElements();
  93         for (int i = 0; i < length(); i++) {
  94             res[i] = f.apply(i, vec1[i], vec2[i]);
  95         }
  96         return new Byte64Vector(res);
  97     }
  98 
  99     @Override
 100     Byte64Vector bOp(Vector<Byte> o1, Mask<Byte> o2, FBinOp f) {
 101         byte[] res = new byte[length()];
 102         byte[] vec1 = this.getElements();
 103         byte[] vec2 = ((Byte64Vector)o1).getElements();
 104         boolean[] mbits = ((Byte64Mask)o2).getBits();
 105         for (int i = 0; i < length(); i++) {
 106             res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i];
 107         }
 108         return new Byte64Vector(res);
 109     }
 110 
 111     // Trinary operator
 112 
 113     @Override
 114     Byte64Vector tOp(Vector<Byte> o1, Vector<Byte> o2, FTriOp f) {
 115         byte[] res = new byte[length()];
 116         byte[] vec1 = this.getElements();
 117         byte[] vec2 = ((Byte64Vector)o1).getElements();
 118         byte[] vec3 = ((Byte64Vector)o2).getElements();
 119         for (int i = 0; i < length(); i++) {
 120             res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]);
 121         }
 122         return new Byte64Vector(res);
 123     }
 124 
 125     @Override
 126     Byte64Vector tOp(Vector<Byte> o1, Vector<Byte> o2, Mask<Byte> o3, FTriOp f) {
 127         byte[] res = new byte[length()];
 128         byte[] vec1 = getElements();
 129         byte[] vec2 = ((Byte64Vector)o1).getElements();
 130         byte[] vec3 = ((Byte64Vector)o2).getElements();
 131         boolean[] mbits = ((Byte64Mask)o3).getBits();
 132         for (int i = 0; i < length(); i++) {
 133             res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i];
 134         }
 135         return new Byte64Vector(res);
 136     }
 137 
 138     @Override
 139     byte rOp(byte v, FBinOp f) {
 140         byte[] vec = getElements();
 141         for (int i = 0; i < length(); i++) {
 142             v = f.apply(i, v, vec[i]);
 143         }
 144         return v;
 145     }
 146 
 147     @Override
 148     @ForceInline
 149     public <F> Vector<F> cast(Species<F> s) {
 150         Objects.requireNonNull(s);
 151         if (s.length() != LENGTH)
 152             throw new IllegalArgumentException("Vector length this species length differ");
 153 
 154         return VectorIntrinsics.cast(
 155             Byte64Vector.class,
 156             byte.class, LENGTH,
 157             s.vectorType(),
 158             s.elementType(), LENGTH,
 159             this, s,
 160             (species, vector) -> vector.castDefault(species)
 161         );
 162     }
 163 
 164     @SuppressWarnings("unchecked")
 165     @ForceInline
 166     private <F> Vector<F> castDefault(Species<F> s) {
 167         int limit = s.length();
 168 
 169         Class<?> stype = s.elementType();
 170         if (stype == byte.class) {
 171             byte[] a = new byte[limit];
 172             for (int i = 0; i < limit; i++) {
 173                 a[i] = (byte) this.get(i);
 174             }
 175             return (Vector) ByteVector.fromArray((ByteVector.ByteSpecies) s, a, 0);
 176         } else if (stype == short.class) {
 177             short[] a = new short[limit];
 178             for (int i = 0; i < limit; i++) {
 179                 a[i] = (short) this.get(i);
 180             }
 181             return (Vector) ShortVector.fromArray((ShortVector.ShortSpecies) s, a, 0);
 182         } else if (stype == int.class) {
 183             int[] a = new int[limit];
 184             for (int i = 0; i < limit; i++) {
 185                 a[i] = (int) this.get(i);
 186             }
 187             return (Vector) IntVector.fromArray((IntVector.IntSpecies) s, a, 0);
 188         } else if (stype == long.class) {
 189             long[] a = new long[limit];
 190             for (int i = 0; i < limit; i++) {
 191                 a[i] = (long) this.get(i);
 192             }
 193             return (Vector) LongVector.fromArray((LongVector.LongSpecies) s, a, 0);
 194         } else if (stype == float.class) {
 195             float[] a = new float[limit];
 196             for (int i = 0; i < limit; i++) {
 197                 a[i] = (float) this.get(i);
 198             }
 199             return (Vector) FloatVector.fromArray((FloatVector.FloatSpecies) s, a, 0);
 200         } else if (stype == double.class) {
 201             double[] a = new double[limit];
 202             for (int i = 0; i < limit; i++) {
 203                 a[i] = (double) this.get(i);
 204             }
 205             return (Vector) DoubleVector.fromArray((DoubleVector.DoubleSpecies) s, a, 0);
 206         } else {
 207             throw new UnsupportedOperationException("Bad lane type for casting.");
 208         }
 209     }
 210 
 211     @Override
 212     @ForceInline
 213     @SuppressWarnings("unchecked")
 214     public <F> Vector<F> reinterpret(Species<F> s) {
 215         Objects.requireNonNull(s);
 216 
 217         if(s.elementType().equals(byte.class)) {
 218             return (Vector<F>) reshape((Species<Byte>)s);
 219         }
 220         if(s.bitSize() == bitSize()) {
 221             return reinterpretType(s);
 222         }
 223 
 224         return defaultReinterpret(s);
 225     }
 226 
 227     @ForceInline
 228     private <F> Vector<F> reinterpretType(Species<F> s) {
 229         Objects.requireNonNull(s);
 230 
 231         Class<?> stype = s.elementType();
 232         if (stype == byte.class) {
 233             return VectorIntrinsics.reinterpret(
 234                 Byte64Vector.class,
 235                 byte.class, LENGTH,
 236                 Byte64Vector.class,
 237                 byte.class, Byte64Vector.LENGTH,
 238                 this, s,
 239                 (species, vector) -> vector.defaultReinterpret(species)
 240             );
 241         } else if (stype == short.class) {
 242             return VectorIntrinsics.reinterpret(
 243                 Byte64Vector.class,
 244                 byte.class, LENGTH,
 245                 Short64Vector.class,
 246                 short.class, Short64Vector.LENGTH,
 247                 this, s,
 248                 (species, vector) -> vector.defaultReinterpret(species)
 249             );
 250         } else if (stype == int.class) {
 251             return VectorIntrinsics.reinterpret(
 252                 Byte64Vector.class,
 253                 byte.class, LENGTH,
 254                 Int64Vector.class,
 255                 int.class, Int64Vector.LENGTH,
 256                 this, s,
 257                 (species, vector) -> vector.defaultReinterpret(species)
 258             );
 259         } else if (stype == long.class) {
 260             return VectorIntrinsics.reinterpret(
 261                 Byte64Vector.class,
 262                 byte.class, LENGTH,
 263                 Long64Vector.class,
 264                 long.class, Long64Vector.LENGTH,
 265                 this, s,
 266                 (species, vector) -> vector.defaultReinterpret(species)
 267             );
 268         } else if (stype == float.class) {
 269             return VectorIntrinsics.reinterpret(
 270                 Byte64Vector.class,
 271                 byte.class, LENGTH,
 272                 Float64Vector.class,
 273                 float.class, Float64Vector.LENGTH,
 274                 this, s,
 275                 (species, vector) -> vector.defaultReinterpret(species)
 276             );
 277         } else if (stype == double.class) {
 278             return VectorIntrinsics.reinterpret(
 279                 Byte64Vector.class,
 280                 byte.class, LENGTH,
 281                 Double64Vector.class,
 282                 double.class, Double64Vector.LENGTH,
 283                 this, s,
 284                 (species, vector) -> vector.defaultReinterpret(species)
 285             );
 286         } else {
 287             throw new UnsupportedOperationException("Bad lane type for casting.");
 288         }
 289     }
 290 
 291     @Override
 292     @ForceInline
 293     public ByteVector reshape(Species<Byte> s) {
 294         Objects.requireNonNull(s);
 295         if (s.bitSize() == 64 && (s instanceof Byte64Vector.Byte64Species)) {
 296             Byte64Vector.Byte64Species ts = (Byte64Vector.Byte64Species)s;
 297             return VectorIntrinsics.reinterpret(
 298                 Byte64Vector.class,
 299                 byte.class, LENGTH,
 300                 Byte64Vector.class,
 301                 byte.class, Byte64Vector.LENGTH,
 302                 this, ts,
 303                 (species, vector) -> (ByteVector) vector.defaultReinterpret(species)
 304             );
 305         } else if (s.bitSize() == 128 && (s instanceof Byte128Vector.Byte128Species)) {
 306             Byte128Vector.Byte128Species ts = (Byte128Vector.Byte128Species)s;
 307             return VectorIntrinsics.reinterpret(
 308                 Byte64Vector.class,
 309                 byte.class, LENGTH,
 310                 Byte128Vector.class,
 311                 byte.class, Byte128Vector.LENGTH,
 312                 this, ts,
 313                 (species, vector) -> (ByteVector) vector.defaultReinterpret(species)
 314             );
 315         } else if (s.bitSize() == 256 && (s instanceof Byte256Vector.Byte256Species)) {
 316             Byte256Vector.Byte256Species ts = (Byte256Vector.Byte256Species)s;
 317             return VectorIntrinsics.reinterpret(
 318                 Byte64Vector.class,
 319                 byte.class, LENGTH,
 320                 Byte256Vector.class,
 321                 byte.class, Byte256Vector.LENGTH,
 322                 this, ts,
 323                 (species, vector) -> (ByteVector) vector.defaultReinterpret(species)
 324             );
 325         } else if (s.bitSize() == 512 && (s instanceof Byte512Vector.Byte512Species)) {
 326             Byte512Vector.Byte512Species ts = (Byte512Vector.Byte512Species)s;
 327             return VectorIntrinsics.reinterpret(
 328                 Byte64Vector.class,
 329                 byte.class, LENGTH,
 330                 Byte512Vector.class,
 331                 byte.class, Byte512Vector.LENGTH,
 332                 this, ts,
 333                 (species, vector) -> (ByteVector) vector.defaultReinterpret(species)
 334             );
 335         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 336                 && (s.bitSize() % 128 == 0) && (s instanceof ByteMaxVector.ByteMaxSpecies)) {
 337             ByteMaxVector.ByteMaxSpecies ts = (ByteMaxVector.ByteMaxSpecies)s;
 338             return VectorIntrinsics.reinterpret(
 339                 Byte64Vector.class,
 340                 byte.class, LENGTH,
 341                 ByteMaxVector.class,
 342                 byte.class, ByteMaxVector.LENGTH,
 343                 this, ts,
 344                 (species, vector) -> (ByteVector) vector.defaultReinterpret(species)
 345             );
 346         } else {
 347             throw new InternalError("Unimplemented size");
 348         }
 349     }
 350 
 351     // Binary operations with scalars
 352 
 353     @Override
 354     @ForceInline
 355     public ByteVector add(byte o) {
 356         return add(SPECIES.broadcast(o));
 357     }
 358 
 359     @Override
 360     @ForceInline
 361     public ByteVector add(byte o, Mask<Byte> m) {
 362         return add(SPECIES.broadcast(o), m);
 363     }
 364 
 365     @Override
 366     @ForceInline
 367     public ByteVector sub(byte o) {
 368         return sub(SPECIES.broadcast(o));
 369     }
 370 
 371     @Override
 372     @ForceInline
 373     public ByteVector sub(byte o, Mask<Byte> m) {
 374         return sub(SPECIES.broadcast(o), m);
 375     }
 376 
 377     @Override
 378     @ForceInline
 379     public ByteVector mul(byte o) {
 380         return mul(SPECIES.broadcast(o));
 381     }
 382 
 383     @Override
 384     @ForceInline
 385     public ByteVector mul(byte o, Mask<Byte> m) {
 386         return mul(SPECIES.broadcast(o), m);
 387     }
 388 
 389     @Override
 390     @ForceInline
 391     public ByteVector min(byte o) {
 392         return min(SPECIES.broadcast(o));
 393     }
 394 
 395     @Override
 396     @ForceInline
 397     public ByteVector max(byte o) {
 398         return max(SPECIES.broadcast(o));
 399     }
 400 
 401     @Override
 402     @ForceInline
 403     public Mask<Byte> equal(byte o) {
 404         return equal(SPECIES.broadcast(o));
 405     }
 406 
 407     @Override
 408     @ForceInline
 409     public Mask<Byte> notEqual(byte o) {
 410         return notEqual(SPECIES.broadcast(o));
 411     }
 412 
 413     @Override
 414     @ForceInline
 415     public Mask<Byte> lessThan(byte o) {
 416         return lessThan(SPECIES.broadcast(o));
 417     }
 418 
 419     @Override
 420     @ForceInline
 421     public Mask<Byte> lessThanEq(byte o) {
 422         return lessThanEq(SPECIES.broadcast(o));
 423     }
 424 
 425     @Override
 426     @ForceInline
 427     public Mask<Byte> greaterThan(byte o) {
 428         return greaterThan(SPECIES.broadcast(o));
 429     }
 430 
 431     @Override
 432     @ForceInline
 433     public Mask<Byte> greaterThanEq(byte o) {
 434         return greaterThanEq(SPECIES.broadcast(o));
 435     }
 436 
 437     @Override
 438     @ForceInline
 439     public ByteVector blend(byte o, Mask<Byte> m) {
 440         return blend(SPECIES.broadcast(o), m);
 441     }
 442 
 443 
 444     @Override
 445     @ForceInline
 446     public ByteVector and(byte o) {
 447         return and(SPECIES.broadcast(o));
 448     }
 449 
 450     @Override
 451     @ForceInline
 452     public ByteVector and(byte o, Mask<Byte> m) {
 453         return and(SPECIES.broadcast(o), m);
 454     }
 455 
 456     @Override
 457     @ForceInline
 458     public ByteVector or(byte o) {
 459         return or(SPECIES.broadcast(o));
 460     }
 461 
 462     @Override
 463     @ForceInline
 464     public ByteVector or(byte o, Mask<Byte> m) {
 465         return or(SPECIES.broadcast(o), m);
 466     }
 467 
 468     @Override
 469     @ForceInline
 470     public ByteVector xor(byte o) {
 471         return xor(SPECIES.broadcast(o));
 472     }
 473 
 474     @Override
 475     @ForceInline
 476     public ByteVector xor(byte o, Mask<Byte> m) {
 477         return xor(SPECIES.broadcast(o), m);
 478     }
 479 
 480     @Override
 481     @ForceInline
 482     public Byte64Vector neg() {
 483         return (Byte64Vector)zero(SPECIES).sub(this);
 484     }
 485 
 486     // Unary operations
 487 
 488     @ForceInline
 489     @Override
 490     public Byte64Vector neg(Mask<Byte> m) {
 491         return blend(neg(), m);
 492     }
 493 
 494     @Override
 495     @ForceInline
 496     public Byte64Vector abs() {
 497         return VectorIntrinsics.unaryOp(
 498             VECTOR_OP_ABS, Byte64Vector.class, byte.class, LENGTH,
 499             this,
 500             v1 -> v1.uOp((i, a) -> (byte) Math.abs(a)));
 501     }
 502 
 503     @ForceInline
 504     @Override
 505     public Byte64Vector abs(Mask<Byte> m) {
 506         return blend(abs(), m);
 507     }
 508 
 509 
 510     @Override
 511     @ForceInline
 512     public Byte64Vector not() {
 513         return VectorIntrinsics.unaryOp(
 514             VECTOR_OP_NOT, Byte64Vector.class, byte.class, LENGTH,
 515             this,
 516             v1 -> v1.uOp((i, a) -> (byte) ~a));
 517     }
 518 
 519     @ForceInline
 520     @Override
 521     public Byte64Vector not(Mask<Byte> m) {
 522         return blend(not(), m);
 523     }
 524     // Binary operations
 525 
 526     @Override
 527     @ForceInline
 528     public Byte64Vector add(Vector<Byte> o) {
 529         Objects.requireNonNull(o);
 530         Byte64Vector v = (Byte64Vector)o;
 531         return VectorIntrinsics.binaryOp(
 532             VECTOR_OP_ADD, Byte64Vector.class, byte.class, LENGTH,
 533             this, v,
 534             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a + b)));
 535     }
 536 
 537     @Override
 538     @ForceInline
 539     public Byte64Vector add(Vector<Byte> v, Mask<Byte> m) {
 540         return blend(add(v), m);
 541     }
 542 
 543     @Override
 544     @ForceInline
 545     public Byte64Vector sub(Vector<Byte> o) {
 546         Objects.requireNonNull(o);
 547         Byte64Vector v = (Byte64Vector)o;
 548         return VectorIntrinsics.binaryOp(
 549             VECTOR_OP_SUB, Byte64Vector.class, byte.class, LENGTH,
 550             this, v,
 551             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a - b)));
 552     }
 553 
 554     @Override
 555     @ForceInline
 556     public Byte64Vector sub(Vector<Byte> v, Mask<Byte> m) {
 557         return blend(sub(v), m);
 558     }
 559 
 560     @Override
 561     @ForceInline
 562     public Byte64Vector mul(Vector<Byte> o) {
 563         Objects.requireNonNull(o);
 564         Byte64Vector v = (Byte64Vector)o;
 565         return VectorIntrinsics.binaryOp(
 566             VECTOR_OP_MUL, Byte64Vector.class, byte.class, LENGTH,
 567             this, v,
 568             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a * b)));
 569     }
 570 
 571     @Override
 572     @ForceInline
 573     public Byte64Vector mul(Vector<Byte> v, Mask<Byte> m) {
 574         return blend(mul(v), m);
 575     }
 576 
 577     @Override
 578     @ForceInline
 579     public Byte64Vector min(Vector<Byte> o) {
 580         Objects.requireNonNull(o);
 581         Byte64Vector v = (Byte64Vector)o;
 582         return (Byte64Vector) VectorIntrinsics.binaryOp(
 583             VECTOR_OP_MIN, Byte64Vector.class, byte.class, LENGTH,
 584             this, v,
 585             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte) Math.min(a, b)));
 586     }
 587 
 588     @Override
 589     @ForceInline
 590     public Byte64Vector min(Vector<Byte> v, Mask<Byte> m) {
 591         return blend(min(v), m);
 592     }
 593 
 594     @Override
 595     @ForceInline
 596     public Byte64Vector max(Vector<Byte> o) {
 597         Objects.requireNonNull(o);
 598         Byte64Vector v = (Byte64Vector)o;
 599         return VectorIntrinsics.binaryOp(
 600             VECTOR_OP_MAX, Byte64Vector.class, byte.class, LENGTH,
 601             this, v,
 602             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte) Math.max(a, b)));
 603         }
 604 
 605     @Override
 606     @ForceInline
 607     public Byte64Vector max(Vector<Byte> v, Mask<Byte> m) {
 608         return blend(max(v), m);
 609     }
 610 
 611     @Override
 612     @ForceInline
 613     public Byte64Vector and(Vector<Byte> o) {
 614         Objects.requireNonNull(o);
 615         Byte64Vector v = (Byte64Vector)o;
 616         return VectorIntrinsics.binaryOp(
 617             VECTOR_OP_AND, Byte64Vector.class, byte.class, LENGTH,
 618             this, v,
 619             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a & b)));
 620     }
 621 
 622     @Override
 623     @ForceInline
 624     public Byte64Vector or(Vector<Byte> o) {
 625         Objects.requireNonNull(o);
 626         Byte64Vector v = (Byte64Vector)o;
 627         return VectorIntrinsics.binaryOp(
 628             VECTOR_OP_OR, Byte64Vector.class, byte.class, LENGTH,
 629             this, v,
 630             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a | b)));
 631     }
 632 
 633     @Override
 634     @ForceInline
 635     public Byte64Vector xor(Vector<Byte> o) {
 636         Objects.requireNonNull(o);
 637         Byte64Vector v = (Byte64Vector)o;
 638         return VectorIntrinsics.binaryOp(
 639             VECTOR_OP_XOR, Byte64Vector.class, byte.class, LENGTH,
 640             this, v,
 641             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (byte)(a ^ b)));
 642     }
 643 
 644     @Override
 645     @ForceInline
 646     public Byte64Vector and(Vector<Byte> v, Mask<Byte> m) {
 647         return blend(and(v), m);
 648     }
 649 
 650     @Override
 651     @ForceInline
 652     public Byte64Vector or(Vector<Byte> v, Mask<Byte> m) {
 653         return blend(or(v), m);
 654     }
 655 
 656     @Override
 657     @ForceInline
 658     public Byte64Vector xor(Vector<Byte> v, Mask<Byte> m) {
 659         return blend(xor(v), m);
 660     }
 661 
 662     @Override
 663     @ForceInline
 664     public Byte64Vector shiftL(int s) {
 665         return VectorIntrinsics.broadcastInt(
 666             VECTOR_OP_LSHIFT, Byte64Vector.class, byte.class, LENGTH,
 667             this, s,
 668             (v, i) -> v.uOp((__, a) -> (byte) (a << (i & 7))));
 669     }
 670 
 671     @Override
 672     @ForceInline
 673     public Byte64Vector shiftL(int s, Mask<Byte> m) {
 674         return blend(shiftL(s), m);
 675     }
 676 
 677     @Override
 678     @ForceInline
 679     public Byte64Vector shiftR(int s) {
 680         return VectorIntrinsics.broadcastInt(
 681             VECTOR_OP_URSHIFT, Byte64Vector.class, byte.class, LENGTH,
 682             this, s,
 683             (v, i) -> v.uOp((__, a) -> (byte) ((a & 0xFF) >>> (i & 7))));
 684     }
 685 
 686     @Override
 687     @ForceInline
 688     public Byte64Vector shiftR(int s, Mask<Byte> m) {
 689         return blend(shiftR(s), m);
 690     }
 691 
 692     @Override
 693     @ForceInline
 694     public Byte64Vector aShiftR(int s) {
 695         return VectorIntrinsics.broadcastInt(
 696             VECTOR_OP_RSHIFT, Byte64Vector.class, byte.class, LENGTH,
 697             this, s,
 698             (v, i) -> v.uOp((__, a) -> (byte) (a >> (i & 7))));
 699     }
 700 
 701     @Override
 702     @ForceInline
 703     public Byte64Vector aShiftR(int s, Mask<Byte> m) {
 704         return blend(aShiftR(s), m);
 705     }
 706     // Ternary operations
 707 
 708 
 709     // Type specific horizontal reductions
 710 
 711     @Override
 712     @ForceInline
 713     public byte addAll() {
 714         return (byte) VectorIntrinsics.reductionCoerced(
 715             VECTOR_OP_ADD, Byte64Vector.class, byte.class, LENGTH,
 716             this,
 717             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a + b)));
 718     }
 719 
 720     @Override
 721     @ForceInline
 722     public byte andAll() {
 723         return (byte) VectorIntrinsics.reductionCoerced(
 724             VECTOR_OP_AND, Byte64Vector.class, byte.class, LENGTH,
 725             this,
 726             v -> (long) v.rOp((byte) -1, (i, a, b) -> (byte) (a & b)));
 727     }
 728 
 729     @Override
 730     @ForceInline
 731     public byte andAll(Mask<Byte> m) {
 732         return blend(SPECIES.broadcast((byte) -1), m).andAll();
 733     }
 734 
 735     @Override
 736     @ForceInline
 737     public byte minAll() {
 738         return (byte) VectorIntrinsics.reductionCoerced(
 739             VECTOR_OP_MIN, Byte64Vector.class, byte.class, LENGTH,
 740             this,
 741             v -> (long) v.rOp(Byte.MAX_VALUE , (i, a, b) -> (byte) Math.min(a, b)));
 742     }
 743 
 744     @Override
 745     @ForceInline
 746     public byte maxAll() {
 747         return (byte) VectorIntrinsics.reductionCoerced(
 748             VECTOR_OP_MAX, Byte64Vector.class, byte.class, LENGTH,
 749             this,
 750             v -> (long) v.rOp(Byte.MIN_VALUE , (i, a, b) -> (byte) Math.max(a, b)));
 751     }
 752 
 753     @Override
 754     @ForceInline
 755     public byte mulAll() {
 756         return (byte) VectorIntrinsics.reductionCoerced(
 757             VECTOR_OP_MUL, Byte64Vector.class, byte.class, LENGTH,
 758             this,
 759             v -> (long) v.rOp((byte) 1, (i, a, b) -> (byte) (a * b)));
 760     }
 761 
 762     @Override
 763     @ForceInline
 764     public byte orAll() {
 765         return (byte) VectorIntrinsics.reductionCoerced(
 766             VECTOR_OP_OR, Byte64Vector.class, byte.class, LENGTH,
 767             this,
 768             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a | b)));
 769     }
 770 
 771     @Override
 772     @ForceInline
 773     public byte orAll(Mask<Byte> m) {
 774         return blend(SPECIES.broadcast((byte) 0), m).orAll();
 775     }
 776 
 777     @Override
 778     @ForceInline
 779     public byte xorAll() {
 780         return (byte) VectorIntrinsics.reductionCoerced(
 781             VECTOR_OP_XOR, Byte64Vector.class, byte.class, LENGTH,
 782             this,
 783             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a ^ b)));
 784     }
 785 
 786     @Override
 787     @ForceInline
 788     public byte xorAll(Mask<Byte> m) {
 789         return blend(SPECIES.broadcast((byte) 0), m).xorAll();
 790     }
 791 
 792 
 793     @Override
 794     @ForceInline
 795     public byte addAll(Mask<Byte> m) {
 796         return blend(SPECIES.broadcast((byte) 0), m).addAll();
 797     }
 798 
 799     @Override
 800     @ForceInline
 801     public byte mulAll(Mask<Byte> m) {
 802         return blend(SPECIES.broadcast((byte) 1), m).mulAll();
 803     }
 804 
 805     @Override
 806     @ForceInline
 807     public byte minAll(Mask<Byte> m) {
 808         return blend(SPECIES.broadcast(Byte.MAX_VALUE), m).minAll();
 809     }
 810 
 811     @Override
 812     @ForceInline
 813     public byte maxAll(Mask<Byte> m) {
 814         return blend(SPECIES.broadcast(Byte.MIN_VALUE), m).maxAll();
 815     }
 816 
 817     @Override
 818     @ForceInline
 819     public Shuffle<Byte> toShuffle() {
 820         byte[] a = toArray();
 821         int[] sa = new int[a.length];
 822         for (int i = 0; i < a.length; i++) {
 823             sa[i] = (int) a[i];
 824         }
 825         return ByteVector.shuffleFromArray(SPECIES, sa, 0);
 826     }
 827 
 828     // Memory operations
 829 
 830     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BYTE_INDEX_SCALE);
 831     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 832 
 833     @Override
 834     @ForceInline
 835     public void intoArray(byte[] a, int ix) {
 836         Objects.requireNonNull(a);
 837         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 838         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 839                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 840                                this,
 841                                a, ix,
 842                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 843     }
 844 
 845     @Override
 846     @ForceInline
 847     public final void intoArray(byte[] a, int ax, Mask<Byte> m) {
 848         ByteVector oldVal = ByteVector.fromArray(SPECIES, a, ax);
 849         ByteVector newVal = oldVal.blend(this, m);
 850         newVal.intoArray(a, ax);
 851     }
 852 
 853     @Override
 854     @ForceInline
 855     public void intoByteArray(byte[] a, int ix) {
 856         Objects.requireNonNull(a);
 857         ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
 858         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 859                                a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 860                                this,
 861                                a, ix,
 862                                (c, idx, v) -> {
 863                                    ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 864                                    ByteBuffer tb = bbc;
 865                                    v.forEach((i, e) -> tb.put(e));
 866                                });
 867     }
 868 
 869     @Override
 870     @ForceInline
 871     public final void intoByteArray(byte[] a, int ix, Mask<Byte> m) {
 872         Byte64Vector oldVal = (Byte64Vector) ByteVector.fromByteArray(SPECIES, a, ix);
 873         Byte64Vector newVal = oldVal.blend(this, m);
 874         newVal.intoByteArray(a, ix);
 875     }
 876 
 877     @Override
 878     @ForceInline
 879     public void intoByteBuffer(ByteBuffer bb, int ix) {
 880         if (bb.order() != ByteOrder.nativeOrder()) {
 881             throw new IllegalArgumentException();
 882         }
 883         if (bb.isReadOnly()) {
 884             throw new ReadOnlyBufferException();
 885         }
 886         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), bitSize() / Byte.SIZE);
 887         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 888                                U.getReference(bb, BYTE_BUFFER_HB), ix + U.getLong(bb, BUFFER_ADDRESS),
 889                                this,
 890                                bb, ix,
 891                                (c, idx, v) -> {
 892                                    ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 893                                    ByteBuffer tb = bbc;
 894                                    v.forEach((i, e) -> tb.put(e));
 895                                });
 896     }
 897 
 898     @Override
 899     @ForceInline
 900     public void intoByteBuffer(ByteBuffer bb, int ix, Mask<Byte> m) {
 901         Byte64Vector oldVal = (Byte64Vector) ByteVector.fromByteBuffer(SPECIES, bb, ix);
 902         Byte64Vector newVal = oldVal.blend(this, m);
 903         newVal.intoByteBuffer(bb, ix);
 904     }
 905 
 906     //
 907 
 908     @Override
 909     public String toString() {
 910         return Arrays.toString(getElements());
 911     }
 912 
 913     @Override
 914     public boolean equals(Object o) {
 915         if (this == o) return true;
 916         if (o == null || this.getClass() != o.getClass()) return false;
 917 
 918         Byte64Vector that = (Byte64Vector) o;
 919         return this.equal(that).allTrue();
 920     }
 921 
 922     @Override
 923     public int hashCode() {
 924         return Arrays.hashCode(vec);
 925     }
 926 
 927     // Binary test
 928 
 929     @Override
 930     Byte64Mask bTest(Vector<Byte> o, FBinTest f) {
 931         byte[] vec1 = getElements();
 932         byte[] vec2 = ((Byte64Vector)o).getElements();
 933         boolean[] bits = new boolean[length()];
 934         for (int i = 0; i < length(); i++){
 935             bits[i] = f.apply(i, vec1[i], vec2[i]);
 936         }
 937         return new Byte64Mask(bits);
 938     }
 939 
 940     // Comparisons
 941 
 942     @Override
 943     @ForceInline
 944     public Byte64Mask equal(Vector<Byte> o) {
 945         Objects.requireNonNull(o);
 946         Byte64Vector v = (Byte64Vector)o;
 947 
 948         return VectorIntrinsics.compare(
 949             BT_eq, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 950             this, v,
 951             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a == b));
 952     }
 953 
 954     @Override
 955     @ForceInline
 956     public Byte64Mask notEqual(Vector<Byte> o) {
 957         Objects.requireNonNull(o);
 958         Byte64Vector v = (Byte64Vector)o;
 959 
 960         return VectorIntrinsics.compare(
 961             BT_ne, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 962             this, v,
 963             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a != b));
 964     }
 965 
 966     @Override
 967     @ForceInline
 968     public Byte64Mask lessThan(Vector<Byte> o) {
 969         Objects.requireNonNull(o);
 970         Byte64Vector v = (Byte64Vector)o;
 971 
 972         return VectorIntrinsics.compare(
 973             BT_lt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 974             this, v,
 975             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a < b));
 976     }
 977 
 978     @Override
 979     @ForceInline
 980     public Byte64Mask lessThanEq(Vector<Byte> o) {
 981         Objects.requireNonNull(o);
 982         Byte64Vector v = (Byte64Vector)o;
 983 
 984         return VectorIntrinsics.compare(
 985             BT_le, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 986             this, v,
 987             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a <= b));
 988     }
 989 
 990     @Override
 991     @ForceInline
 992     public Byte64Mask greaterThan(Vector<Byte> o) {
 993         Objects.requireNonNull(o);
 994         Byte64Vector v = (Byte64Vector)o;
 995 
 996         return (Byte64Mask) VectorIntrinsics.compare(
 997             BT_gt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 998             this, v,
 999             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a > b));
1000     }
1001 
1002     @Override
1003     @ForceInline
1004     public Byte64Mask greaterThanEq(Vector<Byte> o) {
1005         Objects.requireNonNull(o);
1006         Byte64Vector v = (Byte64Vector)o;
1007 
1008         return VectorIntrinsics.compare(
1009             BT_ge, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
1010             this, v,
1011             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a >= b));
1012     }
1013 
1014     // Foreach
1015 
1016     @Override
1017     void forEach(FUnCon f) {
1018         byte[] vec = getElements();
1019         for (int i = 0; i < length(); i++) {
1020             f.apply(i, vec[i]);
1021         }
1022     }
1023 
1024     @Override
1025     void forEach(Mask<Byte> o, FUnCon f) {
1026         boolean[] mbits = ((Byte64Mask)o).getBits();
1027         forEach((i, a) -> {
1028             if (mbits[i]) { f.apply(i, a); }
1029         });
1030     }
1031 
1032 
1033 
1034     @Override
1035     public Byte64Vector rotateEL(int j) {
1036         byte[] vec = getElements();
1037         byte[] res = new byte[length()];
1038         for (int i = 0; i < length(); i++){
1039             res[(j + i) % length()] = vec[i];
1040         }
1041         return new Byte64Vector(res);
1042     }
1043 
1044     @Override
1045     public Byte64Vector rotateER(int j) {
1046         byte[] vec = getElements();
1047         byte[] res = new byte[length()];
1048         for (int i = 0; i < length(); i++){
1049             int z = i - j;
1050             if(j < 0) {
1051                 res[length() + z] = vec[i];
1052             } else {
1053                 res[z] = vec[i];
1054             }
1055         }
1056         return new Byte64Vector(res);
1057     }
1058 
1059     @Override
1060     public Byte64Vector shiftEL(int j) {
1061         byte[] vec = getElements();
1062         byte[] res = new byte[length()];
1063         for (int i = 0; i < length() - j; i++) {
1064             res[i] = vec[i + j];
1065         }
1066         return new Byte64Vector(res);
1067     }
1068 
1069     @Override
1070     public Byte64Vector shiftER(int j) {
1071         byte[] vec = getElements();
1072         byte[] res = new byte[length()];
1073         for (int i = 0; i < length() - j; i++){
1074             res[i + j] = vec[i];
1075         }
1076         return new Byte64Vector(res);
1077     }
1078 
1079     @Override
1080     @ForceInline
1081     public Byte64Vector rearrange(Vector<Byte> v,
1082                                   Shuffle<Byte> s, Mask<Byte> m) {
1083         return this.rearrange(s).blend(v.rearrange(s), m);
1084     }
1085 
1086     @Override
1087     @ForceInline
1088     public Byte64Vector rearrange(Shuffle<Byte> o1) {
1089         Objects.requireNonNull(o1);
1090         Byte64Shuffle s =  (Byte64Shuffle)o1;
1091 
1092         return VectorIntrinsics.rearrangeOp(
1093             Byte64Vector.class, Byte64Shuffle.class, byte.class, LENGTH,
1094             this, s,
1095             (v1, s_) -> v1.uOp((i, a) -> {
1096                 int ei = s_.getElement(i);
1097                 return v1.get(ei);
1098             }));
1099     }
1100 
1101     @Override
1102     @ForceInline
1103     public Byte64Vector blend(Vector<Byte> o1, Mask<Byte> o2) {
1104         Objects.requireNonNull(o1);
1105         Objects.requireNonNull(o2);
1106         Byte64Vector v = (Byte64Vector)o1;
1107         Byte64Mask   m = (Byte64Mask)o2;
1108 
1109         return VectorIntrinsics.blend(
1110             Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
1111             this, v, m,
1112             (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a));
1113     }
1114 
1115     // Accessors
1116 
1117     @Override
1118     public byte get(int i) {
1119         if (i < 0 || i >= LENGTH) {
1120             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1121         }
1122         return (byte) VectorIntrinsics.extract(
1123                                 Byte64Vector.class, byte.class, LENGTH,
1124                                 this, i,
1125                                 (vec, ix) -> {
1126                                     byte[] vecarr = vec.getElements();
1127                                     return (long)vecarr[ix];
1128                                 });
1129     }
1130 
1131     @Override
1132     public Byte64Vector with(int i, byte e) {
1133         if (i < 0 || i >= LENGTH) {
1134             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1135         }
1136         return VectorIntrinsics.insert(
1137                                 Byte64Vector.class, byte.class, LENGTH,
1138                                 this, i, (long)e,
1139                                 (v, ix, bits) -> {
1140                                     byte[] res = v.getElements().clone();
1141                                     res[ix] = (byte)bits;
1142                                     return new Byte64Vector(res);
1143                                 });
1144     }
1145 
1146     // Mask
1147 
1148     static final class Byte64Mask extends AbstractMask<Byte> {
1149         static final Byte64Mask TRUE_MASK = new Byte64Mask(true);
1150         static final Byte64Mask FALSE_MASK = new Byte64Mask(false);
1151 
1152         private final boolean[] bits; // Don't access directly, use getBits() instead.
1153 
1154         public Byte64Mask(boolean[] bits) {
1155             this(bits, 0);
1156         }
1157 
1158         public Byte64Mask(boolean[] bits, int offset) {
1159             boolean[] a = new boolean[species().length()];
1160             for (int i = 0; i < a.length; i++) {
1161                 a[i] = bits[offset + i];
1162             }
1163             this.bits = a;
1164         }
1165 
1166         public Byte64Mask(boolean val) {
1167             boolean[] bits = new boolean[species().length()];
1168             Arrays.fill(bits, val);
1169             this.bits = bits;
1170         }
1171 
1172         boolean[] getBits() {
1173             return VectorIntrinsics.maybeRebox(this).bits;
1174         }
1175 
1176         @Override
1177         Byte64Mask uOp(MUnOp f) {
1178             boolean[] res = new boolean[species().length()];
1179             boolean[] bits = getBits();
1180             for (int i = 0; i < species().length(); i++) {
1181                 res[i] = f.apply(i, bits[i]);
1182             }
1183             return new Byte64Mask(res);
1184         }
1185 
1186         @Override
1187         Byte64Mask bOp(Mask<Byte> o, MBinOp f) {
1188             boolean[] res = new boolean[species().length()];
1189             boolean[] bits = getBits();
1190             boolean[] mbits = ((Byte64Mask)o).getBits();
1191             for (int i = 0; i < species().length(); i++) {
1192                 res[i] = f.apply(i, bits[i], mbits[i]);
1193             }
1194             return new Byte64Mask(res);
1195         }
1196 
1197         @Override
1198         public Byte64Species species() {
1199             return SPECIES;
1200         }
1201 
1202         @Override
1203         public Byte64Vector toVector() {
1204             byte[] res = new byte[species().length()];
1205             boolean[] bits = getBits();
1206             for (int i = 0; i < species().length(); i++) {
1207                 // -1 will result in the most significant bit being set in
1208                 // addition to some or all other bits
1209                 res[i] = (byte) (bits[i] ? -1 : 0);
1210             }
1211             return new Byte64Vector(res);
1212         }
1213 
1214         // Unary operations
1215 
1216         @Override
1217         @ForceInline
1218         public Byte64Mask not() {
1219             return (Byte64Mask) VectorIntrinsics.unaryOp(
1220                                              VECTOR_OP_NOT, Byte64Mask.class, byte.class, LENGTH,
1221                                              this,
1222                                              (m1) -> m1.uOp((i, a) -> !a));
1223         }
1224 
1225         // Binary operations
1226 
1227         @Override
1228         @ForceInline
1229         public Byte64Mask and(Mask<Byte> o) {
1230             Objects.requireNonNull(o);
1231             Byte64Mask m = (Byte64Mask)o;
1232             return VectorIntrinsics.binaryOp(VECTOR_OP_AND, Byte64Mask.class, byte.class, LENGTH,
1233                                              this, m,
1234                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b));
1235         }
1236 
1237         @Override
1238         @ForceInline
1239         public Byte64Mask or(Mask<Byte> o) {
1240             Objects.requireNonNull(o);
1241             Byte64Mask m = (Byte64Mask)o;
1242             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Byte64Mask.class, byte.class, LENGTH,
1243                                              this, m,
1244                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1245         }
1246 
1247         // Reductions
1248 
1249         @Override
1250         @ForceInline
1251         public boolean anyTrue() {
1252             return VectorIntrinsics.test(BT_ne, Byte64Mask.class, byte.class, LENGTH,
1253                                          this, this,
1254                                          (m, __) -> anyTrueHelper(((Byte64Mask)m).getBits()));
1255         }
1256 
1257         @Override
1258         @ForceInline
1259         public boolean allTrue() {
1260             return VectorIntrinsics.test(BT_overflow, Byte64Mask.class, byte.class, LENGTH,
1261                                          this, ByteVector.maskAllTrue(species()),
1262                                          (m, __) -> allTrueHelper(((Byte64Mask)m).getBits()));
1263         }
1264     }
1265 
1266     // Shuffle
1267 
1268     static final class Byte64Shuffle extends AbstractShuffle<Byte> {
1269         Byte64Shuffle(byte[] reorder) {
1270             super(reorder);
1271         }
1272 
1273         public Byte64Shuffle(int[] reorder) {
1274             super(reorder);
1275         }
1276 
1277         public Byte64Shuffle(int[] reorder, int i) {
1278             super(reorder, i);
1279         }
1280 
1281         public Byte64Shuffle(IntUnaryOperator f) {
1282             super(f);
1283         }
1284 
1285         @Override
1286         public Byte64Species species() {
1287             return SPECIES;
1288         }
1289 
1290         @Override
1291         public ByteVector toVector() {
1292             byte[] va = new byte[SPECIES.length()];
1293             for (int i = 0; i < va.length; i++) {
1294               va[i] = (byte) getElement(i);
1295             }
1296             return ByteVector.fromArray(SPECIES, va, 0);
1297         }
1298 
1299         @Override
1300         public Byte64Shuffle rearrange(Vector.Shuffle<Byte> o) {
1301             Byte64Shuffle s = (Byte64Shuffle) o;
1302             byte[] r = new byte[reorder.length];
1303             for (int i = 0; i < reorder.length; i++) {
1304                 r[i] = reorder[s.reorder[i]];
1305             }
1306             return new Byte64Shuffle(r);
1307         }
1308     }
1309 
1310     // Species
1311 
1312     @Override
1313     public Byte64Species species() {
1314         return SPECIES;
1315     }
1316 
1317     static final class Byte64Species extends ByteSpecies {
1318         static final int BIT_SIZE = Shape.S_64_BIT.bitSize();
1319 
1320         static final int LENGTH = BIT_SIZE / Byte.SIZE;
1321 
1322         @Override
1323         public String toString() {
1324            StringBuilder sb = new StringBuilder("Shape[");
1325            sb.append(bitSize()).append(" bits, ");
1326            sb.append(length()).append(" ").append(byte.class.getSimpleName()).append("s x ");
1327            sb.append(elementSize()).append(" bits");
1328            sb.append("]");
1329            return sb.toString();
1330         }
1331 
1332         @Override
1333         @ForceInline
1334         public int bitSize() {
1335             return BIT_SIZE;
1336         }
1337 
1338         @Override
1339         @ForceInline
1340         public int length() {
1341             return LENGTH;
1342         }
1343 
1344         @Override
1345         @ForceInline
1346         public Class<Byte> elementType() {
1347             return byte.class;
1348         }
1349 
1350         @Override
1351         @ForceInline
1352         public Class<?> boxType() {
1353             return Byte64Vector.class;
1354         }
1355 
1356         @Override
1357         @ForceInline
1358         public Class<?> maskType() {
1359             return Byte64Mask.class;
1360         }
1361 
1362         @Override
1363         @ForceInline
1364         public int elementSize() {
1365             return Byte.SIZE;
1366         }
1367 
1368         @Override
1369         @ForceInline
1370         @SuppressWarnings("unchecked")
1371         Class<?> vectorType() {
1372             return Byte64Vector.class;
1373         }
1374 
1375         @Override
1376         @ForceInline
1377         public Shape shape() {
1378             return Shape.S_64_BIT;
1379         }
1380 
1381         @Override
1382         Byte64Vector op(FOp f) {
1383             byte[] res = new byte[length()];
1384             for (int i = 0; i < length(); i++) {
1385                 res[i] = f.apply(i);
1386             }
1387             return new Byte64Vector(res);
1388         }
1389 
1390         @Override
1391         Byte64Vector op(Mask<Byte> o, FOp f) {
1392             byte[] res = new byte[length()];
1393             boolean[] mbits = ((Byte64Mask)o).getBits();
1394             for (int i = 0; i < length(); i++) {
1395                 if (mbits[i]) {
1396                     res[i] = f.apply(i);
1397                 }
1398             }
1399             return new Byte64Vector(res);
1400         }
1401 
1402         @Override
1403         Byte64Mask opm(FOpm f) {
1404             boolean[] res = new boolean[length()];
1405             for (int i = 0; i < length(); i++) {
1406                 res[i] = (boolean)f.apply(i);
1407             }
1408             return new Byte64Mask(res);
1409         }
1410 
1411         // Factories
1412 
1413         @Override
1414         @ForceInline
1415         public Byte64Vector zero() {
1416             return VectorIntrinsics.broadcastCoerced(Byte64Vector.class, byte.class, LENGTH,
1417                                                      0, SPECIES,
1418                                                      ((bits, s) -> ((Byte64Species)s).op(i -> (byte)bits)));
1419         }
1420 
1421         @Override
1422         @ForceInline
1423         public Byte64Vector broadcast(byte e) {
1424             return VectorIntrinsics.broadcastCoerced(
1425                 Byte64Vector.class, byte.class, LENGTH,
1426                 e, SPECIES,
1427                 ((bits, s) -> ((Byte64Species)s).op(i -> (byte)bits)));
1428         }
1429 
1430         @Override
1431         @ForceInline
1432         public Byte64Vector scalars(byte... es) {
1433             Objects.requireNonNull(es);
1434             int ix = VectorIntrinsics.checkIndex(0, es.length, LENGTH);
1435             return VectorIntrinsics.load(Byte64Vector.class, byte.class, LENGTH,
1436                                          es, Unsafe.ARRAY_BYTE_BASE_OFFSET,
1437                                          es, ix, SPECIES,
1438                                          (c, idx, s) -> ((Byte64Species)s).op(n -> c[idx + n]));
1439         }
1440 
1441         @Override
1442         @ForceInline
1443         public <E> Byte64Mask cast(Mask<E> m) {
1444             if (m.length() != LENGTH)
1445                 throw new IllegalArgumentException("Mask length this species length differ");
1446             return new Byte64Mask(m.toArray());
1447         }
1448 
1449         @Override
1450         @ForceInline
1451         public <E> Byte64Shuffle cast(Shuffle<E> s) {
1452             if (s.length() != LENGTH)
1453                 throw new IllegalArgumentException("Shuffle length this species length differ");
1454             return new Byte64Shuffle(s.toArray());
1455         }
1456     }
1457 }