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