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 Long64Vector extends LongVector {
 43     static final LongSpecies VSPECIES =
 44         (LongSpecies) LongVector.SPECIES_64;
 45 
 46     static final VectorShape VSHAPE =
 47         VSPECIES.vectorShape();
 48 
 49     static final Class<Long64Vector> VCLASS = Long64Vector.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<Long> ETYPE = long.class; // used by the JVM
 56 
 57     Long64Vector(long[] v) {
 58         super(v);
 59     }
 60 
 61     // For compatibility as Long64Vector::new,
 62     // stored into species.vectorFactory.
 63     Long64Vector(Object v) {
 64         this((long[]) v);
 65     }
 66 
 67     static final Long64Vector ZERO = new Long64Vector(new long[VLENGTH]);
 68     static final Long64Vector IOTA = new Long64Vector(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 LongSpecies 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<Long> elementType() { return long.class; }
 92 
 93     @ForceInline
 94     @Override
 95     public final int elementSize() { return Long.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     long[] vec() {
117         return (long[])getPayload();
118     }
119 
120     // Virtualized constructors
121 
122     @Override
123     @ForceInline
124     public final Long64Vector broadcast(long e) {
125         return (Long64Vector) super.broadcastTemplate(e);  // specialize
126     }
127 
128 
129     @Override
130     @ForceInline
131     Long64Mask maskFromArray(boolean[] bits) {
132         return new Long64Mask(bits);
133     }
134 
135     @Override
136     @ForceInline
137     Long64Shuffle iotaShuffle() { return Long64Shuffle.IOTA; }
138 
139     @ForceInline
140     Long64Shuffle iotaShuffle(int start, int step, boolean wrap) {
141       if (wrap) {
142         return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.class, VSPECIES, VLENGTH, start, step, 1,
143                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (VectorIntrinsics.wrapToRange(i*lstep + lstart, l))));
144       } else {
145         return (Long64Shuffle)VectorSupport.shuffleIota(ETYPE, Long64Shuffle.class, VSPECIES, VLENGTH, start, step, 0,
146                 (l, lstart, lstep, s) -> s.shuffleFromOp(i -> (i*lstep + lstart)));
147       }
148     }
149 
150     @Override
151     @ForceInline
152     Long64Shuffle shuffleFromBytes(byte[] reorder) { return new Long64Shuffle(reorder); }
153 
154     @Override
155     @ForceInline
156     Long64Shuffle shuffleFromArray(int[] indexes, int i) { return new Long64Shuffle(indexes, i); }
157 
158     @Override
159     @ForceInline
160     Long64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Long64Shuffle(fn); }
161 
162     // Make a vector of the same species but the given elements:
163     @ForceInline
164     final @Override
165     Long64Vector vectorFactory(long[] vec) {
166         return new Long64Vector(vec);
167     }
168 
169     @ForceInline
170     final @Override
171     Byte64Vector asByteVectorRaw() {
172         return (Byte64Vector) super.asByteVectorRawTemplate();  // specialize
173     }
174 
175     @ForceInline
176     final @Override
177     AbstractVector<?> asVectorRaw(LaneType laneType) {
178         return super.asVectorRawTemplate(laneType);  // specialize
179     }
180 
181     // Unary operator
182 
183     @ForceInline
184     final @Override
185     Long64Vector uOp(FUnOp f) {
186         return (Long64Vector) super.uOpTemplate(f);  // specialize
187     }
188 
189     @ForceInline
190     final @Override
191     Long64Vector uOp(VectorMask<Long> m, FUnOp f) {
192         return (Long64Vector)
193             super.uOpTemplate((Long64Mask)m, f);  // specialize
194     }
195 
196     // Binary operator
197 
198     @ForceInline
199     final @Override
200     Long64Vector bOp(Vector<Long> v, FBinOp f) {
201         return (Long64Vector) super.bOpTemplate((Long64Vector)v, f);  // specialize
202     }
203 
204     @ForceInline
205     final @Override
206     Long64Vector bOp(Vector<Long> v,
207                      VectorMask<Long> m, FBinOp f) {
208         return (Long64Vector)
209             super.bOpTemplate((Long64Vector)v, (Long64Mask)m,
210                               f);  // specialize
211     }
212 
213     // Ternary operator
214 
215     @ForceInline
216     final @Override
217     Long64Vector tOp(Vector<Long> v1, Vector<Long> v2, FTriOp f) {
218         return (Long64Vector)
219             super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2,
220                               f);  // specialize
221     }
222 
223     @ForceInline
224     final @Override
225     Long64Vector tOp(Vector<Long> v1, Vector<Long> v2,
226                      VectorMask<Long> m, FTriOp f) {
227         return (Long64Vector)
228             super.tOpTemplate((Long64Vector)v1, (Long64Vector)v2,
229                               (Long64Mask)m, f);  // specialize
230     }
231 
232     @ForceInline
233     final @Override
234     long rOp(long v, VectorMask<Long> m, FBinOp f) {
235         return super.rOpTemplate(v, m, f);  // specialize
236     }
237 
238     @Override
239     @ForceInline
240     public final <F>
241     Vector<F> convertShape(VectorOperators.Conversion<Long,F> conv,
242                            VectorSpecies<F> rsp, int part) {
243         return super.convertShapeTemplate(conv, rsp, part);  // specialize
244     }
245 
246     @Override
247     @ForceInline
248     public final <F>
249     Vector<F> reinterpretShape(VectorSpecies<F> toSpecies, int part) {
250         return super.reinterpretShapeTemplate(toSpecies, part);  // specialize
251     }
252 
253     // Specialized algebraic operations:
254 
255     // The following definition forces a specialized version of this
256     // crucial method into the v-table of this class.  A call to add()
257     // will inline to a call to lanewise(ADD,), at which point the JIT
258     // intrinsic will have the opcode of ADD, plus all the metadata
259     // for this particular class, enabling it to generate precise
260     // code.
261     //
262     // There is probably no benefit to the JIT to specialize the
263     // masked or broadcast versions of the lanewise method.
264 
265     @Override
266     @ForceInline
267     public Long64Vector lanewise(Unary op) {
268         return (Long64Vector) super.lanewiseTemplate(op);  // specialize
269     }
270 
271     @Override
272     @ForceInline
273     public Long64Vector lanewise(Unary op, VectorMask<Long> m) {
274         return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, (Long64Mask) m);  // specialize
275     }
276 
277     @Override
278     @ForceInline
279     public Long64Vector lanewise(Binary op, Vector<Long> v) {
280         return (Long64Vector) super.lanewiseTemplate(op, v);  // specialize
281     }
282 
283     @Override
284     @ForceInline
285     public Long64Vector lanewise(Binary op, Vector<Long> v, VectorMask<Long> m) {
286         return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, v, (Long64Mask) m);  // specialize
287     }
288 
289     /*package-private*/
290     @Override
291     @ForceInline Long64Vector
292     lanewiseShift(VectorOperators.Binary op, int e) {
293         return (Long64Vector) super.lanewiseShiftTemplate(op, e);  // specialize
294     }
295 
296     /*package-private*/
297     @Override
298     @ForceInline Long64Vector
299     lanewiseShift(VectorOperators.Binary op, int e, VectorMask<Long> m) {
300         return (Long64Vector) super.lanewiseShiftTemplate(op, Long64Mask.class, e, (Long64Mask) m);  // specialize
301     }
302 
303     /*package-private*/
304     @Override
305     @ForceInline
306     public final
307     Long64Vector
308     lanewise(Ternary op, Vector<Long> v1, Vector<Long> v2) {
309         return (Long64Vector) super.lanewiseTemplate(op, v1, v2);  // specialize
310     }
311 
312     @Override
313     @ForceInline
314     public final
315     Long64Vector
316     lanewise(Ternary op, Vector<Long> v1, Vector<Long> v2, VectorMask<Long> m) {
317         return (Long64Vector) super.lanewiseTemplate(op, Long64Mask.class, v1, v2, (Long64Mask) m);  // specialize
318     }
319 
320     @Override
321     @ForceInline
322     public final
323     Long64Vector addIndex(int scale) {
324         return (Long64Vector) super.addIndexTemplate(scale);  // specialize
325     }
326 
327     // Type specific horizontal reductions
328 
329     @Override
330     @ForceInline
331     public final long reduceLanes(VectorOperators.Associative op) {
332         return super.reduceLanesTemplate(op);  // specialized
333     }
334 
335     @Override
336     @ForceInline
337     public final long reduceLanes(VectorOperators.Associative op,
338                                     VectorMask<Long> m) {
339         return super.reduceLanesTemplate(op, Long64Mask.class, (Long64Mask) m);  // specialized
340     }
341 
342     @Override
343     @ForceInline
344     public final long reduceLanesToLong(VectorOperators.Associative op) {
345         return (long) super.reduceLanesTemplate(op);  // specialized
346     }
347 
348     @Override
349     @ForceInline
350     public final long reduceLanesToLong(VectorOperators.Associative op,
351                                         VectorMask<Long> m) {
352         return (long) super.reduceLanesTemplate(op, Long64Mask.class, (Long64Mask) m);  // specialized
353     }
354 
355     @ForceInline
356     public VectorShuffle<Long> toShuffle() {
357         return super.toShuffleTemplate(Long64Shuffle.class); // specialize
358     }
359 
360     // Specialized unary testing
361 
362     @Override
363     @ForceInline
364     public final Long64Mask test(Test op) {
365         return super.testTemplate(Long64Mask.class, op);  // specialize
366     }
367 
368     // Specialized comparisons
369 
370     @Override
371     @ForceInline
372     public final Long64Mask compare(Comparison op, Vector<Long> v) {
373         return super.compareTemplate(Long64Mask.class, op, v);  // specialize
374     }
375 
376     @Override
377     @ForceInline
378     public final Long64Mask compare(Comparison op, long s) {
379         return super.compareTemplate(Long64Mask.class, op, s);  // specialize
380     }
381 
382 
383     @Override
384     @ForceInline
385     public final Long64Mask compare(Comparison op, Vector<Long> v, VectorMask<Long> m) {
386         return super.compareTemplate(Long64Mask.class, op, v, (Long64Mask) m);
387     }
388 
389 
390     @Override
391     @ForceInline
392     public Long64Vector blend(Vector<Long> v, VectorMask<Long> m) {
393         return (Long64Vector)
394             super.blendTemplate(Long64Mask.class,
395                                 (Long64Vector) v,
396                                 (Long64Mask) m);  // specialize
397     }
398 
399     @Override
400     @ForceInline
401     public Long64Vector slice(int origin, Vector<Long> v) {
402         return (Long64Vector) super.sliceTemplate(origin, v);  // specialize
403     }
404 
405     @Override
406     @ForceInline
407     public Long64Vector slice(int origin) {
408         return (Long64Vector) super.sliceTemplate(origin);  // specialize
409     }
410 
411     @Override
412     @ForceInline
413     public Long64Vector unslice(int origin, Vector<Long> w, int part) {
414         return (Long64Vector) super.unsliceTemplate(origin, w, part);  // specialize
415     }
416 
417     @Override
418     @ForceInline
419     public Long64Vector unslice(int origin, Vector<Long> w, int part, VectorMask<Long> m) {
420         return (Long64Vector)
421             super.unsliceTemplate(Long64Mask.class,
422                                   origin, w, part,
423                                   (Long64Mask) m);  // specialize
424     }
425 
426     @Override
427     @ForceInline
428     public Long64Vector unslice(int origin) {
429         return (Long64Vector) super.unsliceTemplate(origin);  // specialize
430     }
431 
432     @Override
433     @ForceInline
434     public Long64Vector rearrange(VectorShuffle<Long> s) {
435         return (Long64Vector)
436             super.rearrangeTemplate(Long64Shuffle.class,
437                                     (Long64Shuffle) s);  // specialize
438     }
439 
440     @Override
441     @ForceInline
442     public Long64Vector rearrange(VectorShuffle<Long> shuffle,
443                                   VectorMask<Long> m) {
444         return (Long64Vector)
445             super.rearrangeTemplate(Long64Shuffle.class,
446                                     Long64Mask.class,
447                                     (Long64Shuffle) shuffle,
448                                     (Long64Mask) m);  // specialize
449     }
450 
451     @Override
452     @ForceInline
453     public Long64Vector rearrange(VectorShuffle<Long> s,
454                                   Vector<Long> v) {
455         return (Long64Vector)
456             super.rearrangeTemplate(Long64Shuffle.class,
457                                     (Long64Shuffle) s,
458                                     (Long64Vector) v);  // specialize
459     }
460 
461     @Override
462     @ForceInline
463     public Long64Vector selectFrom(Vector<Long> v) {
464         return (Long64Vector)
465             super.selectFromTemplate((Long64Vector) v);  // specialize
466     }
467 
468     @Override
469     @ForceInline
470     public Long64Vector selectFrom(Vector<Long> v,
471                                    VectorMask<Long> m) {
472         return (Long64Vector)
473             super.selectFromTemplate((Long64Vector) v,
474                                      (Long64Mask) m);  // specialize
475     }
476 
477 
478     @ForceInline
479     @Override
480     public long lane(int i) {
481         switch(i) {
482             case 0: return laneHelper(0);
483             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
484         }
485     }
486 
487     public long laneHelper(int i) {
488         return (long) VectorSupport.extract(
489                                 VCLASS, ETYPE, VLENGTH,
490                                 this, i,
491                                 (vec, ix) -> {
492                                     long[] vecarr = vec.vec();
493                                     return (long)vecarr[ix];
494                                 });
495     }
496 
497     @ForceInline
498     @Override
499     public Long64Vector withLane(int i, long e) {
500         switch (i) {
501             case 0: return withLaneHelper(0, e);
502             default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH);
503         }
504     }
505 
506     public Long64Vector withLaneHelper(int i, long e) {
507         return VectorSupport.insert(
508                                 VCLASS, ETYPE, VLENGTH,
509                                 this, i, (long)e,
510                                 (v, ix, bits) -> {
511                                     long[] res = v.vec().clone();
512                                     res[ix] = (long)bits;
513                                     return v.vectorFactory(res);
514                                 });
515     }
516 
517     // Mask
518 
519     static final class Long64Mask extends AbstractMask<Long> {
520         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
521         static final Class<Long> ETYPE = long.class; // used by the JVM
522 
523         Long64Mask(boolean[] bits) {
524             this(bits, 0);
525         }
526 
527         Long64Mask(boolean[] bits, int offset) {
528             super(prepare(bits, offset));
529         }
530 
531         Long64Mask(boolean val) {
532             super(prepare(val));
533         }
534 
535         private static boolean[] prepare(boolean[] bits, int offset) {
536             boolean[] newBits = new boolean[VSPECIES.laneCount()];
537             for (int i = 0; i < newBits.length; i++) {
538                 newBits[i] = bits[offset + i];
539             }
540             return newBits;
541         }
542 
543         private static boolean[] prepare(boolean val) {
544             boolean[] bits = new boolean[VSPECIES.laneCount()];
545             Arrays.fill(bits, val);
546             return bits;
547         }
548 
549         @ForceInline
550         final @Override
551         public LongSpecies vspecies() {
552             // ISSUE:  This should probably be a @Stable
553             // field inside AbstractMask, rather than
554             // a megamorphic method.
555             return VSPECIES;
556         }
557 
558         @ForceInline
559         boolean[] getBits() {
560             return (boolean[])getPayload();
561         }
562 
563         @Override
564         Long64Mask uOp(MUnOp f) {
565             boolean[] res = new boolean[vspecies().laneCount()];
566             boolean[] bits = getBits();
567             for (int i = 0; i < res.length; i++) {
568                 res[i] = f.apply(i, bits[i]);
569             }
570             return new Long64Mask(res);
571         }
572 
573         @Override
574         Long64Mask bOp(VectorMask<Long> m, MBinOp f) {
575             boolean[] res = new boolean[vspecies().laneCount()];
576             boolean[] bits = getBits();
577             boolean[] mbits = ((Long64Mask)m).getBits();
578             for (int i = 0; i < res.length; i++) {
579                 res[i] = f.apply(i, bits[i], mbits[i]);
580             }
581             return new Long64Mask(res);
582         }
583 
584         @ForceInline
585         @Override
586         public final
587         Long64Vector toVector() {
588             return (Long64Vector) super.toVectorTemplate();  // specialize
589         }
590 
591         /**
592          * Helper function for lane-wise mask conversions.
593          * This function kicks in after intrinsic failure.
594          */
595         @ForceInline
596         private final <E>
597         VectorMask<E> defaultMaskCast(AbstractSpecies<E> dsp) {
598             if (length() != dsp.laneCount())
599                 throw new IllegalArgumentException("VectorMask length and species length differ");
600             boolean[] maskArray = toArray();
601             return  dsp.maskFactory(maskArray).check(dsp);
602         }
603 
604         @Override
605         @ForceInline
606         public <E> VectorMask<E> cast(VectorSpecies<E> dsp) {
607             AbstractSpecies<E> species = (AbstractSpecies<E>) dsp;
608             if (length() != species.laneCount())
609                 throw new IllegalArgumentException("VectorMask length and species length differ");
610 
611             return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST,
612                 this.getClass(), ETYPE, VLENGTH,
613                 species.maskType(), species.elementType(), VLENGTH,
614                 this, species,
615                 (m, s) -> s.maskFactory(m.toArray()).check(s));
616         }
617 
618         @Override
619         @ForceInline
620         public Long64Mask eq(VectorMask<Long> mask) {
621             Objects.requireNonNull(mask);
622             Long64Mask m = (Long64Mask)mask;
623             return xor(m.not());
624         }
625 
626         // Unary operations
627 
628         @Override
629         @ForceInline
630         public Long64Mask not() {
631             return xor(maskAll(true));
632         }
633 
634         // Binary operations
635 
636         @Override
637         @ForceInline
638         public Long64Mask and(VectorMask<Long> mask) {
639             Objects.requireNonNull(mask);
640             Long64Mask m = (Long64Mask)mask;
641             return VectorSupport.binaryOp(VECTOR_OP_AND, Long64Mask.class, null, long.class, VLENGTH,
642                                           this, m, null,
643                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
644         }
645 
646         @Override
647         @ForceInline
648         public Long64Mask or(VectorMask<Long> mask) {
649             Objects.requireNonNull(mask);
650             Long64Mask m = (Long64Mask)mask;
651             return VectorSupport.binaryOp(VECTOR_OP_OR, Long64Mask.class, null, long.class, VLENGTH,
652                                           this, m, null,
653                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));
654         }
655 
656         @ForceInline
657         /* package-private */
658         Long64Mask xor(VectorMask<Long> mask) {
659             Objects.requireNonNull(mask);
660             Long64Mask m = (Long64Mask)mask;
661             return VectorSupport.binaryOp(VECTOR_OP_XOR, Long64Mask.class, null, long.class, VLENGTH,
662                                           this, m, null,
663                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b));
664         }
665 
666         // Mask Query operations
667 
668         @Override
669         @ForceInline
670         public int trueCount() {
671             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long64Mask.class, long.class, VLENGTH, this,
672                                                       (m) -> trueCountHelper(m.getBits()));
673         }
674 
675         @Override
676         @ForceInline
677         public int firstTrue() {
678             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long64Mask.class, long.class, VLENGTH, this,
679                                                       (m) -> firstTrueHelper(m.getBits()));
680         }
681 
682         @Override
683         @ForceInline
684         public int lastTrue() {
685             return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long64Mask.class, long.class, VLENGTH, this,
686                                                       (m) -> lastTrueHelper(m.getBits()));
687         }
688 
689         @Override
690         @ForceInline
691         public long toLong() {
692             if (length() > Long.SIZE) {
693                 throw new UnsupportedOperationException("too many lanes for one long");
694             }
695             return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long64Mask.class, long.class, VLENGTH, this,
696                                                       (m) -> toLongHelper(m.getBits()));
697         }
698 
699         // Reductions
700 
701         @Override
702         @ForceInline
703         public boolean anyTrue() {
704             return VectorSupport.test(BT_ne, Long64Mask.class, long.class, VLENGTH,
705                                          this, vspecies().maskAll(true),
706                                          (m, __) -> anyTrueHelper(((Long64Mask)m).getBits()));
707         }
708 
709         @Override
710         @ForceInline
711         public boolean allTrue() {
712             return VectorSupport.test(BT_overflow, Long64Mask.class, long.class, VLENGTH,
713                                          this, vspecies().maskAll(true),
714                                          (m, __) -> allTrueHelper(((Long64Mask)m).getBits()));
715         }
716 
717         @ForceInline
718         /*package-private*/
719         static Long64Mask maskAll(boolean bit) {
720             return VectorSupport.broadcastCoerced(Long64Mask.class, long.class, VLENGTH,
721                                                   (bit ? -1 : 0), null,
722                                                   (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
723         }
724         private static final Long64Mask  TRUE_MASK = new Long64Mask(true);
725         private static final Long64Mask FALSE_MASK = new Long64Mask(false);
726 
727     }
728 
729     // Shuffle
730 
731     static final class Long64Shuffle extends AbstractShuffle<Long> {
732         static final int VLENGTH = VSPECIES.laneCount();    // used by the JVM
733         static final Class<Long> ETYPE = long.class; // used by the JVM
734 
735         Long64Shuffle(byte[] reorder) {
736             super(VLENGTH, reorder);
737         }
738 
739         public Long64Shuffle(int[] reorder) {
740             super(VLENGTH, reorder);
741         }
742 
743         public Long64Shuffle(int[] reorder, int i) {
744             super(VLENGTH, reorder, i);
745         }
746 
747         public Long64Shuffle(IntUnaryOperator fn) {
748             super(VLENGTH, fn);
749         }
750 
751         @Override
752         public LongSpecies vspecies() {
753             return VSPECIES;
754         }
755 
756         static {
757             // There must be enough bits in the shuffle lanes to encode
758             // VLENGTH valid indexes and VLENGTH exceptional ones.
759             assert(VLENGTH < Byte.MAX_VALUE);
760             assert(Byte.MIN_VALUE <= -VLENGTH);
761         }
762         static final Long64Shuffle IOTA = new Long64Shuffle(IDENTITY);
763 
764         @Override
765         @ForceInline
766         public Long64Vector toVector() {
767             return VectorSupport.shuffleToVector(VCLASS, ETYPE, Long64Shuffle.class, this, VLENGTH,
768                                                     (s) -> ((Long64Vector)(((AbstractShuffle<Long>)(s)).toVectorTemplate())));
769         }
770 
771         @Override
772         @ForceInline
773         public <F> VectorShuffle<F> cast(VectorSpecies<F> s) {
774             AbstractSpecies<F> species = (AbstractSpecies<F>) s;
775             if (length() != species.laneCount())
776                 throw new IllegalArgumentException("VectorShuffle length and species length differ");
777             int[] shuffleArray = toArray();
778             return s.shuffleFromArray(shuffleArray, 0).check(s);
779         }
780 
781         @ForceInline
782         @Override
783         public Long64Shuffle rearrange(VectorShuffle<Long> shuffle) {
784             Long64Shuffle s = (Long64Shuffle) shuffle;
785             byte[] reorder1 = reorder();
786             byte[] reorder2 = s.reorder();
787             byte[] r = new byte[reorder1.length];
788             for (int i = 0; i < reorder1.length; i++) {
789                 int ssi = reorder2[i];
790                 r[i] = reorder1[ssi];  // throws on exceptional index
791             }
792             return new Long64Shuffle(r);
793         }
794     }
795 
796     // ================================================
797 
798     // Specialized low-level memory operations.
799 
800     @ForceInline
801     @Override
802     final
803     LongVector fromArray0(long[] a, int offset) {
804         return super.fromArray0Template(a, offset);  // specialize
805     }
806 
807     @ForceInline
808     @Override
809     final
810     LongVector fromArray0(long[] a, int offset, VectorMask<Long> m) {
811         return super.fromArray0Template(Long64Mask.class, a, offset, (Long64Mask) m);  // specialize
812     }
813 
814     @ForceInline
815     @Override
816     final
817     LongVector fromArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Long> m) {
818         return super.fromArray0Template(Long64Mask.class, a, offset, indexMap, mapOffset, (Long64Mask) m);
819     }
820 
821 
822 
823     @ForceInline
824     @Override
825     final
826     LongVector fromByteArray0(byte[] a, int offset) {
827         return super.fromByteArray0Template(a, offset);  // specialize
828     }
829 
830     @ForceInline
831     @Override
832     final
833     LongVector fromByteArray0(byte[] a, int offset, VectorMask<Long> m) {
834         return super.fromByteArray0Template(Long64Mask.class, a, offset, (Long64Mask) m);  // specialize
835     }
836 
837     @ForceInline
838     @Override
839     final
840     LongVector fromByteBuffer0(ByteBuffer bb, int offset) {
841         return super.fromByteBuffer0Template(bb, offset);  // specialize
842     }
843 
844     @ForceInline
845     @Override
846     final
847     LongVector fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<Long> m) {
848         return super.fromByteBuffer0Template(Long64Mask.class, bb, offset, (Long64Mask) m);  // specialize
849     }
850 
851     @ForceInline
852     @Override
853     final
854     void intoArray0(long[] a, int offset) {
855         super.intoArray0Template(a, offset);  // specialize
856     }
857 
858     @ForceInline
859     @Override
860     final
861     void intoArray0(long[] a, int offset, VectorMask<Long> m) {
862         super.intoArray0Template(Long64Mask.class, a, offset, (Long64Mask) m);
863     }
864 
865     @ForceInline
866     @Override
867     final
868     void intoArray0(long[] a, int offset, int[] indexMap, int mapOffset, VectorMask<Long> m) {
869         super.intoArray0Template(Long64Mask.class, a, offset, indexMap, mapOffset, (Long64Mask) m);
870     }
871 
872 
873     @ForceInline
874     @Override
875     final
876     void intoByteArray0(byte[] a, int offset) {
877         super.intoByteArray0Template(a, offset);  // specialize
878     }
879 
880     @ForceInline
881     @Override
882     final
883     void intoByteArray0(byte[] a, int offset, VectorMask<Long> m) {
884         super.intoByteArray0Template(Long64Mask.class, a, offset, (Long64Mask) m);  // specialize
885     }
886 
887     @ForceInline
888     @Override
889     final
890     void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<Long> m) {
891         super.intoByteBuffer0Template(Long64Mask.class, bb, offset, (Long64Mask) m);
892     }
893 
894 
895     // End of specialized low-level memory operations.
896 
897     // ================================================
898 
899 }