1 /*
   2  * Copyright (c) 2017, 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
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 
  27 import java.nio.ByteBuffer;
  28 import java.nio.ByteOrder;
  29 import java.nio.LongBuffer;
  30 import java.nio.ReadOnlyBufferException;
  31 import java.util.Arrays;
  32 import java.util.Objects;
  33 import java.util.function.IntUnaryOperator;
  34 
  35 import jdk.internal.misc.Unsafe;
  36 import jdk.internal.vm.annotation.ForceInline;
  37 import static jdk.incubator.vector.VectorIntrinsics.*;
  38 
  39 @SuppressWarnings("cast")
  40 final class Long64Vector extends LongVector {
  41     static final Long64Species SPECIES = new Long64Species();
  42 
  43     static final Long64Vector ZERO = new Long64Vector();
  44 
  45     static final int LENGTH = SPECIES.length();
  46 
  47     // Index vector species
  48     private static final IntVector.IntSpecies INDEX_SPEC;
  49     static {
  50         INDEX_SPEC = (IntVector.IntSpecies) Species.of(int.class, Shape.S_64_BIT);
  51     }
  52     private final long[] vec; // Don't access directly, use getElements() instead.
  53 
  54     private long[] getElements() {
  55         return VectorIntrinsics.maybeRebox(this).vec;
  56     }
  57 
  58     Long64Vector() {
  59         vec = new long[SPECIES.length()];
  60     }
  61 
  62     Long64Vector(long[] v) {
  63         vec = v;
  64     }
  65 
  66     @Override
  67     public int length() { return LENGTH; }
  68 
  69     // Unary operator
  70 
  71     @Override
  72     Long64Vector uOp(FUnOp f) {
  73         long[] vec = getElements();
  74         long[] res = new long[length()];
  75         for (int i = 0; i < length(); i++) {
  76             res[i] = f.apply(i, vec[i]);
  77         }
  78         return new Long64Vector(res);
  79     }
  80 
  81     @Override
  82     Long64Vector uOp(Mask<Long> o, FUnOp f) {
  83         long[] vec = getElements();
  84         long[] res = new long[length()];
  85         boolean[] mbits = ((Long64Mask)o).getBits();
  86         for (int i = 0; i < length(); i++) {
  87             res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i];
  88         }
  89         return new Long64Vector(res);
  90     }
  91 
  92     // Binary operator
  93 
  94     @Override
  95     Long64Vector bOp(Vector<Long> o, FBinOp f) {
  96         long[] res = new long[length()];
  97         long[] vec1 = this.getElements();
  98         long[] vec2 = ((Long64Vector)o).getElements();
  99         for (int i = 0; i < length(); i++) {
 100             res[i] = f.apply(i, vec1[i], vec2[i]);
 101         }
 102         return new Long64Vector(res);
 103     }
 104 
 105     @Override
 106     Long64Vector bOp(Vector<Long> o1, Mask<Long> o2, FBinOp f) {
 107         long[] res = new long[length()];
 108         long[] vec1 = this.getElements();
 109         long[] vec2 = ((Long64Vector)o1).getElements();
 110         boolean[] mbits = ((Long64Mask)o2).getBits();
 111         for (int i = 0; i < length(); i++) {
 112             res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i];
 113         }
 114         return new Long64Vector(res);
 115     }
 116 
 117     // Trinary operator
 118 
 119     @Override
 120     Long64Vector tOp(Vector<Long> o1, Vector<Long> o2, FTriOp f) {
 121         long[] res = new long[length()];
 122         long[] vec1 = this.getElements();
 123         long[] vec2 = ((Long64Vector)o1).getElements();
 124         long[] vec3 = ((Long64Vector)o2).getElements();
 125         for (int i = 0; i < length(); i++) {
 126             res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]);
 127         }
 128         return new Long64Vector(res);
 129     }
 130 
 131     @Override
 132     Long64Vector tOp(Vector<Long> o1, Vector<Long> o2, Mask<Long> o3, FTriOp f) {
 133         long[] res = new long[length()];
 134         long[] vec1 = getElements();
 135         long[] vec2 = ((Long64Vector)o1).getElements();
 136         long[] vec3 = ((Long64Vector)o2).getElements();
 137         boolean[] mbits = ((Long64Mask)o3).getBits();
 138         for (int i = 0; i < length(); i++) {
 139             res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i];
 140         }
 141         return new Long64Vector(res);
 142     }
 143 
 144     @Override
 145     long rOp(long v, FBinOp f) {
 146         long[] vec = getElements();
 147         for (int i = 0; i < length(); i++) {
 148             v = f.apply(i, v, vec[i]);
 149         }
 150         return v;
 151     }
 152 
 153     @Override
 154     @ForceInline
 155     public <F> Vector<F> cast(Species<F> s) {
 156         Objects.requireNonNull(s);
 157         if (s.length() != LENGTH)
 158             throw new IllegalArgumentException("Vector length this species length differ");
 159 
 160         return VectorIntrinsics.cast(
 161             Long64Vector.class,
 162             long.class, LENGTH,
 163             s.vectorType(),
 164             s.elementType(), LENGTH,
 165             this, s,
 166             (species, vector) -> vector.castDefault(species)
 167         );
 168     }
 169 
 170     @SuppressWarnings("unchecked")
 171     @ForceInline
 172     private <F> Vector<F> castDefault(Species<F> s) {
 173         int limit = s.length();
 174 
 175         Class<?> stype = s.elementType();
 176         if (stype == byte.class) {
 177             byte[] a = new byte[limit];
 178             for (int i = 0; i < limit; i++) {
 179                 a[i] = (byte) this.get(i);
 180             }
 181             return (Vector) ByteVector.fromArray((ByteVector.ByteSpecies) s, a, 0);
 182         } else if (stype == short.class) {
 183             short[] a = new short[limit];
 184             for (int i = 0; i < limit; i++) {
 185                 a[i] = (short) this.get(i);
 186             }
 187             return (Vector) ShortVector.fromArray((ShortVector.ShortSpecies) s, a, 0);
 188         } else if (stype == int.class) {
 189             int[] a = new int[limit];
 190             for (int i = 0; i < limit; i++) {
 191                 a[i] = (int) this.get(i);
 192             }
 193             return (Vector) IntVector.fromArray((IntVector.IntSpecies) s, a, 0);
 194         } else if (stype == long.class) {
 195             long[] a = new long[limit];
 196             for (int i = 0; i < limit; i++) {
 197                 a[i] = (long) this.get(i);
 198             }
 199             return (Vector) LongVector.fromArray((LongVector.LongSpecies) s, a, 0);
 200         } else if (stype == float.class) {
 201             float[] a = new float[limit];
 202             for (int i = 0; i < limit; i++) {
 203                 a[i] = (float) this.get(i);
 204             }
 205             return (Vector) FloatVector.fromArray((FloatVector.FloatSpecies) s, a, 0);
 206         } else if (stype == double.class) {
 207             double[] a = new double[limit];
 208             for (int i = 0; i < limit; i++) {
 209                 a[i] = (double) this.get(i);
 210             }
 211             return (Vector) DoubleVector.fromArray((DoubleVector.DoubleSpecies) s, a, 0);
 212         } else {
 213             throw new UnsupportedOperationException("Bad lane type for casting.");
 214         }
 215     }
 216 
 217     @Override
 218     @ForceInline
 219     @SuppressWarnings("unchecked")
 220     public <F> Vector<F> reinterpret(Species<F> s) {
 221         Objects.requireNonNull(s);
 222 
 223         if(s.elementType().equals(long.class)) {
 224             return (Vector<F>) reshape((Species<Long>)s);
 225         }
 226         if(s.bitSize() == bitSize()) {
 227             return reinterpretType(s);
 228         }
 229 
 230         return defaultReinterpret(s);
 231     }
 232 
 233     @ForceInline
 234     private <F> Vector<F> reinterpretType(Species<F> s) {
 235         Objects.requireNonNull(s);
 236 
 237         Class<?> stype = s.elementType();
 238         if (stype == byte.class) {
 239             return VectorIntrinsics.reinterpret(
 240                 Long64Vector.class,
 241                 long.class, LENGTH,
 242                 Byte64Vector.class,
 243                 byte.class, Byte64Vector.LENGTH,
 244                 this, s,
 245                 (species, vector) -> vector.defaultReinterpret(species)
 246             );
 247         } else if (stype == short.class) {
 248             return VectorIntrinsics.reinterpret(
 249                 Long64Vector.class,
 250                 long.class, LENGTH,
 251                 Short64Vector.class,
 252                 short.class, Short64Vector.LENGTH,
 253                 this, s,
 254                 (species, vector) -> vector.defaultReinterpret(species)
 255             );
 256         } else if (stype == int.class) {
 257             return VectorIntrinsics.reinterpret(
 258                 Long64Vector.class,
 259                 long.class, LENGTH,
 260                 Int64Vector.class,
 261                 int.class, Int64Vector.LENGTH,
 262                 this, s,
 263                 (species, vector) -> vector.defaultReinterpret(species)
 264             );
 265         } else if (stype == long.class) {
 266             return VectorIntrinsics.reinterpret(
 267                 Long64Vector.class,
 268                 long.class, LENGTH,
 269                 Long64Vector.class,
 270                 long.class, Long64Vector.LENGTH,
 271                 this, s,
 272                 (species, vector) -> vector.defaultReinterpret(species)
 273             );
 274         } else if (stype == float.class) {
 275             return VectorIntrinsics.reinterpret(
 276                 Long64Vector.class,
 277                 long.class, LENGTH,
 278                 Float64Vector.class,
 279                 float.class, Float64Vector.LENGTH,
 280                 this, s,
 281                 (species, vector) -> vector.defaultReinterpret(species)
 282             );
 283         } else if (stype == double.class) {
 284             return VectorIntrinsics.reinterpret(
 285                 Long64Vector.class,
 286                 long.class, LENGTH,
 287                 Double64Vector.class,
 288                 double.class, Double64Vector.LENGTH,
 289                 this, s,
 290                 (species, vector) -> vector.defaultReinterpret(species)
 291             );
 292         } else {
 293             throw new UnsupportedOperationException("Bad lane type for casting.");
 294         }
 295     }
 296 
 297     @Override
 298     @ForceInline
 299     public LongVector reshape(Species<Long> s) {
 300         Objects.requireNonNull(s);
 301         if (s.bitSize() == 64 && (s instanceof Long64Vector.Long64Species)) {
 302             Long64Vector.Long64Species ts = (Long64Vector.Long64Species)s;
 303             return VectorIntrinsics.reinterpret(
 304                 Long64Vector.class,
 305                 long.class, LENGTH,
 306                 Long64Vector.class,
 307                 long.class, Long64Vector.LENGTH,
 308                 this, ts,
 309                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 310             );
 311         } else if (s.bitSize() == 128 && (s instanceof Long128Vector.Long128Species)) {
 312             Long128Vector.Long128Species ts = (Long128Vector.Long128Species)s;
 313             return VectorIntrinsics.reinterpret(
 314                 Long64Vector.class,
 315                 long.class, LENGTH,
 316                 Long128Vector.class,
 317                 long.class, Long128Vector.LENGTH,
 318                 this, ts,
 319                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 256 && (s instanceof Long256Vector.Long256Species)) {
 322             Long256Vector.Long256Species ts = (Long256Vector.Long256Species)s;
 323             return VectorIntrinsics.reinterpret(
 324                 Long64Vector.class,
 325                 long.class, LENGTH,
 326                 Long256Vector.class,
 327                 long.class, Long256Vector.LENGTH,
 328                 this, ts,
 329                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 330             );
 331         } else if (s.bitSize() == 512 && (s instanceof Long512Vector.Long512Species)) {
 332             Long512Vector.Long512Species ts = (Long512Vector.Long512Species)s;
 333             return VectorIntrinsics.reinterpret(
 334                 Long64Vector.class,
 335                 long.class, LENGTH,
 336                 Long512Vector.class,
 337                 long.class, Long512Vector.LENGTH,
 338                 this, ts,
 339                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 340             );
 341         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 342                 && (s.bitSize() % 128 == 0) && (s instanceof LongMaxVector.LongMaxSpecies)) {
 343             LongMaxVector.LongMaxSpecies ts = (LongMaxVector.LongMaxSpecies)s;
 344             return VectorIntrinsics.reinterpret(
 345                 Long64Vector.class,
 346                 long.class, LENGTH,
 347                 LongMaxVector.class,
 348                 long.class, LongMaxVector.LENGTH,
 349                 this, ts,
 350                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 351             );
 352         } else {
 353             throw new InternalError("Unimplemented size");
 354         }
 355     }
 356 
 357     // Binary operations with scalars
 358 
 359     @Override
 360     @ForceInline
 361     public LongVector add(long o) {
 362         return add(SPECIES.broadcast(o));
 363     }
 364 
 365     @Override
 366     @ForceInline
 367     public LongVector add(long o, Mask<Long> m) {
 368         return add(SPECIES.broadcast(o), m);
 369     }
 370 
 371     @Override
 372     @ForceInline
 373     public LongVector sub(long o) {
 374         return sub(SPECIES.broadcast(o));
 375     }
 376 
 377     @Override
 378     @ForceInline
 379     public LongVector sub(long o, Mask<Long> m) {
 380         return sub(SPECIES.broadcast(o), m);
 381     }
 382 
 383     @Override
 384     @ForceInline
 385     public LongVector mul(long o) {
 386         return mul(SPECIES.broadcast(o));
 387     }
 388 
 389     @Override
 390     @ForceInline
 391     public LongVector mul(long o, Mask<Long> m) {
 392         return mul(SPECIES.broadcast(o), m);
 393     }
 394 
 395     @Override
 396     @ForceInline
 397     public LongVector min(long o) {
 398         return min(SPECIES.broadcast(o));
 399     }
 400 
 401     @Override
 402     @ForceInline
 403     public LongVector max(long o) {
 404         return max(SPECIES.broadcast(o));
 405     }
 406 
 407     @Override
 408     @ForceInline
 409     public Mask<Long> equal(long o) {
 410         return equal(SPECIES.broadcast(o));
 411     }
 412 
 413     @Override
 414     @ForceInline
 415     public Mask<Long> notEqual(long o) {
 416         return notEqual(SPECIES.broadcast(o));
 417     }
 418 
 419     @Override
 420     @ForceInline
 421     public Mask<Long> lessThan(long o) {
 422         return lessThan(SPECIES.broadcast(o));
 423     }
 424 
 425     @Override
 426     @ForceInline
 427     public Mask<Long> lessThanEq(long o) {
 428         return lessThanEq(SPECIES.broadcast(o));
 429     }
 430 
 431     @Override
 432     @ForceInline
 433     public Mask<Long> greaterThan(long o) {
 434         return greaterThan(SPECIES.broadcast(o));
 435     }
 436 
 437     @Override
 438     @ForceInline
 439     public Mask<Long> greaterThanEq(long o) {
 440         return greaterThanEq(SPECIES.broadcast(o));
 441     }
 442 
 443     @Override
 444     @ForceInline
 445     public LongVector blend(long o, Mask<Long> m) {
 446         return blend(SPECIES.broadcast(o), m);
 447     }
 448 
 449 
 450     @Override
 451     @ForceInline
 452     public LongVector and(long o) {
 453         return and(SPECIES.broadcast(o));
 454     }
 455 
 456     @Override
 457     @ForceInline
 458     public LongVector and(long o, Mask<Long> m) {
 459         return and(SPECIES.broadcast(o), m);
 460     }
 461 
 462     @Override
 463     @ForceInline
 464     public LongVector or(long o) {
 465         return or(SPECIES.broadcast(o));
 466     }
 467 
 468     @Override
 469     @ForceInline
 470     public LongVector or(long o, Mask<Long> m) {
 471         return or(SPECIES.broadcast(o), m);
 472     }
 473 
 474     @Override
 475     @ForceInline
 476     public LongVector xor(long o) {
 477         return xor(SPECIES.broadcast(o));
 478     }
 479 
 480     @Override
 481     @ForceInline
 482     public LongVector xor(long o, Mask<Long> m) {
 483         return xor(SPECIES.broadcast(o), m);
 484     }
 485 
 486     @Override
 487     @ForceInline
 488     public Long64Vector neg() {
 489         return (Long64Vector)zero(SPECIES).sub(this);
 490     }
 491 
 492     // Unary operations
 493 
 494     @ForceInline
 495     @Override
 496     public Long64Vector neg(Mask<Long> m) {
 497         return blend(neg(), m);
 498     }
 499 
 500     @Override
 501     @ForceInline
 502     public Long64Vector abs() {
 503         return VectorIntrinsics.unaryOp(
 504             VECTOR_OP_ABS, Long64Vector.class, long.class, LENGTH,
 505             this,
 506             v1 -> v1.uOp((i, a) -> (long) Math.abs(a)));
 507     }
 508 
 509     @ForceInline
 510     @Override
 511     public Long64Vector abs(Mask<Long> m) {
 512         return blend(abs(), m);
 513     }
 514 
 515 
 516     @Override
 517     @ForceInline
 518     public Long64Vector not() {
 519         return VectorIntrinsics.unaryOp(
 520             VECTOR_OP_NOT, Long64Vector.class, long.class, LENGTH,
 521             this,
 522             v1 -> v1.uOp((i, a) -> (long) ~a));
 523     }
 524 
 525     @ForceInline
 526     @Override
 527     public Long64Vector not(Mask<Long> m) {
 528         return blend(not(), m);
 529     }
 530     // Binary operations
 531 
 532     @Override
 533     @ForceInline
 534     public Long64Vector add(Vector<Long> o) {
 535         Objects.requireNonNull(o);
 536         Long64Vector v = (Long64Vector)o;
 537         return VectorIntrinsics.binaryOp(
 538             VECTOR_OP_ADD, Long64Vector.class, long.class, LENGTH,
 539             this, v,
 540             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a + b)));
 541     }
 542 
 543     @Override
 544     @ForceInline
 545     public Long64Vector add(Vector<Long> v, Mask<Long> m) {
 546         return blend(add(v), m);
 547     }
 548 
 549     @Override
 550     @ForceInline
 551     public Long64Vector sub(Vector<Long> o) {
 552         Objects.requireNonNull(o);
 553         Long64Vector v = (Long64Vector)o;
 554         return VectorIntrinsics.binaryOp(
 555             VECTOR_OP_SUB, Long64Vector.class, long.class, LENGTH,
 556             this, v,
 557             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a - b)));
 558     }
 559 
 560     @Override
 561     @ForceInline
 562     public Long64Vector sub(Vector<Long> v, Mask<Long> m) {
 563         return blend(sub(v), m);
 564     }
 565 
 566     @Override
 567     @ForceInline
 568     public Long64Vector mul(Vector<Long> o) {
 569         Objects.requireNonNull(o);
 570         Long64Vector v = (Long64Vector)o;
 571         return VectorIntrinsics.binaryOp(
 572             VECTOR_OP_MUL, Long64Vector.class, long.class, LENGTH,
 573             this, v,
 574             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a * b)));
 575     }
 576 
 577     @Override
 578     @ForceInline
 579     public Long64Vector mul(Vector<Long> v, Mask<Long> m) {
 580         return blend(mul(v), m);
 581     }
 582 
 583     @Override
 584     @ForceInline
 585     public Long64Vector min(Vector<Long> o) {
 586         Objects.requireNonNull(o);
 587         Long64Vector v = (Long64Vector)o;
 588         return (Long64Vector) VectorIntrinsics.binaryOp(
 589             VECTOR_OP_MIN, Long64Vector.class, long.class, LENGTH,
 590             this, v,
 591             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long) Math.min(a, b)));
 592     }
 593 
 594     @Override
 595     @ForceInline
 596     public Long64Vector min(Vector<Long> v, Mask<Long> m) {
 597         return blend(min(v), m);
 598     }
 599 
 600     @Override
 601     @ForceInline
 602     public Long64Vector max(Vector<Long> o) {
 603         Objects.requireNonNull(o);
 604         Long64Vector v = (Long64Vector)o;
 605         return VectorIntrinsics.binaryOp(
 606             VECTOR_OP_MAX, Long64Vector.class, long.class, LENGTH,
 607             this, v,
 608             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long) Math.max(a, b)));
 609         }
 610 
 611     @Override
 612     @ForceInline
 613     public Long64Vector max(Vector<Long> v, Mask<Long> m) {
 614         return blend(max(v), m);
 615     }
 616 
 617     @Override
 618     @ForceInline
 619     public Long64Vector and(Vector<Long> o) {
 620         Objects.requireNonNull(o);
 621         Long64Vector v = (Long64Vector)o;
 622         return VectorIntrinsics.binaryOp(
 623             VECTOR_OP_AND, Long64Vector.class, long.class, LENGTH,
 624             this, v,
 625             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a & b)));
 626     }
 627 
 628     @Override
 629     @ForceInline
 630     public Long64Vector or(Vector<Long> o) {
 631         Objects.requireNonNull(o);
 632         Long64Vector v = (Long64Vector)o;
 633         return VectorIntrinsics.binaryOp(
 634             VECTOR_OP_OR, Long64Vector.class, long.class, LENGTH,
 635             this, v,
 636             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a | b)));
 637     }
 638 
 639     @Override
 640     @ForceInline
 641     public Long64Vector xor(Vector<Long> o) {
 642         Objects.requireNonNull(o);
 643         Long64Vector v = (Long64Vector)o;
 644         return VectorIntrinsics.binaryOp(
 645             VECTOR_OP_XOR, Long64Vector.class, long.class, LENGTH,
 646             this, v,
 647             (v1, v2) -> v1.bOp(v2, (i, a, b) -> (long)(a ^ b)));
 648     }
 649 
 650     @Override
 651     @ForceInline
 652     public Long64Vector and(Vector<Long> v, Mask<Long> m) {
 653         return blend(and(v), m);
 654     }
 655 
 656     @Override
 657     @ForceInline
 658     public Long64Vector or(Vector<Long> v, Mask<Long> m) {
 659         return blend(or(v), m);
 660     }
 661 
 662     @Override
 663     @ForceInline
 664     public Long64Vector xor(Vector<Long> v, Mask<Long> m) {
 665         return blend(xor(v), m);
 666     }
 667 
 668     @Override
 669     @ForceInline
 670     public Long64Vector shiftL(int s) {
 671         return VectorIntrinsics.broadcastInt(
 672             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 673             this, s,
 674             (v, i) -> v.uOp((__, a) -> (long) (a << i)));
 675     }
 676 
 677     @Override
 678     @ForceInline
 679     public Long64Vector shiftL(int s, Mask<Long> m) {
 680         return blend(shiftL(s), m);
 681     }
 682 
 683     @Override
 684     @ForceInline
 685     public Long64Vector shiftR(int s) {
 686         return VectorIntrinsics.broadcastInt(
 687             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 688             this, s,
 689             (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
 690     }
 691 
 692     @Override
 693     @ForceInline
 694     public Long64Vector shiftR(int s, Mask<Long> m) {
 695         return blend(shiftR(s), m);
 696     }
 697 
 698     @Override
 699     @ForceInline
 700     public Long64Vector aShiftR(int s) {
 701         return VectorIntrinsics.broadcastInt(
 702             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 703             this, s,
 704             (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
 705     }
 706 
 707     @Override
 708     @ForceInline
 709     public Long64Vector aShiftR(int s, Mask<Long> m) {
 710         return blend(aShiftR(s), m);
 711     }
 712 
 713     @Override
 714     @ForceInline
 715     public Long64Vector shiftL(Vector<Long> s) {
 716         Long64Vector shiftv = (Long64Vector)s;
 717         // As per shift specification for Java, mask the shift count.
 718         shiftv = shiftv.and(species().broadcast(0x3f));
 719         return VectorIntrinsics.binaryOp(
 720             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 721             this, shiftv,
 722             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
 723     }
 724 
 725     @Override
 726     @ForceInline
 727     public Long64Vector shiftR(Vector<Long> s) {
 728         Long64Vector shiftv = (Long64Vector)s;
 729         // As per shift specification for Java, mask the shift count.
 730         shiftv = shiftv.and(species().broadcast(0x3f));
 731         return VectorIntrinsics.binaryOp(
 732             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 733             this, shiftv,
 734             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
 735     }
 736 
 737     @Override
 738     @ForceInline
 739     public Long64Vector aShiftR(Vector<Long> s) {
 740         Long64Vector shiftv = (Long64Vector)s;
 741         // As per shift specification for Java, mask the shift count.
 742         shiftv = shiftv.and(species().broadcast(0x3f));
 743         return VectorIntrinsics.binaryOp(
 744             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 745             this, shiftv,
 746             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
 747     }
 748     // Ternary operations
 749 
 750 
 751     // Type specific horizontal reductions
 752 
 753     @Override
 754     @ForceInline
 755     public long addAll() {
 756         return (long) VectorIntrinsics.reductionCoerced(
 757             VECTOR_OP_ADD, Long64Vector.class, long.class, LENGTH,
 758             this,
 759             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));
 760     }
 761 
 762     @Override
 763     @ForceInline
 764     public long andAll() {
 765         return (long) VectorIntrinsics.reductionCoerced(
 766             VECTOR_OP_AND, Long64Vector.class, long.class, LENGTH,
 767             this,
 768             v -> (long) v.rOp((long) -1, (i, a, b) -> (long) (a & b)));
 769     }
 770 
 771     @Override
 772     @ForceInline
 773     public long andAll(Mask<Long> m) {
 774         return blend(SPECIES.broadcast((long) -1), m).andAll();
 775     }
 776 
 777     @Override
 778     @ForceInline
 779     public long minAll() {
 780         return (long) VectorIntrinsics.reductionCoerced(
 781             VECTOR_OP_MIN, Long64Vector.class, long.class, LENGTH,
 782             this,
 783             v -> (long) v.rOp(Long.MAX_VALUE , (i, a, b) -> (long) Math.min(a, b)));
 784     }
 785 
 786     @Override
 787     @ForceInline
 788     public long maxAll() {
 789         return (long) VectorIntrinsics.reductionCoerced(
 790             VECTOR_OP_MAX, Long64Vector.class, long.class, LENGTH,
 791             this,
 792             v -> (long) v.rOp(Long.MIN_VALUE , (i, a, b) -> (long) Math.max(a, b)));
 793     }
 794 
 795     @Override
 796     @ForceInline
 797     public long mulAll() {
 798         return (long) VectorIntrinsics.reductionCoerced(
 799             VECTOR_OP_MUL, Long64Vector.class, long.class, LENGTH,
 800             this,
 801             v -> (long) v.rOp((long) 1, (i, a, b) -> (long) (a * b)));
 802     }
 803 
 804     @Override
 805     @ForceInline
 806     public long orAll() {
 807         return (long) VectorIntrinsics.reductionCoerced(
 808             VECTOR_OP_OR, Long64Vector.class, long.class, LENGTH,
 809             this,
 810             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a | b)));
 811     }
 812 
 813     @Override
 814     @ForceInline
 815     public long orAll(Mask<Long> m) {
 816         return blend(SPECIES.broadcast((long) 0), m).orAll();
 817     }
 818 
 819     @Override
 820     @ForceInline
 821     public long xorAll() {
 822         return (long) VectorIntrinsics.reductionCoerced(
 823             VECTOR_OP_XOR, Long64Vector.class, long.class, LENGTH,
 824             this,
 825             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a ^ b)));
 826     }
 827 
 828     @Override
 829     @ForceInline
 830     public long xorAll(Mask<Long> m) {
 831         return blend(SPECIES.broadcast((long) 0), m).xorAll();
 832     }
 833 
 834 
 835     @Override
 836     @ForceInline
 837     public long addAll(Mask<Long> m) {
 838         return blend(SPECIES.broadcast((long) 0), m).addAll();
 839     }
 840 
 841     @Override
 842     @ForceInline
 843     public long mulAll(Mask<Long> m) {
 844         return blend(SPECIES.broadcast((long) 1), m).mulAll();
 845     }
 846 
 847     @Override
 848     @ForceInline
 849     public long minAll(Mask<Long> m) {
 850         return blend(SPECIES.broadcast(Long.MAX_VALUE), m).minAll();
 851     }
 852 
 853     @Override
 854     @ForceInline
 855     public long maxAll(Mask<Long> m) {
 856         return blend(SPECIES.broadcast(Long.MIN_VALUE), m).maxAll();
 857     }
 858 
 859     @Override
 860     @ForceInline
 861     public Shuffle<Long> toShuffle() {
 862         long[] a = toArray();
 863         int[] sa = new int[a.length];
 864         for (int i = 0; i < a.length; i++) {
 865             sa[i] = (int) a[i];
 866         }
 867         return LongVector.shuffleFromArray(SPECIES, sa, 0);
 868     }
 869 
 870     // Memory operations
 871 
 872     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_LONG_INDEX_SCALE);
 873     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 874 
 875     @Override
 876     @ForceInline
 877     public void intoArray(long[] a, int ix) {
 878         Objects.requireNonNull(a);
 879         ix = VectorIntrinsics.checkIndex(ix, a.length, LENGTH);
 880         VectorIntrinsics.store(Long64Vector.class, long.class, LENGTH,
 881                                a, (((long) ix) << ARRAY_SHIFT) + Unsafe.ARRAY_LONG_BASE_OFFSET,
 882                                this,
 883                                a, ix,
 884                                (arr, idx, v) -> v.forEach((i, e) -> arr[idx + i] = e));
 885     }
 886 
 887     @Override
 888     @ForceInline
 889     public final void intoArray(long[] a, int ax, Mask<Long> m) {
 890         LongVector oldVal = LongVector.fromArray(SPECIES, a, ax);
 891         LongVector newVal = oldVal.blend(this, m);
 892         newVal.intoArray(a, ax);
 893     }
 894     @Override
 895     @ForceInline
 896     public void intoArray(long[] a, int ix, int[] b, int iy) {
 897         this.intoArray(a, ix + b[iy]);
 898     }
 899 
 900      @Override
 901      @ForceInline
 902      public final void intoArray(long[] a, int ax, Mask<Long> m, int[] b, int iy) {
 903          // @@@ This can result in out of bounds errors for unset mask lanes
 904          LongVector oldVal = LongVector.fromArray(SPECIES, a, ax, b, iy);
 905          LongVector newVal = oldVal.blend(this, m);
 906          newVal.intoArray(a, ax, b, iy);
 907      }
 908 
 909     @Override
 910     @ForceInline
 911     public void intoByteArray(byte[] a, int ix) {
 912         Objects.requireNonNull(a);
 913         ix = VectorIntrinsics.checkIndex(ix, a.length, bitSize() / Byte.SIZE);
 914         VectorIntrinsics.store(Long64Vector.class, long.class, LENGTH,
 915                                a, ((long) ix) + Unsafe.ARRAY_BYTE_BASE_OFFSET,
 916                                this,
 917                                a, ix,
 918                                (c, idx, v) -> {
 919                                    ByteBuffer bbc = ByteBuffer.wrap(c, idx, c.length - idx).order(ByteOrder.nativeOrder());
 920                                    LongBuffer tb = bbc.asLongBuffer();
 921                                    v.forEach((i, e) -> tb.put(e));
 922                                });
 923     }
 924 
 925     @Override
 926     @ForceInline
 927     public final void intoByteArray(byte[] a, int ix, Mask<Long> m) {
 928         Long64Vector oldVal = (Long64Vector) LongVector.fromByteArray(SPECIES, a, ix);
 929         Long64Vector newVal = oldVal.blend(this, m);
 930         newVal.intoByteArray(a, ix);
 931     }
 932 
 933     @Override
 934     @ForceInline
 935     public void intoByteBuffer(ByteBuffer bb, int ix) {
 936         if (bb.order() != ByteOrder.nativeOrder()) {
 937             throw new IllegalArgumentException();
 938         }
 939         if (bb.isReadOnly()) {
 940             throw new ReadOnlyBufferException();
 941         }
 942         ix = VectorIntrinsics.checkIndex(ix, bb.limit(), bitSize() / Byte.SIZE);
 943         VectorIntrinsics.store(Long64Vector.class, long.class, LENGTH,
 944                                U.getReference(bb, BYTE_BUFFER_HB), ix + U.getLong(bb, BUFFER_ADDRESS),
 945                                this,
 946                                bb, ix,
 947                                (c, idx, v) -> {
 948                                    ByteBuffer bbc = c.duplicate().position(idx).order(ByteOrder.nativeOrder());
 949                                    LongBuffer tb = bbc.asLongBuffer();
 950                                    v.forEach((i, e) -> tb.put(e));
 951                                });
 952     }
 953 
 954     @Override
 955     @ForceInline
 956     public void intoByteBuffer(ByteBuffer bb, int ix, Mask<Long> m) {
 957         Long64Vector oldVal = (Long64Vector) LongVector.fromByteBuffer(SPECIES, bb, ix);
 958         Long64Vector newVal = oldVal.blend(this, m);
 959         newVal.intoByteBuffer(bb, ix);
 960     }
 961 
 962     //
 963 
 964     @Override
 965     public String toString() {
 966         return Arrays.toString(getElements());
 967     }
 968 
 969     @Override
 970     public boolean equals(Object o) {
 971         if (this == o) return true;
 972         if (o == null || this.getClass() != o.getClass()) return false;
 973 
 974         Long64Vector that = (Long64Vector) o;
 975         return this.equal(that).allTrue();
 976     }
 977 
 978     @Override
 979     public int hashCode() {
 980         return Arrays.hashCode(vec);
 981     }
 982 
 983     // Binary test
 984 
 985     @Override
 986     Long64Mask bTest(Vector<Long> o, FBinTest f) {
 987         long[] vec1 = getElements();
 988         long[] vec2 = ((Long64Vector)o).getElements();
 989         boolean[] bits = new boolean[length()];
 990         for (int i = 0; i < length(); i++){
 991             bits[i] = f.apply(i, vec1[i], vec2[i]);
 992         }
 993         return new Long64Mask(bits);
 994     }
 995 
 996     // Comparisons
 997 
 998     @Override
 999     @ForceInline
1000     public Long64Mask equal(Vector<Long> o) {
1001         Objects.requireNonNull(o);
1002         Long64Vector v = (Long64Vector)o;
1003 
1004         return VectorIntrinsics.compare(
1005             BT_eq, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1006             this, v,
1007             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a == b));
1008     }
1009 
1010     @Override
1011     @ForceInline
1012     public Long64Mask notEqual(Vector<Long> o) {
1013         Objects.requireNonNull(o);
1014         Long64Vector v = (Long64Vector)o;
1015 
1016         return VectorIntrinsics.compare(
1017             BT_ne, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1018             this, v,
1019             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a != b));
1020     }
1021 
1022     @Override
1023     @ForceInline
1024     public Long64Mask lessThan(Vector<Long> o) {
1025         Objects.requireNonNull(o);
1026         Long64Vector v = (Long64Vector)o;
1027 
1028         return VectorIntrinsics.compare(
1029             BT_lt, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1030             this, v,
1031             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a < b));
1032     }
1033 
1034     @Override
1035     @ForceInline
1036     public Long64Mask lessThanEq(Vector<Long> o) {
1037         Objects.requireNonNull(o);
1038         Long64Vector v = (Long64Vector)o;
1039 
1040         return VectorIntrinsics.compare(
1041             BT_le, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1042             this, v,
1043             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a <= b));
1044     }
1045 
1046     @Override
1047     @ForceInline
1048     public Long64Mask greaterThan(Vector<Long> o) {
1049         Objects.requireNonNull(o);
1050         Long64Vector v = (Long64Vector)o;
1051 
1052         return (Long64Mask) VectorIntrinsics.compare(
1053             BT_gt, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1054             this, v,
1055             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a > b));
1056     }
1057 
1058     @Override
1059     @ForceInline
1060     public Long64Mask greaterThanEq(Vector<Long> o) {
1061         Objects.requireNonNull(o);
1062         Long64Vector v = (Long64Vector)o;
1063 
1064         return VectorIntrinsics.compare(
1065             BT_ge, Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1066             this, v,
1067             (v1, v2) -> v1.bTest(v2, (i, a, b) -> a >= b));
1068     }
1069 
1070     // Foreach
1071 
1072     @Override
1073     void forEach(FUnCon f) {
1074         long[] vec = getElements();
1075         for (int i = 0; i < length(); i++) {
1076             f.apply(i, vec[i]);
1077         }
1078     }
1079 
1080     @Override
1081     void forEach(Mask<Long> o, FUnCon f) {
1082         boolean[] mbits = ((Long64Mask)o).getBits();
1083         forEach((i, a) -> {
1084             if (mbits[i]) { f.apply(i, a); }
1085         });
1086     }
1087 
1088 
1089     Double64Vector toFP() {
1090         long[] vec = getElements();
1091         double[] res = new double[this.species().length()];
1092         for(int i = 0; i < this.species().length(); i++){
1093             res[i] = Double.longBitsToDouble(vec[i]);
1094         }
1095         return new Double64Vector(res);
1096     }
1097 
1098     @Override
1099     public Long64Vector rotateEL(int j) {
1100         long[] vec = getElements();
1101         long[] res = new long[length()];
1102         for (int i = 0; i < length(); i++){
1103             res[(j + i) % length()] = vec[i];
1104         }
1105         return new Long64Vector(res);
1106     }
1107 
1108     @Override
1109     public Long64Vector rotateER(int j) {
1110         long[] vec = getElements();
1111         long[] res = new long[length()];
1112         for (int i = 0; i < length(); i++){
1113             int z = i - j;
1114             if(j < 0) {
1115                 res[length() + z] = vec[i];
1116             } else {
1117                 res[z] = vec[i];
1118             }
1119         }
1120         return new Long64Vector(res);
1121     }
1122 
1123     @Override
1124     public Long64Vector shiftEL(int j) {
1125         long[] vec = getElements();
1126         long[] res = new long[length()];
1127         for (int i = 0; i < length() - j; i++) {
1128             res[i] = vec[i + j];
1129         }
1130         return new Long64Vector(res);
1131     }
1132 
1133     @Override
1134     public Long64Vector shiftER(int j) {
1135         long[] vec = getElements();
1136         long[] res = new long[length()];
1137         for (int i = 0; i < length() - j; i++){
1138             res[i + j] = vec[i];
1139         }
1140         return new Long64Vector(res);
1141     }
1142 
1143     @Override
1144     @ForceInline
1145     public Long64Vector rearrange(Vector<Long> v,
1146                                   Shuffle<Long> s, Mask<Long> m) {
1147         return this.rearrange(s).blend(v.rearrange(s), m);
1148     }
1149 
1150     @Override
1151     @ForceInline
1152     public Long64Vector rearrange(Shuffle<Long> o1) {
1153         Objects.requireNonNull(o1);
1154         Long64Shuffle s =  (Long64Shuffle)o1;
1155 
1156         return VectorIntrinsics.rearrangeOp(
1157             Long64Vector.class, Long64Shuffle.class, long.class, LENGTH,
1158             this, s,
1159             (v1, s_) -> v1.uOp((i, a) -> {
1160                 int ei = s_.getElement(i);
1161                 return v1.get(ei);
1162             }));
1163     }
1164 
1165     @Override
1166     @ForceInline
1167     public Long64Vector blend(Vector<Long> o1, Mask<Long> o2) {
1168         Objects.requireNonNull(o1);
1169         Objects.requireNonNull(o2);
1170         Long64Vector v = (Long64Vector)o1;
1171         Long64Mask   m = (Long64Mask)o2;
1172 
1173         return VectorIntrinsics.blend(
1174             Long64Vector.class, Long64Mask.class, long.class, LENGTH,
1175             this, v, m,
1176             (v1, v2, m_) -> v1.bOp(v2, (i, a, b) -> m_.getElement(i) ? b : a));
1177     }
1178 
1179     // Accessors
1180 
1181     @Override
1182     public long get(int i) {
1183         if (i < 0 || i >= LENGTH) {
1184             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1185         }
1186         return (long) VectorIntrinsics.extract(
1187                                 Long64Vector.class, long.class, LENGTH,
1188                                 this, i,
1189                                 (vec, ix) -> {
1190                                     long[] vecarr = vec.getElements();
1191                                     return (long)vecarr[ix];
1192                                 });
1193     }
1194 
1195     @Override
1196     public Long64Vector with(int i, long e) {
1197         if (i < 0 || i >= LENGTH) {
1198             throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + LENGTH);
1199         }
1200         return VectorIntrinsics.insert(
1201                                 Long64Vector.class, long.class, LENGTH,
1202                                 this, i, (long)e,
1203                                 (v, ix, bits) -> {
1204                                     long[] res = v.getElements().clone();
1205                                     res[ix] = (long)bits;
1206                                     return new Long64Vector(res);
1207                                 });
1208     }
1209 
1210     // Mask
1211 
1212     static final class Long64Mask extends AbstractMask<Long> {
1213         static final Long64Mask TRUE_MASK = new Long64Mask(true);
1214         static final Long64Mask FALSE_MASK = new Long64Mask(false);
1215 
1216         private final boolean[] bits; // Don't access directly, use getBits() instead.
1217 
1218         public Long64Mask(boolean[] bits) {
1219             this(bits, 0);
1220         }
1221 
1222         public Long64Mask(boolean[] bits, int offset) {
1223             boolean[] a = new boolean[species().length()];
1224             for (int i = 0; i < a.length; i++) {
1225                 a[i] = bits[offset + i];
1226             }
1227             this.bits = a;
1228         }
1229 
1230         public Long64Mask(boolean val) {
1231             boolean[] bits = new boolean[species().length()];
1232             Arrays.fill(bits, val);
1233             this.bits = bits;
1234         }
1235 
1236         boolean[] getBits() {
1237             return VectorIntrinsics.maybeRebox(this).bits;
1238         }
1239 
1240         @Override
1241         Long64Mask uOp(MUnOp f) {
1242             boolean[] res = new boolean[species().length()];
1243             boolean[] bits = getBits();
1244             for (int i = 0; i < species().length(); i++) {
1245                 res[i] = f.apply(i, bits[i]);
1246             }
1247             return new Long64Mask(res);
1248         }
1249 
1250         @Override
1251         Long64Mask bOp(Mask<Long> o, MBinOp f) {
1252             boolean[] res = new boolean[species().length()];
1253             boolean[] bits = getBits();
1254             boolean[] mbits = ((Long64Mask)o).getBits();
1255             for (int i = 0; i < species().length(); i++) {
1256                 res[i] = f.apply(i, bits[i], mbits[i]);
1257             }
1258             return new Long64Mask(res);
1259         }
1260 
1261         @Override
1262         public Long64Species species() {
1263             return SPECIES;
1264         }
1265 
1266         @Override
1267         public Long64Vector toVector() {
1268             long[] res = new long[species().length()];
1269             boolean[] bits = getBits();
1270             for (int i = 0; i < species().length(); i++) {
1271                 // -1 will result in the most significant bit being set in
1272                 // addition to some or all other bits
1273                 res[i] = (long) (bits[i] ? -1 : 0);
1274             }
1275             return new Long64Vector(res);
1276         }
1277 
1278         // Unary operations
1279 
1280         @Override
1281         @ForceInline
1282         public Long64Mask not() {
1283             return (Long64Mask) VectorIntrinsics.unaryOp(
1284                                              VECTOR_OP_NOT, Long64Mask.class, long.class, LENGTH,
1285                                              this,
1286                                              (m1) -> m1.uOp((i, a) -> !a));
1287         }
1288 
1289         // Binary operations
1290 
1291         @Override
1292         @ForceInline
1293         public Long64Mask and(Mask<Long> o) {
1294             Objects.requireNonNull(o);
1295             Long64Mask m = (Long64Mask)o;
1296             return VectorIntrinsics.binaryOp(VECTOR_OP_AND, Long64Mask.class, long.class, LENGTH,
1297                                              this, m,
1298                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a & b));
1299         }
1300 
1301         @Override
1302         @ForceInline
1303         public Long64Mask or(Mask<Long> o) {
1304             Objects.requireNonNull(o);
1305             Long64Mask m = (Long64Mask)o;
1306             return VectorIntrinsics.binaryOp(VECTOR_OP_OR, Long64Mask.class, long.class, LENGTH,
1307                                              this, m,
1308                                              (m1, m2) -> m1.bOp(m2, (i, a, b) -> a | b));
1309         }
1310 
1311         // Reductions
1312 
1313         @Override
1314         @ForceInline
1315         public boolean anyTrue() {
1316             return VectorIntrinsics.test(BT_ne, Long64Mask.class, long.class, LENGTH,
1317                                          this, this,
1318                                          (m, __) -> anyTrueHelper(((Long64Mask)m).getBits()));
1319         }
1320 
1321         @Override
1322         @ForceInline
1323         public boolean allTrue() {
1324             return VectorIntrinsics.test(BT_overflow, Long64Mask.class, long.class, LENGTH,
1325                                          this, LongVector.maskAllTrue(species()),
1326                                          (m, __) -> allTrueHelper(((Long64Mask)m).getBits()));
1327         }
1328     }
1329 
1330     // Shuffle
1331 
1332     static final class Long64Shuffle extends AbstractShuffle<Long> {
1333         Long64Shuffle(byte[] reorder) {
1334             super(reorder);
1335         }
1336 
1337         public Long64Shuffle(int[] reorder) {
1338             super(reorder);
1339         }
1340 
1341         public Long64Shuffle(int[] reorder, int i) {
1342             super(reorder, i);
1343         }
1344 
1345         public Long64Shuffle(IntUnaryOperator f) {
1346             super(f);
1347         }
1348 
1349         @Override
1350         public Long64Species species() {
1351             return SPECIES;
1352         }
1353 
1354         @Override
1355         public LongVector toVector() {
1356             long[] va = new long[SPECIES.length()];
1357             for (int i = 0; i < va.length; i++) {
1358               va[i] = (long) getElement(i);
1359             }
1360             return LongVector.fromArray(SPECIES, va, 0);
1361         }
1362 
1363         @Override
1364         public Long64Shuffle rearrange(Vector.Shuffle<Long> o) {
1365             Long64Shuffle s = (Long64Shuffle) o;
1366             byte[] r = new byte[reorder.length];
1367             for (int i = 0; i < reorder.length; i++) {
1368                 r[i] = reorder[s.reorder[i]];
1369             }
1370             return new Long64Shuffle(r);
1371         }
1372     }
1373 
1374     // Species
1375 
1376     @Override
1377     public Long64Species species() {
1378         return SPECIES;
1379     }
1380 
1381     static final class Long64Species extends LongSpecies {
1382         static final int BIT_SIZE = Shape.S_64_BIT.bitSize();
1383 
1384         static final int LENGTH = BIT_SIZE / Long.SIZE;
1385 
1386         @Override
1387         public String toString() {
1388            StringBuilder sb = new StringBuilder("Shape[");
1389            sb.append(bitSize()).append(" bits, ");
1390            sb.append(length()).append(" ").append(long.class.getSimpleName()).append("s x ");
1391            sb.append(elementSize()).append(" bits");
1392            sb.append("]");
1393            return sb.toString();
1394         }
1395 
1396         @Override
1397         @ForceInline
1398         public int bitSize() {
1399             return BIT_SIZE;
1400         }
1401 
1402         @Override
1403         @ForceInline
1404         public int length() {
1405             return LENGTH;
1406         }
1407 
1408         @Override
1409         @ForceInline
1410         public Class<Long> elementType() {
1411             return long.class;
1412         }
1413 
1414         @Override
1415         @ForceInline
1416         public Class<?> boxType() {
1417             return Long64Vector.class;
1418         }
1419 
1420         @Override
1421         @ForceInline
1422         public Class<?> maskType() {
1423             return Long64Mask.class;
1424         }
1425 
1426         @Override
1427         @ForceInline
1428         public int elementSize() {
1429             return Long.SIZE;
1430         }
1431 
1432         @Override
1433         @ForceInline
1434         @SuppressWarnings("unchecked")
1435         Class<?> vectorType() {
1436             return Long64Vector.class;
1437         }
1438 
1439         @Override
1440         @ForceInline
1441         public Shape shape() {
1442             return Shape.S_64_BIT;
1443         }
1444 
1445        @Override
1446        IntVector.IntSpecies indexSpecies() {
1447           return INDEX_SPEC;
1448        }
1449 
1450         @Override
1451         Long64Vector op(FOp f) {
1452             long[] res = new long[length()];
1453             for (int i = 0; i < length(); i++) {
1454                 res[i] = f.apply(i);
1455             }
1456             return new Long64Vector(res);
1457         }
1458 
1459         @Override
1460         Long64Vector op(Mask<Long> o, FOp f) {
1461             long[] res = new long[length()];
1462             boolean[] mbits = ((Long64Mask)o).getBits();
1463             for (int i = 0; i < length(); i++) {
1464                 if (mbits[i]) {
1465                     res[i] = f.apply(i);
1466                 }
1467             }
1468             return new Long64Vector(res);
1469         }
1470 
1471         @Override
1472         Long64Mask opm(FOpm f) {
1473             boolean[] res = new boolean[length()];
1474             for (int i = 0; i < length(); i++) {
1475                 res[i] = (boolean)f.apply(i);
1476             }
1477             return new Long64Mask(res);
1478         }
1479 
1480         // Factories
1481 
1482         @Override
1483         @ForceInline
1484         public Long64Vector zero() {
1485             return VectorIntrinsics.broadcastCoerced(Long64Vector.class, long.class, LENGTH,
1486                                                      0, SPECIES,
1487                                                      ((bits, s) -> ((Long64Species)s).op(i -> (long)bits)));
1488         }
1489 
1490         @Override
1491         @ForceInline
1492         public Long64Vector broadcast(long e) {
1493             return VectorIntrinsics.broadcastCoerced(
1494                 Long64Vector.class, long.class, LENGTH,
1495                 e, SPECIES,
1496                 ((bits, s) -> ((Long64Species)s).op(i -> (long)bits)));
1497         }
1498 
1499         @Override
1500         @ForceInline
1501         public Long64Vector scalars(long... es) {
1502             Objects.requireNonNull(es);
1503             int ix = VectorIntrinsics.checkIndex(0, es.length, LENGTH);
1504             return VectorIntrinsics.load(Long64Vector.class, long.class, LENGTH,
1505                                          es, Unsafe.ARRAY_LONG_BASE_OFFSET,
1506                                          es, ix, SPECIES,
1507                                          (c, idx, s) -> ((Long64Species)s).op(n -> c[idx + n]));
1508         }
1509 
1510         @Override
1511         @ForceInline
1512         public <E> Long64Mask cast(Mask<E> m) {
1513             if (m.length() != LENGTH)
1514                 throw new IllegalArgumentException("Mask length this species length differ");
1515             return new Long64Mask(m.toArray());
1516         }
1517 
1518         @Override
1519         @ForceInline
1520         public <E> Long64Shuffle cast(Shuffle<E> s) {
1521             if (s.length() != LENGTH)
1522                 throw new IllegalArgumentException("Shuffle length this species length differ");
1523             return new Long64Shuffle(s.toArray());
1524         }
1525     }
1526 }