< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.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


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


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


 640     @Override
 641     @ForceInline
 642     public Short512Vector and(Vector<Short> v, VectorMask<Short> m) {
 643         return blend(and(v), m);
 644     }
 645 
 646     @Override
 647     @ForceInline
 648     public Short512Vector or(Vector<Short> v, VectorMask<Short> m) {
 649         return blend(or(v), m);
 650     }
 651 
 652     @Override
 653     @ForceInline
 654     public Short512Vector xor(Vector<Short> v, VectorMask<Short> m) {
 655         return blend(xor(v), m);
 656     }
 657 
 658     @Override
 659     @ForceInline
 660     public Short512Vector shiftL(int s) {
 661         return VectorIntrinsics.broadcastInt(
 662             VECTOR_OP_LSHIFT, Short512Vector.class, short.class, LENGTH,
 663             this, s,
 664             (v, i) -> v.uOp((__, a) -> (short) (a << (i & 15))));
 665     }
 666 
 667     @Override
 668     @ForceInline
 669     public Short512Vector shiftL(int s, VectorMask<Short> m) {
 670         return blend(shiftL(s), m);
 671     }
 672 
 673     @Override
 674     @ForceInline
 675     public Short512Vector shiftR(int s) {









 676         return VectorIntrinsics.broadcastInt(
 677             VECTOR_OP_URSHIFT, Short512Vector.class, short.class, LENGTH,
 678             this, s,
 679             (v, i) -> v.uOp((__, a) -> (short) ((a & 0xFFFF) >>> (i & 15))));






 680     }
 681 
 682     @Override
 683     @ForceInline
 684     public Short512Vector shiftR(int s, VectorMask<Short> m) {
 685         return blend(shiftR(s), m);



 686     }
 687 
 688     @Override
 689     @ForceInline
 690     public Short512Vector aShiftR(int s) {
 691         return VectorIntrinsics.broadcastInt(
 692             VECTOR_OP_RSHIFT, Short512Vector.class, short.class, LENGTH,
 693             this, s,
 694             (v, i) -> v.uOp((__, a) -> (short) (a >> (i & 15))));






 695     }
 696 
 697     @Override
 698     @ForceInline
 699     public Short512Vector aShiftR(int s, VectorMask<Short> m) {
 700         return blend(aShiftR(s), m);



 701     }
 702     // Ternary operations
 703 
 704 
 705     // Type specific horizontal reductions
 706 
 707     @Override
 708     @ForceInline
 709     public short addAll() {
 710         return (short) VectorIntrinsics.reductionCoerced(
 711             VECTOR_OP_ADD, Short512Vector.class, short.class, LENGTH,
 712             this,
 713             v -> (long) v.rOp((short) 0, (i, a, b) -> (short) (a + b)));
 714     }
 715 
 716     @Override
 717     @ForceInline
 718     public short andAll() {
 719         return (short) VectorIntrinsics.reductionCoerced(
 720             VECTOR_OP_AND, Short512Vector.class, short.class, LENGTH,
 721             this,
 722             v -> (long) v.rOp((short) -1, (i, a, b) -> (short) (a & b)));
 723     }
 724 
 725     @Override
 726     @ForceInline
 727     public short andAll(VectorMask<Short> m) {
 728         return ShortVector.broadcast(SPECIES, (short) -1).blend(this, m).andAll();
 729     }
 730 
 731     @Override
 732     @ForceInline
 733     public short minAll() {
 734         return (short) VectorIntrinsics.reductionCoerced(
 735             VECTOR_OP_MIN, Short512Vector.class, short.class, LENGTH,
 736             this,
 737             v -> (long) v.rOp(Short.MAX_VALUE , (i, a, b) -> (short) Math.min(a, b)));
 738     }
 739 
 740     @Override
 741     @ForceInline
 742     public short maxAll() {
 743         return (short) VectorIntrinsics.reductionCoerced(
 744             VECTOR_OP_MAX, Short512Vector.class, short.class, LENGTH,
 745             this,
 746             v -> (long) v.rOp(Short.MIN_VALUE , (i, a, b) -> (short) Math.max(a, b)));
 747     }
 748 
 749     @Override
 750     @ForceInline
 751     public short mulAll() {
 752         return (short) VectorIntrinsics.reductionCoerced(
 753             VECTOR_OP_MUL, Short512Vector.class, short.class, LENGTH,
 754             this,
 755             v -> (long) v.rOp((short) 1, (i, a, b) -> (short) (a * b)));
 756     }
 757 
 758     @Override
 759     @ForceInline
 760     public short orAll() {
 761         return (short) VectorIntrinsics.reductionCoerced(
 762             VECTOR_OP_OR, Short512Vector.class, short.class, LENGTH,
 763             this,
 764             v -> (long) v.rOp((short) 0, (i, a, b) -> (short) (a | b)));
 765     }
 766 
 767     @Override
 768     @ForceInline
 769     public short orAll(VectorMask<Short> m) {
 770         return ShortVector.broadcast(SPECIES, (short) 0).blend(this, m).orAll();
 771     }
 772 
 773     @Override
 774     @ForceInline
 775     public short xorAll() {
 776         return (short) VectorIntrinsics.reductionCoerced(
 777             VECTOR_OP_XOR, Short512Vector.class, short.class, LENGTH,
 778             this,
 779             v -> (long) v.rOp((short) 0, (i, a, b) -> (short) (a ^ b)));
 780     }
 781 
 782     @Override
 783     @ForceInline
 784     public short xorAll(VectorMask<Short> m) {
 785         return ShortVector.broadcast(SPECIES, (short) 0).blend(this, m).xorAll();
 786     }
 787 
 788 
 789     @Override
 790     @ForceInline
 791     public short addAll(VectorMask<Short> m) {
 792         return ShortVector.broadcast(SPECIES, (short) 0).blend(this, m).addAll();
 793     }
 794 
 795 
 796     @Override
 797     @ForceInline
 798     public short mulAll(VectorMask<Short> m) {
 799         return ShortVector.broadcast(SPECIES, (short) 1).blend(this, m).mulAll();
 800     }
 801 
 802     @Override
 803     @ForceInline
 804     public short minAll(VectorMask<Short> m) {
 805         return ShortVector.broadcast(SPECIES, Short.MAX_VALUE).blend(this, m).minAll();
 806     }
 807 
 808     @Override
 809     @ForceInline
 810     public short maxAll(VectorMask<Short> m) {
 811         return ShortVector.broadcast(SPECIES, Short.MIN_VALUE).blend(this, m).maxAll();
 812     }
 813 
 814     @Override
 815     @ForceInline
 816     public VectorShuffle<Short> toShuffle() {
 817         short[] a = toArray();
 818         int[] sa = new int[a.length];
 819         for (int i = 0; i < a.length; i++) {
 820             sa[i] = (int) a[i];
 821         }
 822         return VectorShuffle.fromArray(SPECIES, sa, 0);
 823     }
 824 
 825     // Memory operations
 826 
 827     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE);
 828     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
 829 
 830     @Override
 831     @ForceInline


1012 
1013     @Override
1014     void forEach(FUnCon f) {
1015         short[] vec = getElements();
1016         for (int i = 0; i < length(); i++) {
1017             f.apply(i, vec[i]);
1018         }
1019     }
1020 
1021     @Override
1022     void forEach(VectorMask<Short> o, FUnCon f) {
1023         boolean[] mbits = ((Short512Mask)o).getBits();
1024         forEach((i, a) -> {
1025             if (mbits[i]) { f.apply(i, a); }
1026         });
1027     }
1028 
1029 
1030 
1031     @Override
1032     public Short512Vector rotateEL(int j) {
1033         short[] vec = getElements();
1034         short[] res = new short[length()];
1035         for (int i = 0; i < length(); i++){
1036             res[(j + i) % length()] = vec[i];
1037         }
1038         return new Short512Vector(res);
1039     }
1040 
1041     @Override
1042     public Short512Vector rotateER(int j) {
1043         short[] vec = getElements();
1044         short[] res = new short[length()];
1045         for (int i = 0; i < length(); i++){
1046             int z = i - j;
1047             if(j < 0) {
1048                 res[length() + z] = vec[i];
1049             } else {
1050                 res[z] = vec[i];
1051             }
1052         }
1053         return new Short512Vector(res);
1054     }
1055 
1056     @Override
1057     public Short512Vector shiftEL(int j) {
1058         short[] vec = getElements();
1059         short[] res = new short[length()];
1060         for (int i = 0; i < length() - j; i++) {
1061             res[i] = vec[i + j];
1062         }
1063         return new Short512Vector(res);
1064     }
1065 
1066     @Override
1067     public Short512Vector shiftER(int j) {
1068         short[] vec = getElements();
1069         short[] res = new short[length()];
1070         for (int i = 0; i < length() - j; i++){
1071             res[i + j] = vec[i];
1072         }
1073         return new Short512Vector(res);
1074     }
1075 
1076     @Override
1077     @ForceInline
1078     public Short512Vector rearrange(Vector<Short> v,
1079                                   VectorShuffle<Short> s, VectorMask<Short> m) {
1080         return this.rearrange(s).blend(v.rearrange(s), m);
1081     }
1082 
1083     @Override
1084     @ForceInline
1085     public Short512Vector rearrange(VectorShuffle<Short> o1) {
1086         Objects.requireNonNull(o1);
1087         Short512Shuffle s =  (Short512Shuffle)o1;




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


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


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


1039 
1040     @Override
1041     void forEach(FUnCon f) {
1042         short[] vec = getElements();
1043         for (int i = 0; i < length(); i++) {
1044             f.apply(i, vec[i]);
1045         }
1046     }
1047 
1048     @Override
1049     void forEach(VectorMask<Short> o, FUnCon f) {
1050         boolean[] mbits = ((Short512Mask)o).getBits();
1051         forEach((i, a) -> {
1052             if (mbits[i]) { f.apply(i, a); }
1053         });
1054     }
1055 
1056 
1057 
1058     @Override
1059     public Short512Vector rotateLanesLeft(int j) {
1060         short[] vec = getElements();
1061         short[] res = new short[length()];
1062         for (int i = 0; i < length(); i++){
1063             res[(j + i) % length()] = vec[i];
1064         }
1065         return new Short512Vector(res);
1066     }
1067 
1068     @Override
1069     public Short512Vector rotateLanesRight(int j) {
1070         short[] vec = getElements();
1071         short[] res = new short[length()];
1072         for (int i = 0; i < length(); i++){
1073             int z = i - j;
1074             if(j < 0) {
1075                 res[length() + z] = vec[i];
1076             } else {
1077                 res[z] = vec[i];
1078             }
1079         }
1080         return new Short512Vector(res);
1081     }
1082 
1083     @Override
1084     public Short512Vector shiftLanesLeft(int j) {
1085         short[] vec = getElements();
1086         short[] res = new short[length()];
1087         for (int i = 0; i < length() - j; i++) {
1088             res[i] = vec[i + j];
1089         }
1090         return new Short512Vector(res);
1091     }
1092 
1093     @Override
1094     public Short512Vector shiftLanesRight(int j) {
1095         short[] vec = getElements();
1096         short[] res = new short[length()];
1097         for (int i = 0; i < length() - j; i++){
1098             res[i + j] = vec[i];
1099         }
1100         return new Short512Vector(res);
1101     }
1102 
1103     @Override
1104     @ForceInline
1105     public Short512Vector rearrange(Vector<Short> v,
1106                                   VectorShuffle<Short> s, VectorMask<Short> m) {
1107         return this.rearrange(s).blend(v.rearrange(s), m);
1108     }
1109 
1110     @Override
1111     @ForceInline
1112     public Short512Vector rearrange(VectorShuffle<Short> o1) {
1113         Objects.requireNonNull(o1);
1114         Short512Shuffle s =  (Short512Shuffle)o1;


< prev index next >