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 SPECIES.broadcast((byte) -1).blend(this, 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 SPECIES.broadcast((byte) 0).blend(this, 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 SPECIES.broadcast((byte) 0).blend(this, m).xorAll();
 790     }
 791 
 792 
 793     @Override
 794     @ForceInline
 795     public byte addAll(Mask<Byte> m) {
 796         return SPECIES.broadcast((byte) 0).blend(this, m).addAll();
 797     }
 798 
 799 
 800     @Override
 801     @ForceInline
 802     public byte mulAll(Mask<Byte> m) {
 803         return SPECIES.broadcast((byte) 1).blend(this, m).mulAll();
 804     }
 805 
 806     @Override
 807     @ForceInline
 808     public byte minAll(Mask<Byte> m) {
 809         return SPECIES.broadcast(Byte.MAX_VALUE).blend(this, m).minAll();
 810     }
 811 
 812     @Override
 813     @ForceInline
 814     public byte maxAll(Mask<Byte> m) {
 815         return SPECIES.broadcast(Byte.MIN_VALUE).blend(this, m).maxAll();
 816     }
 817 
 818     @Override
 819     @ForceInline
 820     public Shuffle<Byte> toShuffle() {
 821         byte[] a = toArray();
 822         int[] sa = new int[a.length];
 823         for (int i = 0; i < a.length; i++) {
 824             sa[i] = (int) a[i];
 825         }
 826         return ByteVector.shuffleFromArray(SPECIES, sa, 0);
 827     }
 828 
 829     // Memory operations
 830 
 831     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BYTE_INDEX_SCALE);
 832     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 833 
 834     @Override
 835     @ForceInline
 836     public void intoArray(byte[] a, int ix) {
 837         Objects.requireNonNull(a);
 838         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 839         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 840                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 841                                this,
 842                                a, ix,
 843                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 844     }
 845 
 846     @Override
 847     @ForceInline
 848     public final void intoArray(byte[] a, int ax, Mask<Byte> m) {
 849         ByteVector oldVal = ByteVector.fromArray(SPECIES, a, ax);
 850         ByteVector newVal = oldVal.blend(this, m);
 851         newVal.intoArray(a, ax);
 852     }
 853 
 854     @Override
 855     @ForceInline
 856     public void intoByteArray(byte[] a, int ix) {
 857         Objects.requireNonNull(a);
 858         ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
 859         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 860                                a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 861                                this,
 862                                a, ix,
 863                                (c, idx, v) -> {
 864                                    ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 865                                    ByteBuffer tb = bbc;
 866                                    v.forEach((i, e) -> tb.put(e));
 867                                });
 868     }
 869 
 870     @Override
 871     @ForceInline
 872     public final void intoByteArray(byte[] a, int ix, Mask<Byte> m) {
 873         Byte64Vector oldVal = (Byte64Vector) ByteVector.fromByteArray(SPECIES, a, ix);
 874         Byte64Vector newVal = oldVal.blend(this, m);
 875         newVal.intoByteArray(a, ix);
 876     }
 877 
 878     @Override
 879     @ForceInline
 880     public void intoByteBuffer(ByteBuffer bb, int ix) {
 881         if (bb.order() != ByteOrder.nativeOrder()) {
 882             throw new IllegalArgumentException();
 883         }
 884         if (bb.isReadOnly()) {
 885             throw new ReadOnlyBufferException();
 886         }
 887         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), bitSize() / Byte.SIZE);
 888         VectorIntrinsics.store(Byte64Vector.class, byte.class, LENGTH,
 889                                U.getReference(bb, BYTE_BUFFER_HB), ix + U.getLong(bb, BUFFER_ADDRESS),
 890                                this,
 891                                bb, ix,
 892                                (c, idx, v) -> {
 893                                    ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 894                                    ByteBuffer tb = bbc;
 895                                    v.forEach((i, e) -> tb.put(e));
 896                                });
 897     }
 898 
 899     @Override
 900     @ForceInline
 901     public void intoByteBuffer(ByteBuffer bb, int ix, Mask<Byte> m) {
 902         Byte64Vector oldVal = (Byte64Vector) ByteVector.fromByteBuffer(SPECIES, bb, ix);
 903         Byte64Vector newVal = oldVal.blend(this, m);
 904         newVal.intoByteBuffer(bb, ix);
 905     }
 906 
 907     //
 908 
 909     @Override
 910     public String toString() {
 911         return Arrays.toString(getElements());
 912     }
 913 
 914     @Override
 915     public boolean equals(Object o) {
 916         if (this == o) return true;
 917         if (o == null || this.getClass() != o.getClass()) return false;
 918 
 919         Byte64Vector that = (Byte64Vector) o;
 920         return this.equal(that).allTrue();
 921     }
 922 
 923     @Override
 924     public int hashCode() {
 925         return Arrays.hashCode(vec);
 926     }
 927 
 928     // Binary test
 929 
 930     @Override
 931     Byte64Mask bTest(Vector<Byte> o, FBinTest f) {
 932         byte[] vec1 = getElements();
 933         byte[] vec2 = ((Byte64Vector)o).getElements();
 934         boolean[] bits = new boolean[length()];
 935         for (int i = 0; i < length(); i++){
 936             bits[i] = f.apply(i, vec1[i], vec2[i]);
 937         }
 938         return new Byte64Mask(bits);
 939     }
 940 
 941     // Comparisons
 942 
 943     @Override
 944     @ForceInline
 945     public Byte64Mask equal(Vector<Byte> o) {
 946         Objects.requireNonNull(o);
 947         Byte64Vector v = (Byte64Vector)o;
 948 
 949         return VectorIntrinsics.compare(
 950             BT_eq, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 951             this, v,
 952             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a == b));
 953     }
 954 
 955     @Override
 956     @ForceInline
 957     public Byte64Mask notEqual(Vector<Byte> o) {
 958         Objects.requireNonNull(o);
 959         Byte64Vector v = (Byte64Vector)o;
 960 
 961         return VectorIntrinsics.compare(
 962             BT_ne, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 963             this, v,
 964             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a != b));
 965     }
 966 
 967     @Override
 968     @ForceInline
 969     public Byte64Mask lessThan(Vector<Byte> o) {
 970         Objects.requireNonNull(o);
 971         Byte64Vector v = (Byte64Vector)o;
 972 
 973         return VectorIntrinsics.compare(
 974             BT_lt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 975             this, v,
 976             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a < b));
 977     }
 978 
 979     @Override
 980     @ForceInline
 981     public Byte64Mask lessThanEq(Vector<Byte> o) {
 982         Objects.requireNonNull(o);
 983         Byte64Vector v = (Byte64Vector)o;
 984 
 985         return VectorIntrinsics.compare(
 986             BT_le, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 987             this, v,
 988             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a <= b));
 989     }
 990 
 991     @Override
 992     @ForceInline
 993     public Byte64Mask greaterThan(Vector<Byte> o) {
 994         Objects.requireNonNull(o);
 995         Byte64Vector v = (Byte64Vector)o;
 996 
 997         return (Byte64Mask) VectorIntrinsics.compare(
 998             BT_gt, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
 999             this, v,
1000             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a > b));
1001     }
1002 
1003     @Override
1004     @ForceInline
1005     public Byte64Mask greaterThanEq(Vector<Byte> o) {
1006         Objects.requireNonNull(o);
1007         Byte64Vector v = (Byte64Vector)o;
1008 
1009         return VectorIntrinsics.compare(
1010             BT_ge, Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
1011             this, v,
1012             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a >= b));
1013     }
1014 
1015     // Foreach
1016 
1017     @Override
1018     void forEach(FUnCon f) {
1019         byte[] vec = getElements();
1020         for (int i = 0; i < length(); i++) {
1021             f.apply(i, vec[i]);
1022         }
1023     }
1024 
1025     @Override
1026     void forEach(Mask<Byte> o, FUnCon f) {
1027         boolean[] mbits = ((Byte64Mask)o).getBits();
1028         forEach((i, a) -> {
1029             if (mbits[i]) { f.apply(i, a); }
1030         });
1031     }
1032 
1033 
1034 
1035     @Override
1036     public Byte64Vector rotateEL(int j) {
1037         byte[] vec = getElements();
1038         byte[] res = new byte[length()];
1039         for (int i = 0; i < length(); i++){
1040             res[(j + i) % length()] = vec[i];
1041         }
1042         return new Byte64Vector(res);
1043     }
1044 
1045     @Override
1046     public Byte64Vector rotateER(int j) {
1047         byte[] vec = getElements();
1048         byte[] res = new byte[length()];
1049         for (int i = 0; i < length(); i++){
1050             int z = i - j;
1051             if(j < 0) {
1052                 res[length() + z] = vec[i];
1053             } else {
1054                 res[z] = vec[i];
1055             }
1056         }
1057         return new Byte64Vector(res);
1058     }
1059 
1060     @Override
1061     public Byte64Vector shiftEL(int j) {
1062         byte[] vec = getElements();
1063         byte[] res = new byte[length()];
1064         for (int i = 0; i < length() - j; i++) {
1065             res[i] = vec[i + j];
1066         }
1067         return new Byte64Vector(res);
1068     }
1069 
1070     @Override
1071     public Byte64Vector shiftER(int j) {
1072         byte[] vec = getElements();
1073         byte[] res = new byte[length()];
1074         for (int i = 0; i < length() - j; i++){
1075             res[i + j] = vec[i];
1076         }
1077         return new Byte64Vector(res);
1078     }
1079 
1080     @Override
1081     @ForceInline
1082     public Byte64Vector rearrange(Vector<Byte> v,
1083                                   Shuffle<Byte> s, Mask<Byte> m) {
1084         return this.rearrange(s).blend(v.rearrange(s), m);
1085     }
1086 
1087     @Override
1088     @ForceInline
1089     public Byte64Vector rearrange(Shuffle<Byte> o1) {
1090         Objects.requireNonNull(o1);
1091         Byte64Shuffle s =  (Byte64Shuffle)o1;
1092 
1093         return VectorIntrinsics.rearrangeOp(
1094             Byte64Vector.class, Byte64Shuffle.class, byte.class, LENGTH,
1095             this, s,
1096             (v1, s_) -> v1.uOp((i, a) -> {
1097                 int ei = s_.getElement(i);
1098                 return v1.get(ei);
1099             }));
1100     }
1101 
1102     @Override
1103     @ForceInline
1104     public Byte64Vector blend(Vector<Byte> o1, Mask<Byte> o2) {
1105         Objects.requireNonNull(o1);
1106         Objects.requireNonNull(o2);
1107         Byte64Vector v = (Byte64Vector)o1;
1108         Byte64Mask   m = (Byte64Mask)o2;
1109 
1110         return VectorIntrinsics.blend(
1111             Byte64Vector.class, Byte64Mask.class, byte.class, LENGTH,
1112             this, v, m,
1113             (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a));
1114     }
1115 
1116     // Accessors
1117 
1118     @Override
1119     public byte get(int i) {
1120         if (i < 0 || i >= LENGTH) {
1121             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1122         }
1123         return (byte) VectorIntrinsics.extract(
1124                                 Byte64Vector.class, byte.class, LENGTH,
1125                                 this, i,
1126                                 (vec, ix) -> {
1127                                     byte[] vecarr = vec.getElements();
1128                                     return (long)vecarr[ix];
1129                                 });
1130     }
1131 
1132     @Override
1133     public Byte64Vector with(int i, byte e) {
1134         if (i < 0 || i >= LENGTH) {
1135             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1136         }
1137         return VectorIntrinsics.insert(
1138                                 Byte64Vector.class, byte.class, LENGTH,
1139                                 this, i, (long)e,
1140                                 (v, ix, bits) -> {
1141                                     byte[] res = v.getElements().clone();
1142                                     res[ix] = (byte)bits;
1143                                     return new Byte64Vector(res);
1144                                 });
1145     }
1146 
1147     // Mask
1148 
1149     static final class Byte64Mask extends AbstractMask<Byte> {
1150         static final Byte64Mask TRUE_MASK = new Byte64Mask(true);
1151         static final Byte64Mask FALSE_MASK = new Byte64Mask(false);
1152 
1153         private final boolean[] bits; // Don't access directly, use getBits() instead.
1154 
1155         public Byte64Mask(boolean[] bits) {
1156             this(bits, 0);
1157         }
1158 
1159         public Byte64Mask(boolean[] bits, int offset) {
1160             boolean[] a = new boolean[species().length()];
1161             for (int i = 0; i < a.length; i++) {
1162                 a[i] = bits[offset + i];
1163             }
1164             this.bits = a;
1165         }
1166 
1167         public Byte64Mask(boolean val) {
1168             boolean[] bits = new boolean[species().length()];
1169             Arrays.fill(bits, val);
1170             this.bits = bits;
1171         }
1172 
1173         boolean[] getBits() {
1174             return VectorIntrinsics.maybeRebox(this).bits;
1175         }
1176 
1177         @Override
1178         Byte64Mask uOp(MUnOp f) {
1179             boolean[] res = new boolean[species().length()];
1180             boolean[] bits = getBits();
1181             for (int i = 0; i < species().length(); i++) {
1182                 res[i] = f.apply(i, bits[i]);
1183             }
1184             return new Byte64Mask(res);
1185         }
1186 
1187         @Override
1188         Byte64Mask bOp(Mask<Byte> o, MBinOp f) {
1189             boolean[] res = new boolean[species().length()];
1190             boolean[] bits = getBits();
1191             boolean[] mbits = ((Byte64Mask)o).getBits();
1192             for (int i = 0; i < species().length(); i++) {
1193                 res[i] = f.apply(i, bits[i], mbits[i]);
1194             }
1195             return new Byte64Mask(res);
1196         }
1197 
1198         @Override
1199         public Byte64Species species() {
1200             return SPECIES;
1201         }
1202 
1203         @Override
1204         public Byte64Vector toVector() {
1205             byte[] res = new byte[species().length()];
1206             boolean[] bits = getBits();
1207             for (int i = 0; i < species().length(); i++) {
1208                 // -1 will result in the most significant bit being set in
1209                 // addition to some or all other bits
1210                 res[i] = (byte) (bits[i] ? -1 : 0);
1211             }
1212             return new Byte64Vector(res);
1213         }
1214 
1215         // Unary operations
1216 
1217         @Override
1218         @ForceInline
1219         public Byte64Mask not() {
1220             return (Byte64Mask) VectorIntrinsics.unaryOp(
1221                                              VECTOR_OP_NOT, Byte64Mask.class, byte.class, LENGTH,
1222                                              this,
1223                                              (m1) -> m1.uOp((i, a) -> !a));
1224         }
1225 
1226         // Binary operations
1227 
1228         @Override
1229         @ForceInline
1230         public Byte64Mask and(Mask<Byte> o) {
1231             Objects.requireNonNull(o);
1232             Byte64Mask m = (Byte64Mask)o;
1233             return VectorIntrinsics.binaryOp(VECTOR_OP_AND, Byte64Mask.class, byte.class, LENGTH,
1234                                              this, m,
1235                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b));
1236         }
1237 
1238         @Override
1239         @ForceInline
1240         public Byte64Mask or(Mask<Byte> o) {
1241             Objects.requireNonNull(o);
1242             Byte64Mask m = (Byte64Mask)o;
1243             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Byte64Mask.class, byte.class, LENGTH,
1244                                              this, m,
1245                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1246         }
1247 
1248         // Reductions
1249 
1250         @Override
1251         @ForceInline
1252         public boolean anyTrue() {
1253             return VectorIntrinsics.test(BT_ne, Byte64Mask.class, byte.class, LENGTH,
1254                                          this, this,
1255                                          (m, __) -> anyTrueHelper(((Byte64Mask)m).getBits()));
1256         }
1257 
1258         @Override
1259         @ForceInline
1260         public boolean allTrue() {
1261             return VectorIntrinsics.test(BT_overflow, Byte64Mask.class, byte.class, LENGTH,
1262                                          this, ByteVector.maskAllTrue(species()),
1263                                          (m, __) -> allTrueHelper(((Byte64Mask)m).getBits()));
1264         }
1265     }
1266 
1267     // Shuffle
1268 
1269     static final class Byte64Shuffle extends AbstractShuffle<Byte> {
1270         Byte64Shuffle(byte[] reorder) {
1271             super(reorder);
1272         }
1273 
1274         public Byte64Shuffle(int[] reorder) {
1275             super(reorder);
1276         }
1277 
1278         public Byte64Shuffle(int[] reorder, int i) {
1279             super(reorder, i);
1280         }
1281 
1282         public Byte64Shuffle(IntUnaryOperator f) {
1283             super(f);
1284         }
1285 
1286         @Override
1287         public Byte64Species species() {
1288             return SPECIES;
1289         }
1290 
1291         @Override
1292         public ByteVector toVector() {
1293             byte[] va = new byte[SPECIES.length()];
1294             for (int i = 0; i < va.length; i++) {
1295               va[i] = (byte) getElement(i);
1296             }
1297             return ByteVector.fromArray(SPECIES, va, 0);
1298         }
1299 
1300         @Override
1301         public Byte64Shuffle rearrange(Vector.Shuffle<Byte> o) {
1302             Byte64Shuffle s = (Byte64Shuffle) o;
1303             byte[] r = new byte[reorder.length];
1304             for (int i = 0; i < reorder.length; i++) {
1305                 r[i] = reorder[s.reorder[i]];
1306             }
1307             return new Byte64Shuffle(r);
1308         }
1309     }
1310 
1311     // Species
1312 
1313     @Override
1314     public Byte64Species species() {
1315         return SPECIES;
1316     }
1317 
1318     static final class Byte64Species extends ByteSpecies {
1319         static final int BIT_SIZE = Shape.S_64_BIT.bitSize();
1320 
1321         static final int LENGTH = BIT_SIZE / Byte.SIZE;
1322 
1323         @Override
1324         public String toString() {
1325            StringBuilder sb = new StringBuilder("Shape[");
1326            sb.append(bitSize()).append(" bits, ");
1327            sb.append(length()).append(" ").append(byte.class.getSimpleName()).append("s x ");
1328            sb.append(elementSize()).append(" bits");
1329            sb.append("]");
1330            return sb.toString();
1331         }
1332 
1333         @Override
1334         @ForceInline
1335         public int bitSize() {
1336             return BIT_SIZE;
1337         }
1338 
1339         @Override
1340         @ForceInline
1341         public int length() {
1342             return LENGTH;
1343         }
1344 
1345         @Override
1346         @ForceInline
1347         public Class<Byte> elementType() {
1348             return byte.class;
1349         }
1350 
1351         @Override
1352         @ForceInline
1353         public Class<?> boxType() {
1354             return Byte64Vector.class;
1355         }
1356 
1357         @Override
1358         @ForceInline
1359         public Class<?> maskType() {
1360             return Byte64Mask.class;
1361         }
1362 
1363         @Override
1364         @ForceInline
1365         public int elementSize() {
1366             return Byte.SIZE;
1367         }
1368 
1369         @Override
1370         @ForceInline
1371         @SuppressWarnings("unchecked")
1372         Class<?> vectorType() {
1373             return Byte64Vector.class;
1374         }
1375 
1376         @Override
1377         @ForceInline
1378         public Shape shape() {
1379             return Shape.S_64_BIT;
1380         }
1381 
1382         @Override
1383         Byte64Vector op(FOp f) {
1384             byte[] res = new byte[length()];
1385             for (int i = 0; i < length(); i++) {
1386                 res[i] = f.apply(i);
1387             }
1388             return new Byte64Vector(res);
1389         }
1390 
1391         @Override
1392         Byte64Vector op(Mask<Byte> o, FOp f) {
1393             byte[] res = new byte[length()];
1394             boolean[] mbits = ((Byte64Mask)o).getBits();
1395             for (int i = 0; i < length(); i++) {
1396                 if (mbits[i]) {
1397                     res[i] = f.apply(i);
1398                 }
1399             }
1400             return new Byte64Vector(res);
1401         }
1402 
1403         @Override
1404         Byte64Mask opm(FOpm f) {
1405             boolean[] res = new boolean[length()];
1406             for (int i = 0; i < length(); i++) {
1407                 res[i] = (boolean)f.apply(i);
1408             }
1409             return new Byte64Mask(res);
1410         }
1411 
1412         // Factories
1413 
1414         @Override
1415         @ForceInline
1416         public Byte64Vector zero() {
1417             return VectorIntrinsics.broadcastCoerced(Byte64Vector.class, byte.class, LENGTH,
1418                                                      0, SPECIES,
1419                                                      ((bits, s) -> ((Byte64Species)s).op(i -> (byte)bits)));
1420         }
1421 
1422         @Override
1423         @ForceInline
1424         public Byte64Vector broadcast(byte e) {
1425             return VectorIntrinsics.broadcastCoerced(
1426                 Byte64Vector.class, byte.class, LENGTH,
1427                 e, SPECIES,
1428                 ((bits, s) -> ((Byte64Species)s).op(i -> (byte)bits)));
1429         }
1430 
1431         @Override
1432         @ForceInline
1433         public Byte64Vector scalars(byte... es) {
1434             Objects.requireNonNull(es);
1435             int ix = VectorIntrinsics.checkIndex(0, es.length, LENGTH);
1436             return VectorIntrinsics.load(Byte64Vector.class, byte.class, LENGTH,
1437                                          es, Unsafe.ARRAY_BYTE_BASE_OFFSET,
1438                                          es, ix, SPECIES,
1439                                          (c, idx, s) -> ((Byte64Species)s).op(n -> c[idx + n]));
1440         }
1441 
1442         @Override
1443         @ForceInline
1444         public <E> Byte64Mask cast(Mask<E> m) {
1445             if (m.length() != LENGTH)
1446                 throw new IllegalArgumentException("Mask length this species length differ");
1447             return new Byte64Mask(m.toArray());
1448         }
1449 
1450         @Override
1451         @ForceInline
1452         public <E> Byte64Shuffle cast(Shuffle<E> s) {
1453             if (s.length() != LENGTH)
1454                 throw new IllegalArgumentException("Shuffle length this species length differ");
1455             return new Byte64Shuffle(s.toArray());
1456         }
1457     }
1458 }