1 /*
   2  * Copyright (c) 2017, 2021, 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 any
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 
  27 import java.nio.ByteBuffer;
  28 import java.util.Arrays;
  29 import java.util.Objects;
  30 import java.util.function.IntUnaryOperator;
  31 
  32 import jdk.internal.vm.annotation.ForceInline;
  33 import jdk.internal.vm.vector.VectorSupport;
  34 
  35 import static jdk.internal.vm.vector.VectorSupport.*;
  36 
  37 import static jdk.incubator.vector.VectorOperators.*;
  38 
  39 // -- This file was mechanically generated: Do not edit! -- //
  40 
  41 @SuppressWarnings("cast")  // warning: redundant cast
  42 final class Byte512Vector extends ByteVector {
  43     static final ByteSpecies VSPECIES =
  44         (ByteSpecies) ByteVector.SPECIES_512;
  45 
  46     static final VectorShape VSHAPE =
  47         VSPECIES.vectorShape();
  48 
  49     static final Class<Byte512Vector> VCLASS = Byte512Vector.class;
  50 
  51     static final int VSIZE = VSPECIES.vectorBitSize();
  52 
  53     static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM
  54 
  55     static final Class<Byte> ETYPE = byte.class; // used by the JVM
  56 
  57     Byte512Vector(byte[] v) {
  58         super(v);
  59     }
  60 
  61     // For compatibility as Byte512Vector::new,
  62     // stored into species.vectorFactory.
  63     Byte512Vector(Object v) {
  64         this((byte[]) v);
  65     }
  66 
  67     static final Byte512Vector ZERO = new Byte512Vector(new byte[VLENGTH]);
  68     static final Byte512Vector IOTA = new Byte512Vector(VSPECIES.iotaArray());
  69 
  70     static {
  71         // Warm up a few species caches.
  72         // If we do this too much we will
  73         // get NPEs from bootstrap circularity.
  74         VSPECIES.dummyVector();
  75         VSPECIES.withLanes(LaneType.BYTE);
  76     }
  77 
  78     // Specialized extractors
  79 
  80     @ForceInline
  81     final @Override
  82     public ByteSpecies vspecies() {
  83         // ISSUE:  This should probably be a @Stable
  84         // field inside AbstractVector, rather than
  85         // a megamorphic method.
  86         return VSPECIES;
  87     }
  88 
  89     @ForceInline
  90     @Override
  91     public final Class<Byte> elementType() { return byte.class; }
  92 
  93     @ForceInline
  94     @Override
  95     public final int elementSize() { return Byte.SIZE; }
  96 
  97     @ForceInline
  98     @Override
  99     public final VectorShape shape() { return VSHAPE; }
 100 
 101     @ForceInline
 102     @Override
 103     public final int length() { return VLENGTH; }
 104 
 105     @ForceInline
 106     @Override
 107     public final int bitSize() { return VSIZE; }
 108 
 109     @ForceInline
 110     @Override
 111     public final int byteSize() { return VSIZE / Byte.SIZE; }
 112 
 113     /*package-private*/
 114     @ForceInline
 115     final @Override
 116     byte[] vec() {
 117         return (byte[])getPayload();
 118     }
 119 
 120     // Virtualized constructors
 121 
 122     @Override
 123     @ForceInline
 124     public final Byte512Vector broadcast(byte e) {
 125         return (Byte512Vector) super.broadcastTemplate(e);  // specialize
 126     }
 127 
 128     @Override
 129     @ForceInline
 130     public final Byte512Vector broadcast(long e) {
 131         return (Byte512Vector) super.broadcastTemplate(e);  // specialize
 132     }
 133 
 134     @Override
 135     @ForceInline
 136     Byte512Mask maskFromArray(boolean[] bits) {
 137         return new Byte512Mask(bits);
 138     }
 139 
 140     @Override
 141     @ForceInline
 142     Byte512Shuffle iotaShuffle() { return Byte512Shuffle.IOTA; }
 143 
 144     @ForceInline
 145     Byte512Shuffle iotaShuffle(int start, int step, boolean wrap) {
 146       if (wrap) {
 147         return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
 148                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
 149       } else {
 150         return (Byte512Shuffle)VectorSupport.shuffleIota(ETYPE, Byte512Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
 151                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
 152       }
 153     }
 154 
 155     @Override
 156     @ForceInline
 157     Byte512Shuffle shuffleFromBytes(byte[] reorder) { return new Byte512Shuffle(reorder); }
 158 
 159     @Override
 160     @ForceInline
 161     Byte512Shuffle shuffleFromArray(int[] indexes, int i) { return new Byte512Shuffle(indexes, i); }
 162 
 163     @Override
 164     @ForceInline
 165     Byte512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Byte512Shuffle(fn); }
 166 
 167     // Make a vector of the same species but the given elements:
 168     @ForceInline
 169     final @Override
 170     Byte512Vector vectorFactory(byte[] vec) {
 171         return new Byte512Vector(vec);
 172     }
 173 
 174     @ForceInline
 175     final @Override
 176     Byte512Vector asByteVectorRaw() {
 177         return (Byte512Vector) super.asByteVectorRawTemplate();  // specialize
 178     }
 179 
 180     @ForceInline
 181     final @Override
 182     AbstractVector<?> asVectorRaw(LaneType laneType) {
 183         return super.asVectorRawTemplate(laneType);  // specialize
 184     }
 185 
 186     // Unary operator
 187 
 188     @ForceInline
 189     final @Override
 190     Byte512Vector uOp(FUnOp f) {
 191         return (Byte512Vector) super.uOpTemplate(f);  // specialize
 192     }
 193 
 194     @ForceInline
 195     final @Override
 196     Byte512Vector uOp(VectorMask<Byte> m, FUnOp f) {
 197         return (Byte512Vector)
 198             super.uOpTemplate((Byte512Mask)m, f);  // specialize
 199     }
 200 
 201     // Binary operator
 202 
 203     @ForceInline
 204     final @Override
 205     Byte512Vector bOp(Vector<Byte> v, FBinOp f) {
 206         return (Byte512Vector) super.bOpTemplate((Byte512Vector)v, f);  // specialize
 207     }
 208 
 209     @ForceInline
 210     final @Override
 211     Byte512Vector bOp(Vector<Byte> v,
 212                      VectorMask<Byte> m, FBinOp f) {
 213         return (Byte512Vector)
 214             super.bOpTemplate((Byte512Vector)v, (Byte512Mask)m,
 215                               f);  // specialize
 216     }
 217 
 218     // Ternary operator
 219 
 220     @ForceInline
 221     final @Override
 222     Byte512Vector tOp(Vector<Byte> v1, Vector<Byte> v2, FTriOp f) {
 223         return (Byte512Vector)
 224             super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2,
 225                               f);  // specialize
 226     }
 227 
 228     @ForceInline
 229     final @Override
 230     Byte512Vector tOp(Vector<Byte> v1, Vector<Byte> v2,
 231                      VectorMask<Byte> m, FTriOp f) {
 232         return (Byte512Vector)
 233             super.tOpTemplate((Byte512Vector)v1, (Byte512Vector)v2,
 234                               (Byte512Mask)m, f);  // specialize
 235     }
 236 
 237     @ForceInline
 238     final @Override
 239     byte rOp(byte v, VectorMask<Byte> m, FBinOp f) {
 240         return super.rOpTemplate(v, m, f);  // specialize
 241     }
 242 
 243     @Override
 244     @ForceInline
 245     public final <F>
 246     Vector<F> convertShape(VectorOperators.Conversion<Byte,F> conv,
 247                            VectorSpecies<F> rsp, int part) {
 248         return super.convertShapeTemplate(conv, rsp, part);  // specialize
 249     }
 250 
 251     @Override
 252     @ForceInline
 253     public final <F>
 254     Vector<F> reinterpretShape(VectorSpecies<F> toSpecies, int part) {
 255         return super.reinterpretShapeTemplate(toSpecies, part);  // specialize
 256     }
 257 
 258     // Specialized algebraic operations:
 259 
 260     // The following definition forces a specialized version of this
 261     // crucial method into the v-table of this class.  A call to add()
 262     // will inline to a call to lanewise(ADD,), at which point the JIT
 263     // intrinsic will have the opcode of ADD, plus all the metadata
 264     // for this particular class, enabling it to generate precise
 265     // code.
 266     //
 267     // There is probably no benefit to the JIT to specialize the
 268     // masked or broadcast versions of the lanewise method.
 269 
 270     @Override
 271     @ForceInline
 272     public Byte512Vector lanewise(Unary op) {
 273         return (Byte512Vector) super.lanewiseTemplate(op);  // specialize
 274     }
 275 
 276     @Override
 277     @ForceInline
 278     public Byte512Vector lanewise(Unary op, VectorMask<Byte> m) {
 279         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialize
 280     }
 281 
 282     @Override
 283     @ForceInline
 284     public Byte512Vector lanewise(Binary op, Vector<Byte> v) {
 285         return (Byte512Vector) super.lanewiseTemplate(op, v);  // specialize
 286     }
 287 
 288     @Override
 289     @ForceInline
 290     public Byte512Vector lanewise(Binary op, Vector<Byte> v, VectorMask<Byte> m) {
 291         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v, (Byte512Mask) m);  // specialize
 292     }
 293 
 294     /*package-private*/
 295     @Override
 296     @ForceInline Byte512Vector
 297     lanewiseShift(VectorOperators.Binary op, int e) {
 298         return (Byte512Vector) super.lanewiseShiftTemplate(op, e);  // specialize
 299     }
 300 
 301     /*package-private*/
 302     @Override
 303     @ForceInline Byte512Vector
 304     lanewiseShift(VectorOperators.Binary op, int e, VectorMask<Byte> m) {
 305         return (Byte512Vector) super.lanewiseShiftTemplate(op, Byte512Mask.class, e, (Byte512Mask) m);  // specialize
 306     }
 307 
 308     /*package-private*/
 309     @Override
 310     @ForceInline
 311     public final
 312     Byte512Vector
 313     lanewise(Ternary op, Vector<Byte> v1, Vector<Byte> v2) {
 314         return (Byte512Vector) super.lanewiseTemplate(op, v1, v2);  // specialize
 315     }
 316 
 317     @Override
 318     @ForceInline
 319     public final
 320     Byte512Vector
 321     lanewise(Ternary op, Vector<Byte> v1, Vector<Byte> v2, VectorMask<Byte> m) {
 322         return (Byte512Vector) super.lanewiseTemplate(op, Byte512Mask.class, v1, v2, (Byte512Mask) m);  // specialize
 323     }
 324 
 325     @Override
 326     @ForceInline
 327     public final
 328     Byte512Vector addIndex(int scale) {
 329         return (Byte512Vector) super.addIndexTemplate(scale);  // specialize
 330     }
 331 
 332     // Type specific horizontal reductions
 333 
 334     @Override
 335     @ForceInline
 336     public final byte reduceLanes(VectorOperators.Associative op) {
 337         return super.reduceLanesTemplate(op);  // specialized
 338     }
 339 
 340     @Override
 341     @ForceInline
 342     public final byte reduceLanes(VectorOperators.Associative op,
 343                                     VectorMask<Byte> m) {
 344         return super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialized
 345     }
 346 
 347     @Override
 348     @ForceInline
 349     public final long reduceLanesToLong(VectorOperators.Associative op) {
 350         return (long) super.reduceLanesTemplate(op);  // specialized
 351     }
 352 
 353     @Override
 354     @ForceInline
 355     public final long reduceLanesToLong(VectorOperators.Associative op,
 356                                         VectorMask<Byte> m) {
 357         return (long) super.reduceLanesTemplate(op, Byte512Mask.class, (Byte512Mask) m);  // specialized
 358     }
 359 
 360     @ForceInline
 361     public VectorShuffle<Byte> toShuffle() {
 362         return super.toShuffleTemplate(Byte512Shuffle.class); // specialize
 363     }
 364 
 365     // Specialized unary testing
 366 
 367     @Override
 368     @ForceInline
 369     public final Byte512Mask test(Test op) {
 370         return super.testTemplate(Byte512Mask.class, op);  // specialize
 371     }
 372 
 373     // Specialized comparisons
 374 
 375     @Override
 376     @ForceInline
 377     public final Byte512Mask compare(Comparison op, Vector<Byte> v) {
 378         return super.compareTemplate(Byte512Mask.class, op, v);  // specialize
 379     }
 380 
 381     @Override
 382     @ForceInline
 383     public final Byte512Mask compare(Comparison op, byte s) {
 384         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 385     }
 386 
 387     @Override
 388     @ForceInline
 389     public final Byte512Mask compare(Comparison op, long s) {
 390         return super.compareTemplate(Byte512Mask.class, op, s);  // specialize
 391     }
 392 
 393     @Override
 394     @ForceInline
 395     public final Byte512Mask compare(Comparison op, Vector<Byte> v, VectorMask<Byte> m) {
 396         return super.compareTemplate(Byte512Mask.class, op, v, (Byte512Mask) m);
 397     }
 398 
 399 
 400     @Override
 401     @ForceInline
 402     public Byte512Vector blend(Vector<Byte> v, VectorMask<Byte> m) {
 403         return (Byte512Vector)
 404             super.blendTemplate(Byte512Mask.class,
 405                                 (Byte512Vector) v,
 406                                 (Byte512Mask) m);  // specialize
 407     }
 408 
 409     @Override
 410     @ForceInline
 411     public Byte512Vector slice(int origin, Vector<Byte> v) {
 412         return (Byte512Vector) super.sliceTemplate(origin, v);  // specialize
 413     }
 414 
 415     @Override
 416     @ForceInline
 417     public Byte512Vector slice(int origin) {
 418         return (Byte512Vector) super.sliceTemplate(origin);  // specialize
 419     }
 420 
 421     @Override
 422     @ForceInline
 423     public Byte512Vector unslice(int origin, Vector<Byte> w, int part) {
 424         return (Byte512Vector) super.unsliceTemplate(origin, w, part);  // specialize
 425     }
 426 
 427     @Override
 428     @ForceInline
 429     public Byte512Vector unslice(int origin, Vector<Byte> w, int part, VectorMask<Byte> m) {
 430         return (Byte512Vector)
 431             super.unsliceTemplate(Byte512Mask.class,
 432                                   origin, w, part,
 433                                   (Byte512Mask) m);  // specialize
 434     }
 435 
 436     @Override
 437     @ForceInline
 438     public Byte512Vector unslice(int origin) {
 439         return (Byte512Vector) super.unsliceTemplate(origin);  // specialize
 440     }
 441 
 442     @Override
 443     @ForceInline
 444     public Byte512Vector rearrange(VectorShuffle<Byte> s) {
 445         return (Byte512Vector)
 446             super.rearrangeTemplate(Byte512Shuffle.class,
 447                                     (Byte512Shuffle) s);  // specialize
 448     }
 449 
 450     @Override
 451     @ForceInline
 452     public Byte512Vector rearrange(VectorShuffle<Byte> shuffle,
 453                                   VectorMask<Byte> m) {
 454         return (Byte512Vector)
 455             super.rearrangeTemplate(Byte512Shuffle.class,
 456                                     Byte512Mask.class,
 457                                     (Byte512Shuffle) shuffle,
 458                                     (Byte512Mask) m);  // specialize
 459     }
 460 
 461     @Override
 462     @ForceInline
 463     public Byte512Vector rearrange(VectorShuffle<Byte> s,
 464                                   Vector<Byte> v) {
 465         return (Byte512Vector)
 466             super.rearrangeTemplate(Byte512Shuffle.class,
 467                                     (Byte512Shuffle) s,
 468                                     (Byte512Vector) v);  // specialize
 469     }
 470 
 471     @Override
 472     @ForceInline
 473     public Byte512Vector compress(VectorMask<Byte> m) {
 474         return (Byte512Vector)
 475             super.compressTemplate(Byte512Mask.class,
 476                                    (Byte512Mask) m);  // specialize
 477     }
 478 
 479     @Override
 480     @ForceInline
 481     public Byte512Vector expand(VectorMask<Byte> m) {
 482         return (Byte512Vector)
 483             super.expandTemplate(Byte512Mask.class,
 484                                    (Byte512Mask) m);  // specialize
 485     }
 486 
 487     @Override
 488     @ForceInline
 489     public Byte512Vector selectFrom(Vector<Byte> v) {
 490         return (Byte512Vector)
 491             super.selectFromTemplate((Byte512Vector) v);  // specialize
 492     }
 493 
 494     @Override
 495     @ForceInline
 496     public Byte512Vector selectFrom(Vector<Byte> v,
 497                                    VectorMask<Byte> m) {
 498         return (Byte512Vector)
 499             super.selectFromTemplate((Byte512Vector) v,
 500                                      (Byte512Mask) m);  // specialize
 501     }
 502 
 503 
 504     @ForceInline
 505     @Override
 506     public byte lane(int i) {
 507         switch(i) {
 508             case 0: return laneHelper(0);
 509             case 1: return laneHelper(1);
 510             case 2: return laneHelper(2);
 511             case 3: return laneHelper(3);
 512             case 4: return laneHelper(4);
 513             case 5: return laneHelper(5);
 514             case 6: return laneHelper(6);
 515             case 7: return laneHelper(7);
 516             case 8: return laneHelper(8);
 517             case 9: return laneHelper(9);
 518             case 10: return laneHelper(10);
 519             case 11: return laneHelper(11);
 520             case 12: return laneHelper(12);
 521             case 13: return laneHelper(13);
 522             case 14: return laneHelper(14);
 523             case 15: return laneHelper(15);
 524             case 16: return laneHelper(16);
 525             case 17: return laneHelper(17);
 526             case 18: return laneHelper(18);
 527             case 19: return laneHelper(19);
 528             case 20: return laneHelper(20);
 529             case 21: return laneHelper(21);
 530             case 22: return laneHelper(22);
 531             case 23: return laneHelper(23);
 532             case 24: return laneHelper(24);
 533             case 25: return laneHelper(25);
 534             case 26: return laneHelper(26);
 535             case 27: return laneHelper(27);
 536             case 28: return laneHelper(28);
 537             case 29: return laneHelper(29);
 538             case 30: return laneHelper(30);
 539             case 31: return laneHelper(31);
 540             case 32: return laneHelper(32);
 541             case 33: return laneHelper(33);
 542             case 34: return laneHelper(34);
 543             case 35: return laneHelper(35);
 544             case 36: return laneHelper(36);
 545             case 37: return laneHelper(37);
 546             case 38: return laneHelper(38);
 547             case 39: return laneHelper(39);
 548             case 40: return laneHelper(40);
 549             case 41: return laneHelper(41);
 550             case 42: return laneHelper(42);
 551             case 43: return laneHelper(43);
 552             case 44: return laneHelper(44);
 553             case 45: return laneHelper(45);
 554             case 46: return laneHelper(46);
 555             case 47: return laneHelper(47);
 556             case 48: return laneHelper(48);
 557             case 49: return laneHelper(49);
 558             case 50: return laneHelper(50);
 559             case 51: return laneHelper(51);
 560             case 52: return laneHelper(52);
 561             case 53: return laneHelper(53);
 562             case 54: return laneHelper(54);
 563             case 55: return laneHelper(55);
 564             case 56: return laneHelper(56);
 565             case 57: return laneHelper(57);
 566             case 58: return laneHelper(58);
 567             case 59: return laneHelper(59);
 568             case 60: return laneHelper(60);
 569             case 61: return laneHelper(61);
 570             case 62: return laneHelper(62);
 571             case 63: return laneHelper(63);
 572             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 573         }
 574     }
 575 
 576     public byte laneHelper(int i) {
 577         return (byte) VectorSupport.extract(
 578                                 VCLASS, ETYPE, VLENGTH,
 579                                 this, i,
 580                                 (vec, ix) -> {
 581                                     byte[] vecarr = vec.vec();
 582                                     return (long)vecarr[ix];
 583                                 });
 584     }
 585 
 586     @ForceInline
 587     @Override
 588     public Byte512Vector withLane(int i, byte e) {
 589         switch (i) {
 590             case 0: return withLaneHelper(0, e);
 591             case 1: return withLaneHelper(1, e);
 592             case 2: return withLaneHelper(2, e);
 593             case 3: return withLaneHelper(3, e);
 594             case 4: return withLaneHelper(4, e);
 595             case 5: return withLaneHelper(5, e);
 596             case 6: return withLaneHelper(6, e);
 597             case 7: return withLaneHelper(7, e);
 598             case 8: return withLaneHelper(8, e);
 599             case 9: return withLaneHelper(9, e);
 600             case 10: return withLaneHelper(10, e);
 601             case 11: return withLaneHelper(11, e);
 602             case 12: return withLaneHelper(12, e);
 603             case 13: return withLaneHelper(13, e);
 604             case 14: return withLaneHelper(14, e);
 605             case 15: return withLaneHelper(15, e);
 606             case 16: return withLaneHelper(16, e);
 607             case 17: return withLaneHelper(17, e);
 608             case 18: return withLaneHelper(18, e);
 609             case 19: return withLaneHelper(19, e);
 610             case 20: return withLaneHelper(20, e);
 611             case 21: return withLaneHelper(21, e);
 612             case 22: return withLaneHelper(22, e);
 613             case 23: return withLaneHelper(23, e);
 614             case 24: return withLaneHelper(24, e);
 615             case 25: return withLaneHelper(25, e);
 616             case 26: return withLaneHelper(26, e);
 617             case 27: return withLaneHelper(27, e);
 618             case 28: return withLaneHelper(28, e);
 619             case 29: return withLaneHelper(29, e);
 620             case 30: return withLaneHelper(30, e);
 621             case 31: return withLaneHelper(31, e);
 622             case 32: return withLaneHelper(32, e);
 623             case 33: return withLaneHelper(33, e);
 624             case 34: return withLaneHelper(34, e);
 625             case 35: return withLaneHelper(35, e);
 626             case 36: return withLaneHelper(36, e);
 627             case 37: return withLaneHelper(37, e);
 628             case 38: return withLaneHelper(38, e);
 629             case 39: return withLaneHelper(39, e);
 630             case 40: return withLaneHelper(40, e);
 631             case 41: return withLaneHelper(41, e);
 632             case 42: return withLaneHelper(42, e);
 633             case 43: return withLaneHelper(43, e);
 634             case 44: return withLaneHelper(44, e);
 635             case 45: return withLaneHelper(45, e);
 636             case 46: return withLaneHelper(46, e);
 637             case 47: return withLaneHelper(47, e);
 638             case 48: return withLaneHelper(48, e);
 639             case 49: return withLaneHelper(49, e);
 640             case 50: return withLaneHelper(50, e);
 641             case 51: return withLaneHelper(51, e);
 642             case 52: return withLaneHelper(52, e);
 643             case 53: return withLaneHelper(53, e);
 644             case 54: return withLaneHelper(54, e);
 645             case 55: return withLaneHelper(55, e);
 646             case 56: return withLaneHelper(56, e);
 647             case 57: return withLaneHelper(57, e);
 648             case 58: return withLaneHelper(58, e);
 649             case 59: return withLaneHelper(59, e);
 650             case 60: return withLaneHelper(60, e);
 651             case 61: return withLaneHelper(61, e);
 652             case 62: return withLaneHelper(62, e);
 653             case 63: return withLaneHelper(63, e);
 654             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
 655         }
 656     }
 657 
 658     public Byte512Vector withLaneHelper(int i, byte e) {
 659         return VectorSupport.insert(
 660                                 VCLASS, ETYPE, VLENGTH,
 661                                 this, i, (long)e,
 662                                 (v, ix, bits) -> {
 663                                     byte[] res = v.vec().clone();
 664                                     res[ix] = (byte)bits;
 665                                     return v.vectorFactory(res);
 666                                 });
 667     }
 668 
 669     // Mask
 670 
 671     static final class Byte512Mask extends AbstractMask<Byte> {
 672         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 673         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 674 
 675         Byte512Mask(boolean[] bits) {
 676             this(bits, 0);
 677         }
 678 
 679         Byte512Mask(boolean[] bits, int offset) {
 680             super(prepare(bits, offset));
 681         }
 682 
 683         Byte512Mask(boolean val) {
 684             super(prepare(val));
 685         }
 686 
 687         private static boolean[] prepare(boolean[] bits, int offset) {
 688             boolean[] newBits = new boolean[VSPECIES.laneCount()];
 689             for (int i = 0; i < newBits.length; i++) {
 690                 newBits[i] = bits[offset + i];
 691             }
 692             return newBits;
 693         }
 694 
 695         private static boolean[] prepare(boolean val) {
 696             boolean[] bits = new boolean[VSPECIES.laneCount()];
 697             Arrays.fill(bits, val);
 698             return bits;
 699         }
 700 
 701         @ForceInline
 702         final @Override
 703         public ByteSpecies vspecies() {
 704             // ISSUE:  This should probably be a @Stable
 705             // field inside AbstractMask, rather than
 706             // a megamorphic method.
 707             return VSPECIES;
 708         }
 709 
 710         @ForceInline
 711         boolean[] getBits() {
 712             return (boolean[])getPayload();
 713         }
 714 
 715         @Override
 716         Byte512Mask uOp(MUnOp f) {
 717             boolean[] res = new boolean[vspecies().laneCount()];
 718             boolean[] bits = getBits();
 719             for (int i = 0; i < res.length; i++) {
 720                 res[i] = f.apply(i, bits[i]);
 721             }
 722             return new Byte512Mask(res);
 723         }
 724 
 725         @Override
 726         Byte512Mask bOp(VectorMask<Byte> m, MBinOp f) {
 727             boolean[] res = new boolean[vspecies().laneCount()];
 728             boolean[] bits = getBits();
 729             boolean[] mbits = ((Byte512Mask)m).getBits();
 730             for (int i = 0; i < res.length; i++) {
 731                 res[i] = f.apply(i, bits[i], mbits[i]);
 732             }
 733             return new Byte512Mask(res);
 734         }
 735 
 736         @ForceInline
 737         @Override
 738         public final
 739         Byte512Vector toVector() {
 740             return (Byte512Vector) super.toVectorTemplate();  // specialize
 741         }
 742 
 743         /**
 744          * Helper function for lane-wise mask conversions.
 745          * This function kicks in after intrinsic failure.
 746          */
 747         @ForceInline
 748         private final <E>
 749         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
 750             if (length() != dsp.laneCount())
 751                 throw new IllegalArgumentException("VectorMask length and species length differ");
 752             boolean[] maskArray = toArray();
 753             return  dsp.maskFactory(maskArray).check(dsp);
 754         }
 755 
 756         @Override
 757         @ForceInline
 758         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
 759             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
 760             if (length() != species.laneCount())
 761                 throw new IllegalArgumentException("VectorMask length and species length differ");
 762 
 763             return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
 764                 this.getClass(), ETYPE, VLENGTH,
 765                 species.maskType(), species.elementType(), VLENGTH,
 766                 this, species,
 767                 (m, s) -> s.maskFactory(m.toArray()).check(s));
 768         }
 769 
 770         @Override
 771         @ForceInline
 772         public Byte512Mask eq(VectorMask<Byte> mask) {
 773             Objects.requireNonNull(mask);
 774             Byte512Mask m = (Byte512Mask)mask;
 775             return xor(m.not());
 776         }
 777 
 778         // Unary operations
 779 
 780         @Override
 781         @ForceInline
 782         public Byte512Mask not() {
 783             return xor(maskAll(true));
 784         }
 785 
 786         @Override
 787         @ForceInline
 788         public Byte512Mask compress() {
 789             return (Byte512Mask)VectorSupport.comExpOp(VectorSupport.VECTOR_OP_MASK_COMPRESS,
 790                 Byte512Vector.class, Byte512Mask.class, ETYPE, VLENGTH, null, this,
 791                 (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount()));
 792         }
 793 
 794 
 795         // Binary operations
 796 
 797         @Override
 798         @ForceInline
 799         public Byte512Mask and(VectorMask<Byte> mask) {
 800             Objects.requireNonNull(mask);
 801             Byte512Mask m = (Byte512Mask)mask;
 802             return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, byte.class, VLENGTH,
 803                                           this, m, null,
 804                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
 805         }
 806 
 807         @Override
 808         @ForceInline
 809         public Byte512Mask or(VectorMask<Byte> mask) {
 810             Objects.requireNonNull(mask);
 811             Byte512Mask m = (Byte512Mask)mask;
 812             return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, byte.class, VLENGTH,
 813                                           this, m, null,
 814                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));
 815         }
 816 
 817         @ForceInline
 818         /* package-private */
 819         Byte512Mask xor(VectorMask<Byte> mask) {
 820             Objects.requireNonNull(mask);
 821             Byte512Mask m = (Byte512Mask)mask;
 822             return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, byte.class, VLENGTH,
 823                                           this, m, null,
 824                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b));
 825         }
 826 
 827         // Mask Query operations
 828 
 829         @Override
 830         @ForceInline
 831         public int trueCount() {
 832             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, byte.class, VLENGTH, this,
 833                                                       (m) -> trueCountHelper(m.getBits()));
 834         }
 835 
 836         @Override
 837         @ForceInline
 838         public int firstTrue() {
 839             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 840                                                       (m) -> firstTrueHelper(m.getBits()));
 841         }
 842 
 843         @Override
 844         @ForceInline
 845         public int lastTrue() {
 846             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, byte.class, VLENGTH, this,
 847                                                       (m) -> lastTrueHelper(m.getBits()));
 848         }
 849 
 850         @Override
 851         @ForceInline
 852         public long toLong() {
 853             if (length() > Long.SIZE) {
 854                 throw new UnsupportedOperationException("too many lanes for one long");
 855             }
 856             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, byte.class, VLENGTH, this,
 857                                                       (m) -> toLongHelper(m.getBits()));
 858         }
 859 
 860         // Reductions
 861 
 862         @Override
 863         @ForceInline
 864         public boolean anyTrue() {
 865             return VectorSupport.test(BT_ne, Byte512Mask.class, byte.class, VLENGTH,
 866                                          this, vspecies().maskAll(true),
 867                                          (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits()));
 868         }
 869 
 870         @Override
 871         @ForceInline
 872         public boolean allTrue() {
 873             return VectorSupport.test(BT_overflow, Byte512Mask.class, byte.class, VLENGTH,
 874                                          this, vspecies().maskAll(true),
 875                                          (m, __) -> allTrueHelper(((Byte512Mask)m).getBits()));
 876         }
 877 
 878         @ForceInline
 879         /*package-private*/
 880         static Byte512Mask maskAll(boolean bit) {
 881             return VectorSupport.broadcastCoerced(Byte512Mask.class, byte.class, VLENGTH,
 882                                                   (bit ? -1 : 0), null,
 883                                                   (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
 884         }
 885         private static final Byte512Mask  TRUE_MASK = new Byte512Mask(true);
 886         private static final Byte512Mask FALSE_MASK = new Byte512Mask(false);
 887 
 888     }
 889 
 890     // Shuffle
 891 
 892     static final class Byte512Shuffle extends AbstractShuffle<Byte> {
 893         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
 894         static final Class<Byte> ETYPE = byte.class; // used by the JVM
 895 
 896         Byte512Shuffle(byte[] reorder) {
 897             super(VLENGTH, reorder);
 898         }
 899 
 900         public Byte512Shuffle(int[] reorder) {
 901             super(VLENGTH, reorder);
 902         }
 903 
 904         public Byte512Shuffle(int[] reorder, int i) {
 905             super(VLENGTH, reorder, i);
 906         }
 907 
 908         public Byte512Shuffle(IntUnaryOperator fn) {
 909             super(VLENGTH, fn);
 910         }
 911 
 912         @Override
 913         public ByteSpecies vspecies() {
 914             return VSPECIES;
 915         }
 916 
 917         static {
 918             // There must be enough bits in the shuffle lanes to encode
 919             // VLENGTH valid indexes and VLENGTH exceptional ones.
 920             assert(VLENGTH < Byte.MAX_VALUE);
 921             assert(Byte.MIN_VALUE <= -VLENGTH);
 922         }
 923         static final Byte512Shuffle IOTA = new Byte512Shuffle(IDENTITY);
 924 
 925         @Override
 926         @ForceInline
 927         public Byte512Vector toVector() {
 928             return VectorSupport.shuffleToVector(VCLASS, ETYPE, Byte512Shuffle.class, this, VLENGTH,
 929                                                     (s) -> ((Byte512Vector)(((AbstractShuffle<Byte>)(s)).toVectorTemplate())));
 930         }
 931 
 932         @Override
 933         @ForceInline
 934         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
 935             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
 936             if (length() != species.laneCount())
 937                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
 938             int[] shuffleArray = toArray();
 939             return s.shuffleFromArray(shuffleArray, 0).check(s);
 940         }
 941 
 942         @ForceInline
 943         @Override
 944         public Byte512Shuffle rearrange(VectorShuffle<Byte> shuffle) {
 945             Byte512Shuffle s = (Byte512Shuffle) shuffle;
 946             byte[] reorder1 = reorder();
 947             byte[] reorder2 = s.reorder();
 948             byte[] r = new byte[reorder1.length];
 949             for (int i = 0; i < reorder1.length; i++) {
 950                 int ssi = reorder2[i];
 951                 r[i] = reorder1[ssi];  // throws on exceptional index
 952             }
 953             return new Byte512Shuffle(r);
 954         }
 955     }
 956 
 957     // ================================================
 958 
 959     // Specialized low-level memory operations.
 960 
 961     @ForceInline
 962     @Override
 963     final
 964     ByteVector fromArray0(byte[] a, int offset) {
 965         return super.fromArray0Template(a, offset);  // specialize
 966     }
 967 
 968     @ForceInline
 969     @Override
 970     final
 971     ByteVector fromArray0(byte[] a, int offset, VectorMask<Byte> m) {
 972         return super.fromArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 973     }
 974 
 975 
 976 
 977     @ForceInline
 978     @Override
 979     final
 980     ByteVector fromBooleanArray0(boolean[] a, int offset) {
 981         return super.fromBooleanArray0Template(a, offset);  // specialize
 982     }
 983 
 984     @ForceInline
 985     @Override
 986     final
 987     ByteVector fromBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
 988         return super.fromBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
 989     }
 990 
 991     @ForceInline
 992     @Override
 993     final
 994     ByteVector fromByteArray0(byte[] a, int offset) {
 995         return super.fromByteArray0Template(a, offset);  // specialize
 996     }
 997 
 998     @ForceInline
 999     @Override
1000     final
1001     ByteVector fromByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
1002         return super.fromByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
1003     }
1004 
1005     @ForceInline
1006     @Override
1007     final
1008     ByteVector fromByteBuffer0(ByteBuffer bb, int offset) {
1009         return super.fromByteBuffer0Template(bb, offset);  // specialize
1010     }
1011 
1012     @ForceInline
1013     @Override
1014     final
1015     ByteVector fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
1016         return super.fromByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);  // specialize
1017     }
1018 
1019     @ForceInline
1020     @Override
1021     final
1022     void intoArray0(byte[] a, int offset) {
1023         super.intoArray0Template(a, offset);  // specialize
1024     }
1025 
1026     @ForceInline
1027     @Override
1028     final
1029     void intoArray0(byte[] a, int offset, VectorMask<Byte> m) {
1030         super.intoArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1031     }
1032 
1033 
1034     @ForceInline
1035     @Override
1036     final
1037     void intoBooleanArray0(boolean[] a, int offset, VectorMask<Byte> m) {
1038         super.intoBooleanArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);
1039     }
1040 
1041     @ForceInline
1042     @Override
1043     final
1044     void intoByteArray0(byte[] a, int offset) {
1045         super.intoByteArray0Template(a, offset);  // specialize
1046     }
1047 
1048     @ForceInline
1049     @Override
1050     final
1051     void intoByteArray0(byte[] a, int offset, VectorMask<Byte> m) {
1052         super.intoByteArray0Template(Byte512Mask.class, a, offset, (Byte512Mask) m);  // specialize
1053     }
1054 
1055     @ForceInline
1056     @Override
1057     final
1058     void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<Byte> m) {
1059         super.intoByteBuffer0Template(Byte512Mask.class, bb, offset, (Byte512Mask) m);
1060     }
1061 
1062 
1063     // End of specialized low-level memory operations.
1064 
1065     // ================================================
1066 
1067 }
--- EOF ---