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