< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java

Print this page
rev 55891 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz
rev 55894 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz


 145 
 146     @Override
 147     long rOp(long v, FBinOp f) {
 148         long[] vec = getElements();
 149         for (int i = 0; i < length(); i++) {
 150             v = f.apply(i, v, vec[i]);
 151         }
 152         return v;
 153     }
 154 
 155     @Override
 156     @ForceInline
 157     public <F> Vector<F> cast(VectorSpecies<F> s) {
 158         Objects.requireNonNull(s);
 159         if (s.length() != LENGTH)
 160             throw new IllegalArgumentException("Vector length this species length differ");
 161 
 162         return VectorIntrinsics.cast(
 163             Long64Vector.class,
 164             long.class, LENGTH,
 165             s.boxType(),
 166             s.elementType(), LENGTH,
 167             this, s,
 168             (species, vector) -> vector.castDefault(species)
 169         );
 170     }
 171 
 172     @SuppressWarnings("unchecked")
 173     @ForceInline
 174     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 175         int limit = s.length();
 176 
 177         Class<?> stype = s.elementType();
 178         if (stype == byte.class) {
 179             byte[] a = new byte[limit];
 180             for (int i = 0; i < limit; i++) {
 181                 a[i] = (byte) this.lane(i);
 182             }
 183             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 184         } else if (stype == short.class) {
 185             short[] a = new short[limit];


 283                 (species, vector) -> vector.defaultReinterpret(species)
 284             );
 285         } else if (stype == double.class) {
 286             return VectorIntrinsics.reinterpret(
 287                 Long64Vector.class,
 288                 long.class, LENGTH,
 289                 Double64Vector.class,
 290                 double.class, Double64Vector.LENGTH,
 291                 this, s,
 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else {
 295             throw new UnsupportedOperationException("Bad lane type for casting.");
 296         }
 297     }
 298 
 299     @Override
 300     @ForceInline
 301     public LongVector reshape(VectorSpecies<Long> s) {
 302         Objects.requireNonNull(s);
 303         if (s.bitSize() == 64 && (s.boxType() == Long64Vector.class)) {
 304             return VectorIntrinsics.reinterpret(
 305                 Long64Vector.class,
 306                 long.class, LENGTH,
 307                 Long64Vector.class,
 308                 long.class, Long64Vector.LENGTH,
 309                 this, s,
 310                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 311             );
 312         } else if (s.bitSize() == 128 && (s.boxType() == Long128Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 Long64Vector.class,
 315                 long.class, LENGTH,
 316                 Long128Vector.class,
 317                 long.class, Long128Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 256 && (s.boxType() == Long256Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 Long64Vector.class,
 324                 long.class, LENGTH,
 325                 Long256Vector.class,
 326                 long.class, Long256Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 512 && (s.boxType() == Long512Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 Long64Vector.class,
 333                 long.class, LENGTH,
 334                 Long512Vector.class,
 335                 long.class, Long512Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 338             );
 339         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 340                 && (s.bitSize() % 128 == 0) && (s.boxType() == LongMaxVector.class)) {
 341             return VectorIntrinsics.reinterpret(
 342                 Long64Vector.class,
 343                 long.class, LENGTH,
 344                 LongMaxVector.class,
 345                 long.class, LongMaxVector.LENGTH,
 346                 this, s,
 347                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 348             );
 349         } else {
 350             throw new InternalError("Unimplemented size");
 351         }
 352     }
 353 
 354     // Binary operations with scalars
 355 
 356     @Override
 357     @ForceInline
 358     public LongVector add(long o) {
 359         return add((Long64Vector)LongVector.broadcast(SPECIES, o));
 360     }


 647     @Override
 648     @ForceInline
 649     public Long64Vector and(Vector<Long> v, VectorMask<Long> m) {
 650         return blend(and(v), m);
 651     }
 652 
 653     @Override
 654     @ForceInline
 655     public Long64Vector or(Vector<Long> v, VectorMask<Long> m) {
 656         return blend(or(v), m);
 657     }
 658 
 659     @Override
 660     @ForceInline
 661     public Long64Vector xor(Vector<Long> v, VectorMask<Long> m) {
 662         return blend(xor(v), m);
 663     }
 664 
 665     @Override
 666     @ForceInline
 667     public Long64Vector shiftL(int s) {
 668         return VectorIntrinsics.broadcastInt(
 669             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 670             this, s,
 671             (v, i) -> v.uOp((__, a) -> (long) (a << i)));
 672     }
 673 
 674     @Override
 675     @ForceInline
 676     public Long64Vector shiftL(int s, VectorMask<Long> m) {
 677         return blend(shiftL(s), m);
 678     }
 679 
 680     @Override
 681     @ForceInline
 682     public Long64Vector shiftR(int s) {
 683         return VectorIntrinsics.broadcastInt(
 684             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 685             this, s,
 686             (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
 687     }
 688 
 689     @Override
 690     @ForceInline
 691     public Long64Vector shiftR(int s, VectorMask<Long> m) {
 692         return blend(shiftR(s), m);
 693     }
 694 
 695     @Override
 696     @ForceInline
 697     public Long64Vector aShiftR(int s) {
 698         return VectorIntrinsics.broadcastInt(
 699             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 700             this, s,
 701             (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
 702     }
 703 
 704     @Override
 705     @ForceInline
 706     public Long64Vector aShiftR(int s, VectorMask<Long> m) {
 707         return blend(aShiftR(s), m);
 708     }
 709 
 710     @Override
 711     @ForceInline
 712     public Long64Vector shiftL(Vector<Long> s) {
 713         Long64Vector shiftv = (Long64Vector)s;
 714         // As per shift specification for Java, mask the shift count.
 715         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 716         return VectorIntrinsics.binaryOp(
 717             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 718             this, shiftv,
 719             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
 720     }
 721 
 722     @Override
 723     @ForceInline
 724     public Long64Vector shiftR(Vector<Long> s) {
 725         Long64Vector shiftv = (Long64Vector)s;
 726         // As per shift specification for Java, mask the shift count.
 727         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 728         return VectorIntrinsics.binaryOp(
 729             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 730             this, shiftv,
 731             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
 732     }
 733 
 734     @Override
 735     @ForceInline
 736     public Long64Vector aShiftR(Vector<Long> s) {
 737         Long64Vector shiftv = (Long64Vector)s;
 738         // As per shift specification for Java, mask the shift count.
 739         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 740         return VectorIntrinsics.binaryOp(
 741             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 742             this, shiftv,
 743             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
 744     }
 745     // Ternary operations
 746 
 747 
 748     // Type specific horizontal reductions
 749 
 750     @Override
 751     @ForceInline
 752     public long addAll() {
 753         return (long) VectorIntrinsics.reductionCoerced(
 754             VECTOR_OP_ADD, Long64Vector.class, long.class, LENGTH,
 755             this,
 756             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));
 757     }
 758 
 759     @Override
 760     @ForceInline
 761     public long andAll() {
 762         return (long) VectorIntrinsics.reductionCoerced(
 763             VECTOR_OP_AND, Long64Vector.class, long.class, LENGTH,
 764             this,
 765             v -> (long) v.rOp((long) -1, (i, a, b) -> (long) (a & b)));
 766     }
 767 
 768     @Override
 769     @ForceInline
 770     public long andAll(VectorMask<Long> m) {
 771         return LongVector.broadcast(SPECIES, (long) -1).blend(this, m).andAll();
 772     }
 773 
 774     @Override
 775     @ForceInline
 776     public long minAll() {
 777         return (long) VectorIntrinsics.reductionCoerced(
 778             VECTOR_OP_MIN, Long64Vector.class, long.class, LENGTH,
 779             this,
 780             v -> (long) v.rOp(Long.MAX_VALUE , (i, a, b) -> (long) Math.min(a, b)));
 781     }
 782 
 783     @Override
 784     @ForceInline
 785     public long maxAll() {
 786         return (long) VectorIntrinsics.reductionCoerced(
 787             VECTOR_OP_MAX, Long64Vector.class, long.class, LENGTH,
 788             this,
 789             v -> (long) v.rOp(Long.MIN_VALUE , (i, a, b) -> (long) Math.max(a, b)));
 790     }
 791 
 792     @Override
 793     @ForceInline
 794     public long mulAll() {
 795         return (long) VectorIntrinsics.reductionCoerced(
 796             VECTOR_OP_MUL, Long64Vector.class, long.class, LENGTH,
 797             this,
 798             v -> (long) v.rOp((long) 1, (i, a, b) -> (long) (a * b)));
 799     }
 800 
 801     @Override
 802     @ForceInline
 803     public long orAll() {
 804         return (long) VectorIntrinsics.reductionCoerced(
 805             VECTOR_OP_OR, Long64Vector.class, long.class, LENGTH,
 806             this,
 807             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a | b)));
 808     }
 809 
 810     @Override
 811     @ForceInline
 812     public long orAll(VectorMask<Long> m) {
 813         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).orAll();
 814     }
 815 
 816     @Override
 817     @ForceInline
 818     public long xorAll() {
 819         return (long) VectorIntrinsics.reductionCoerced(
 820             VECTOR_OP_XOR, Long64Vector.class, long.class, LENGTH,
 821             this,
 822             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a ^ b)));
 823     }
 824 
 825     @Override
 826     @ForceInline
 827     public long xorAll(VectorMask<Long> m) {
 828         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).xorAll();
 829     }
 830 
 831 
 832     @Override
 833     @ForceInline
 834     public long addAll(VectorMask<Long> m) {
 835         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).addAll();
 836     }
 837 
 838 
 839     @Override
 840     @ForceInline
 841     public long mulAll(VectorMask<Long> m) {
 842         return LongVector.broadcast(SPECIES, (long) 1).blend(this, m).mulAll();
 843     }
 844 
 845     @Override
 846     @ForceInline
 847     public long minAll(VectorMask<Long> m) {
 848         return LongVector.broadcast(SPECIES, Long.MAX_VALUE).blend(this, m).minAll();
 849     }
 850 
 851     @Override
 852     @ForceInline
 853     public long maxAll(VectorMask<Long> m) {
 854         return LongVector.broadcast(SPECIES, Long.MIN_VALUE).blend(this, m).maxAll();
 855     }
 856 
 857     @Override
 858     @ForceInline
 859     public VectorShuffle<Long> toShuffle() {
 860         long[] a = toArray();
 861         int[] sa = new int[a.length];
 862         for (int i = 0; i < a.length; i++) {
 863             sa[i] = (int) a[i];
 864         }
 865         return VectorShuffle.fromArray(SPECIES, sa, 0);
 866     }
 867 
 868     // Memory operations
 869 
 870     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_LONG_INDEX_SCALE);
 871     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 872 
 873     @Override
 874     @ForceInline


1077 
1078     @Override
1079     void forEach(VectorMask<Long> o, FUnCon f) {
1080         boolean[] mbits = ((Long64Mask)o).getBits();
1081         forEach((i, a) -> {
1082             if (mbits[i]) { f.apply(i, a); }
1083         });
1084     }
1085 
1086 
1087     Double64Vector toFP() {
1088         long[] vec = getElements();
1089         double[] res = new double[this.species().length()];
1090         for(int i = 0; i < this.species().length(); i++){
1091             res[i] = Double.longBitsToDouble(vec[i]);
1092         }
1093         return new Double64Vector(res);
1094     }
1095 
1096     @Override
1097     public Long64Vector rotateEL(int j) {
1098         long[] vec = getElements();
1099         long[] res = new long[length()];
1100         for (int i = 0; i < length(); i++){
1101             res[(j + i) % length()] = vec[i];
1102         }
1103         return new Long64Vector(res);
1104     }
1105 
1106     @Override
1107     public Long64Vector rotateER(int j) {
1108         long[] vec = getElements();
1109         long[] res = new long[length()];
1110         for (int i = 0; i < length(); i++){
1111             int z = i - j;
1112             if(j < 0) {
1113                 res[length() + z] = vec[i];
1114             } else {
1115                 res[z] = vec[i];
1116             }
1117         }
1118         return new Long64Vector(res);
1119     }
1120 
1121     @Override
1122     public Long64Vector shiftEL(int j) {
1123         long[] vec = getElements();
1124         long[] res = new long[length()];
1125         for (int i = 0; i < length() - j; i++) {
1126             res[i] = vec[i + j];
1127         }
1128         return new Long64Vector(res);
1129     }
1130 
1131     @Override
1132     public Long64Vector shiftER(int j) {
1133         long[] vec = getElements();
1134         long[] res = new long[length()];
1135         for (int i = 0; i < length() - j; i++){
1136             res[i + j] = vec[i];
1137         }
1138         return new Long64Vector(res);
1139     }
1140 
1141     @Override
1142     @ForceInline
1143     public Long64Vector rearrange(Vector<Long> v,
1144                                   VectorShuffle<Long> s, VectorMask<Long> m) {
1145         return this.rearrange(s).blend(v.rearrange(s), m);
1146     }
1147 
1148     @Override
1149     @ForceInline
1150     public Long64Vector rearrange(VectorShuffle<Long> o1) {
1151         Objects.requireNonNull(o1);
1152         Long64Shuffle s =  (Long64Shuffle)o1;




 145 
 146     @Override
 147     long rOp(long v, FBinOp f) {
 148         long[] vec = getElements();
 149         for (int i = 0; i < length(); i++) {
 150             v = f.apply(i, v, vec[i]);
 151         }
 152         return v;
 153     }
 154 
 155     @Override
 156     @ForceInline
 157     public <F> Vector<F> cast(VectorSpecies<F> s) {
 158         Objects.requireNonNull(s);
 159         if (s.length() != LENGTH)
 160             throw new IllegalArgumentException("Vector length this species length differ");
 161 
 162         return VectorIntrinsics.cast(
 163             Long64Vector.class,
 164             long.class, LENGTH,
 165             s.vectorType(),
 166             s.elementType(), LENGTH,
 167             this, s,
 168             (species, vector) -> vector.castDefault(species)
 169         );
 170     }
 171 
 172     @SuppressWarnings("unchecked")
 173     @ForceInline
 174     private <F> Vector<F> castDefault(VectorSpecies<F> s) {
 175         int limit = s.length();
 176 
 177         Class<?> stype = s.elementType();
 178         if (stype == byte.class) {
 179             byte[] a = new byte[limit];
 180             for (int i = 0; i < limit; i++) {
 181                 a[i] = (byte) this.lane(i);
 182             }
 183             return (Vector) ByteVector.fromArray((VectorSpecies<Byte>) s, a, 0);
 184         } else if (stype == short.class) {
 185             short[] a = new short[limit];


 283                 (species, vector) -> vector.defaultReinterpret(species)
 284             );
 285         } else if (stype == double.class) {
 286             return VectorIntrinsics.reinterpret(
 287                 Long64Vector.class,
 288                 long.class, LENGTH,
 289                 Double64Vector.class,
 290                 double.class, Double64Vector.LENGTH,
 291                 this, s,
 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else {
 295             throw new UnsupportedOperationException("Bad lane type for casting.");
 296         }
 297     }
 298 
 299     @Override
 300     @ForceInline
 301     public LongVector reshape(VectorSpecies<Long> s) {
 302         Objects.requireNonNull(s);
 303         if (s.bitSize() == 64 && (s.vectorType() == Long64Vector.class)) {
 304             return VectorIntrinsics.reinterpret(
 305                 Long64Vector.class,
 306                 long.class, LENGTH,
 307                 Long64Vector.class,
 308                 long.class, Long64Vector.LENGTH,
 309                 this, s,
 310                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 311             );
 312         } else if (s.bitSize() == 128 && (s.vectorType() == Long128Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 Long64Vector.class,
 315                 long.class, LENGTH,
 316                 Long128Vector.class,
 317                 long.class, Long128Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 256 && (s.vectorType() == Long256Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 Long64Vector.class,
 324                 long.class, LENGTH,
 325                 Long256Vector.class,
 326                 long.class, Long256Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 512 && (s.vectorType() == Long512Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 Long64Vector.class,
 333                 long.class, LENGTH,
 334                 Long512Vector.class,
 335                 long.class, Long512Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 338             );
 339         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 340                 && (s.bitSize() % 128 == 0) && (s.vectorType() == LongMaxVector.class)) {
 341             return VectorIntrinsics.reinterpret(
 342                 Long64Vector.class,
 343                 long.class, LENGTH,
 344                 LongMaxVector.class,
 345                 long.class, LongMaxVector.LENGTH,
 346                 this, s,
 347                 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
 348             );
 349         } else {
 350             throw new InternalError("Unimplemented size");
 351         }
 352     }
 353 
 354     // Binary operations with scalars
 355 
 356     @Override
 357     @ForceInline
 358     public LongVector add(long o) {
 359         return add((Long64Vector)LongVector.broadcast(SPECIES, o));
 360     }


 647     @Override
 648     @ForceInline
 649     public Long64Vector and(Vector<Long> v, VectorMask<Long> m) {
 650         return blend(and(v), m);
 651     }
 652 
 653     @Override
 654     @ForceInline
 655     public Long64Vector or(Vector<Long> v, VectorMask<Long> m) {
 656         return blend(or(v), m);
 657     }
 658 
 659     @Override
 660     @ForceInline
 661     public Long64Vector xor(Vector<Long> v, VectorMask<Long> m) {
 662         return blend(xor(v), m);
 663     }
 664 
 665     @Override
 666     @ForceInline
 667     public Long64Vector shiftLeft(int s) {
 668         return VectorIntrinsics.broadcastInt(
 669             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 670             this, s,
 671             (v, i) -> v.uOp((__, a) -> (long) (a << i)));
 672     }
 673 
 674     @Override
 675     @ForceInline
 676     public Long64Vector shiftLeft(int s, VectorMask<Long> m) {
 677         return blend(shiftLeft(s), m);
 678     }
 679 
 680     @Override
 681     @ForceInline
 682     public Long64Vector shiftRight(int s) {
 683         return VectorIntrinsics.broadcastInt(
 684             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 685             this, s,
 686             (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
 687     }
 688 
 689     @Override
 690     @ForceInline
 691     public Long64Vector shiftRight(int s, VectorMask<Long> m) {
 692         return blend(shiftRight(s), m);
 693     }
 694 
 695     @Override
 696     @ForceInline
 697     public Long64Vector shiftArithmeticRight(int s) {
 698         return VectorIntrinsics.broadcastInt(
 699             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 700             this, s,
 701             (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
 702     }
 703 
 704     @Override
 705     @ForceInline
 706     public Long64Vector shiftArithmeticRight(int s, VectorMask<Long> m) {
 707         return blend(shiftArithmeticRight(s), m);
 708     }
 709 
 710     @Override
 711     @ForceInline
 712     public Long64Vector shiftLeft(Vector<Long> s) {
 713         Long64Vector shiftv = (Long64Vector)s;
 714         // As per shift specification for Java, mask the shift count.
 715         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 716         return VectorIntrinsics.binaryOp(
 717             VECTOR_OP_LSHIFT, Long64Vector.class, long.class, LENGTH,
 718             this, shiftv,
 719             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
 720     }
 721 
 722     @Override
 723     @ForceInline
 724     public Long64Vector shiftRight(Vector<Long> s) {
 725         Long64Vector shiftv = (Long64Vector)s;
 726         // As per shift specification for Java, mask the shift count.
 727         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 728         return VectorIntrinsics.binaryOp(
 729             VECTOR_OP_URSHIFT, Long64Vector.class, long.class, LENGTH,
 730             this, shiftv,
 731             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
 732     }
 733 
 734     @Override
 735     @ForceInline
 736     public Long64Vector shiftArithmeticRight(Vector<Long> s) {
 737         Long64Vector shiftv = (Long64Vector)s;
 738         // As per shift specification for Java, mask the shift count.
 739         shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
 740         return VectorIntrinsics.binaryOp(
 741             VECTOR_OP_RSHIFT, Long64Vector.class, long.class, LENGTH,
 742             this, shiftv,
 743             (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
 744     }
 745     // Ternary operations
 746 
 747 
 748     // Type specific horizontal reductions
 749 
 750     @Override
 751     @ForceInline
 752     public long addLanes() {
 753         return (long) VectorIntrinsics.reductionCoerced(
 754             VECTOR_OP_ADD, Long64Vector.class, long.class, LENGTH,
 755             this,
 756             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));
 757     }
 758 
 759     @Override
 760     @ForceInline
 761     public long andLanes() {
 762         return (long) VectorIntrinsics.reductionCoerced(
 763             VECTOR_OP_AND, Long64Vector.class, long.class, LENGTH,
 764             this,
 765             v -> (long) v.rOp((long) -1, (i, a, b) -> (long) (a & b)));
 766     }
 767 
 768     @Override
 769     @ForceInline
 770     public long andLanes(VectorMask<Long> m) {
 771         return LongVector.broadcast(SPECIES, (long) -1).blend(this, m).andLanes();
 772     }
 773 
 774     @Override
 775     @ForceInline
 776     public long minLanes() {
 777         return (long) VectorIntrinsics.reductionCoerced(
 778             VECTOR_OP_MIN, Long64Vector.class, long.class, LENGTH,
 779             this,
 780             v -> (long) v.rOp(Long.MAX_VALUE , (i, a, b) -> (long) Math.min(a, b)));
 781     }
 782 
 783     @Override
 784     @ForceInline
 785     public long maxLanes() {
 786         return (long) VectorIntrinsics.reductionCoerced(
 787             VECTOR_OP_MAX, Long64Vector.class, long.class, LENGTH,
 788             this,
 789             v -> (long) v.rOp(Long.MIN_VALUE , (i, a, b) -> (long) Math.max(a, b)));
 790     }
 791 
 792     @Override
 793     @ForceInline
 794     public long mulLanes() {
 795         return (long) VectorIntrinsics.reductionCoerced(
 796             VECTOR_OP_MUL, Long64Vector.class, long.class, LENGTH,
 797             this,
 798             v -> (long) v.rOp((long) 1, (i, a, b) -> (long) (a * b)));
 799     }
 800 
 801     @Override
 802     @ForceInline
 803     public long orLanes() {
 804         return (long) VectorIntrinsics.reductionCoerced(
 805             VECTOR_OP_OR, Long64Vector.class, long.class, LENGTH,
 806             this,
 807             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a | b)));
 808     }
 809 
 810     @Override
 811     @ForceInline
 812     public long orLanes(VectorMask<Long> m) {
 813         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).orLanes();
 814     }
 815 
 816     @Override
 817     @ForceInline
 818     public long xorLanes() {
 819         return (long) VectorIntrinsics.reductionCoerced(
 820             VECTOR_OP_XOR, Long64Vector.class, long.class, LENGTH,
 821             this,
 822             v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a ^ b)));
 823     }
 824 
 825     @Override
 826     @ForceInline
 827     public long xorLanes(VectorMask<Long> m) {
 828         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).xorLanes();
 829     }
 830 
 831 
 832     @Override
 833     @ForceInline
 834     public long addLanes(VectorMask<Long> m) {
 835         return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).addLanes();
 836     }
 837 
 838 
 839     @Override
 840     @ForceInline
 841     public long mulLanes(VectorMask<Long> m) {
 842         return LongVector.broadcast(SPECIES, (long) 1).blend(this, m).mulLanes();
 843     }
 844 
 845     @Override
 846     @ForceInline
 847     public long minLanes(VectorMask<Long> m) {
 848         return LongVector.broadcast(SPECIES, Long.MAX_VALUE).blend(this, m).minLanes();
 849     }
 850 
 851     @Override
 852     @ForceInline
 853     public long maxLanes(VectorMask<Long> m) {
 854         return LongVector.broadcast(SPECIES, Long.MIN_VALUE).blend(this, m).maxLanes();
 855     }
 856 
 857     @Override
 858     @ForceInline
 859     public VectorShuffle<Long> toShuffle() {
 860         long[] a = toArray();
 861         int[] sa = new int[a.length];
 862         for (int i = 0; i < a.length; i++) {
 863             sa[i] = (int) a[i];
 864         }
 865         return VectorShuffle.fromArray(SPECIES, sa, 0);
 866     }
 867 
 868     // Memory operations
 869 
 870     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_LONG_INDEX_SCALE);
 871     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 872 
 873     @Override
 874     @ForceInline


1077 
1078     @Override
1079     void forEach(VectorMask<Long> o, FUnCon f) {
1080         boolean[] mbits = ((Long64Mask)o).getBits();
1081         forEach((i, a) -> {
1082             if (mbits[i]) { f.apply(i, a); }
1083         });
1084     }
1085 
1086 
1087     Double64Vector toFP() {
1088         long[] vec = getElements();
1089         double[] res = new double[this.species().length()];
1090         for(int i = 0; i < this.species().length(); i++){
1091             res[i] = Double.longBitsToDouble(vec[i]);
1092         }
1093         return new Double64Vector(res);
1094     }
1095 
1096     @Override
1097     public Long64Vector rotateLanesLeft(int j) {
1098         long[] vec = getElements();
1099         long[] res = new long[length()];
1100         for (int i = 0; i < length(); i++){
1101             res[(j + i) % length()] = vec[i];
1102         }
1103         return new Long64Vector(res);
1104     }
1105 
1106     @Override
1107     public Long64Vector rotateLanesRight(int j) {
1108         long[] vec = getElements();
1109         long[] res = new long[length()];
1110         for (int i = 0; i < length(); i++){
1111             int z = i - j;
1112             if(j < 0) {
1113                 res[length() + z] = vec[i];
1114             } else {
1115                 res[z] = vec[i];
1116             }
1117         }
1118         return new Long64Vector(res);
1119     }
1120 
1121     @Override
1122     public Long64Vector shiftLanesLeft(int j) {
1123         long[] vec = getElements();
1124         long[] res = new long[length()];
1125         for (int i = 0; i < length() - j; i++) {
1126             res[i] = vec[i + j];
1127         }
1128         return new Long64Vector(res);
1129     }
1130 
1131     @Override
1132     public Long64Vector shiftLanesRight(int j) {
1133         long[] vec = getElements();
1134         long[] res = new long[length()];
1135         for (int i = 0; i < length() - j; i++){
1136             res[i + j] = vec[i];
1137         }
1138         return new Long64Vector(res);
1139     }
1140 
1141     @Override
1142     @ForceInline
1143     public Long64Vector rearrange(Vector<Long> v,
1144                                   VectorShuffle<Long> s, VectorMask<Long> m) {
1145         return this.rearrange(s).blend(v.rearrange(s), m);
1146     }
1147 
1148     @Override
1149     @ForceInline
1150     public Long64Vector rearrange(VectorShuffle<Long> o1) {
1151         Objects.requireNonNull(o1);
1152         Long64Shuffle s =  (Long64Shuffle)o1;


< prev index next >