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