< prev index next >

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


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


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


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









 675         return VectorIntrinsics.broadcastInt(
 676             VECTOR_OP_URSHIFT, ByteMaxVector.class, byte.class, LENGTH,
 677             this, s,
 678             (v, i) -> v.uOp((__, a) -> (byte) ((a & 0xFF) >>> (i & 7))));
 679     }
 680 
 681     @Override
 682     @ForceInline
 683     public ByteMaxVector shiftR(int s, VectorMask<Byte> m) {
 684         return blend(shiftR(s), m);
 685     }
 686 
 687     @Override
 688     @ForceInline
 689     public ByteMaxVector aShiftR(int s) {









 690         return VectorIntrinsics.broadcastInt(
 691             VECTOR_OP_RSHIFT, ByteMaxVector.class, byte.class, LENGTH,
 692             this, s,
 693             (v, i) -> v.uOp((__, a) -> (byte) (a >> (i & 7))));






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



 700     }

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


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




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


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


 639     @Override
 640     @ForceInline
 641     public ByteMaxVector and(Vector<Byte> v, VectorMask<Byte> m) {
 642         return blend(and(v), m);
 643     }
 644 
 645     @Override
 646     @ForceInline
 647     public ByteMaxVector or(Vector<Byte> v, VectorMask<Byte> m) {
 648         return blend(or(v), m);
 649     }
 650 
 651     @Override
 652     @ForceInline
 653     public ByteMaxVector xor(Vector<Byte> v, VectorMask<Byte> m) {
 654         return blend(xor(v), m);
 655     }
 656 
 657     @Override
 658     @ForceInline
 659     public ByteMaxVector shiftLeft(int s) {
 660         return VectorIntrinsics.broadcastInt(
 661             VECTOR_OP_LSHIFT, ByteMaxVector.class, byte.class, LENGTH,
 662             this, s,
 663             (v, i) -> v.uOp((__, a) -> (byte) (a << (i & 0x7))));
 664     }
 665 
 666     @Override
 667     @ForceInline
 668     public ByteMaxVector shiftLeft(int s, VectorMask<Byte> m) {
 669         return blend(shiftLeft(s), m);
 670     }
 671 
 672     @Override
 673     @ForceInline
 674     public ByteMaxVector shiftLeft(Vector<Byte> s) {
 675         ByteMaxVector shiftv = (ByteMaxVector)s;
 676         // As per shift specification for Java, mask the shift count.
 677         shiftv = shiftv.and(ByteVector.broadcast(SPECIES, (byte) 0x7));
 678         return this.bOp(shiftv, (i, a, b) -> (byte) (a << (b & 0x7)));
 679     }
 680 
 681     @Override
 682     @ForceInline
 683     public ByteMaxVector shiftRight(int s) {
 684         return VectorIntrinsics.broadcastInt(
 685             VECTOR_OP_URSHIFT, ByteMaxVector.class, byte.class, LENGTH,
 686             this, s,
 687             (v, i) -> v.uOp((__, a) -> (byte) ((a & 0xFF) >>> (i & 0x7))));
 688     }
 689 
 690     @Override
 691     @ForceInline
 692     public ByteMaxVector shiftRight(int s, VectorMask<Byte> m) {
 693         return blend(shiftRight(s), m);
 694     }
 695 
 696     @Override
 697     @ForceInline
 698     public ByteMaxVector shiftRight(Vector<Byte> s) {
 699         ByteMaxVector shiftv = (ByteMaxVector)s;
 700         // As per shift specification for Java, mask the shift count.
 701         shiftv = shiftv.and(ByteVector.broadcast(SPECIES, (byte) 0x7));
 702         return this.bOp(shiftv, (i, a, b) -> (byte) (a >>> (b & 0x7)));
 703     }
 704 
 705     @Override
 706     @ForceInline
 707     public ByteMaxVector shiftArithmeticRight(int s) {
 708         return VectorIntrinsics.broadcastInt(
 709             VECTOR_OP_RSHIFT, ByteMaxVector.class, byte.class, LENGTH,
 710             this, s,
 711             (v, i) -> v.uOp((__, a) -> (byte) (a >> (i & 0x7))));
 712     }
 713 
 714     @Override
 715     @ForceInline
 716     public ByteMaxVector shiftArithmeticRight(int s, VectorMask<Byte> m) {
 717         return blend(shiftArithmeticRight(s), m);
 718     }
 719 
 720     @Override
 721     @ForceInline
 722     public ByteMaxVector shiftArithmeticRight(Vector<Byte> s) {
 723         ByteMaxVector shiftv = (ByteMaxVector)s;
 724         // As per shift specification for Java, mask the shift count.
 725         shiftv = shiftv.and(ByteVector.broadcast(SPECIES, (byte) 0x7));
 726         return this.bOp(shiftv, (i, a, b) -> (byte) (a >> (b & 0x7)));
 727     }
 728 
 729     // Ternary operations
 730 
 731 
 732     // Type specific horizontal reductions
 733 
 734     @Override
 735     @ForceInline
 736     public byte addLanes() {
 737         return (byte) VectorIntrinsics.reductionCoerced(
 738             VECTOR_OP_ADD, ByteMaxVector.class, byte.class, LENGTH,
 739             this,
 740             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a + b)));
 741     }
 742 
 743     @Override
 744     @ForceInline
 745     public byte andLanes() {
 746         return (byte) VectorIntrinsics.reductionCoerced(
 747             VECTOR_OP_AND, ByteMaxVector.class, byte.class, LENGTH,
 748             this,
 749             v -> (long) v.rOp((byte) -1, (i, a, b) -> (byte) (a & b)));
 750     }
 751 
 752     @Override
 753     @ForceInline
 754     public byte andLanes(VectorMask<Byte> m) {
 755         return ByteVector.broadcast(SPECIES, (byte) -1).blend(this, m).andLanes();
 756     }
 757 
 758     @Override
 759     @ForceInline
 760     public byte minLanes() {
 761         return (byte) VectorIntrinsics.reductionCoerced(
 762             VECTOR_OP_MIN, ByteMaxVector.class, byte.class, LENGTH,
 763             this,
 764             v -> (long) v.rOp(Byte.MAX_VALUE , (i, a, b) -> (byte) Math.min(a, b)));
 765     }
 766 
 767     @Override
 768     @ForceInline
 769     public byte maxLanes() {
 770         return (byte) VectorIntrinsics.reductionCoerced(
 771             VECTOR_OP_MAX, ByteMaxVector.class, byte.class, LENGTH,
 772             this,
 773             v -> (long) v.rOp(Byte.MIN_VALUE , (i, a, b) -> (byte) Math.max(a, b)));
 774     }
 775 
 776     @Override
 777     @ForceInline
 778     public byte mulLanes() {
 779         return (byte) VectorIntrinsics.reductionCoerced(
 780             VECTOR_OP_MUL, ByteMaxVector.class, byte.class, LENGTH,
 781             this,
 782             v -> (long) v.rOp((byte) 1, (i, a, b) -> (byte) (a * b)));
 783     }
 784 
 785     @Override
 786     @ForceInline
 787     public byte orLanes() {
 788         return (byte) VectorIntrinsics.reductionCoerced(
 789             VECTOR_OP_OR, ByteMaxVector.class, byte.class, LENGTH,
 790             this,
 791             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a | b)));
 792     }
 793 
 794     @Override
 795     @ForceInline
 796     public byte orLanes(VectorMask<Byte> m) {
 797         return ByteVector.broadcast(SPECIES, (byte) 0).blend(this, m).orLanes();
 798     }
 799 
 800     @Override
 801     @ForceInline
 802     public byte xorLanes() {
 803         return (byte) VectorIntrinsics.reductionCoerced(
 804             VECTOR_OP_XOR, ByteMaxVector.class, byte.class, LENGTH,
 805             this,
 806             v -> (long) v.rOp((byte) 0, (i, a, b) -> (byte) (a ^ b)));
 807     }
 808 
 809     @Override
 810     @ForceInline
 811     public byte xorLanes(VectorMask<Byte> m) {
 812         return ByteVector.broadcast(SPECIES, (byte) 0).blend(this, m).xorLanes();
 813     }
 814 
 815 
 816     @Override
 817     @ForceInline
 818     public byte addLanes(VectorMask<Byte> m) {
 819         return ByteVector.broadcast(SPECIES, (byte) 0).blend(this, m).addLanes();
 820     }
 821 
 822 
 823     @Override
 824     @ForceInline
 825     public byte mulLanes(VectorMask<Byte> m) {
 826         return ByteVector.broadcast(SPECIES, (byte) 1).blend(this, m).mulLanes();
 827     }
 828 
 829     @Override
 830     @ForceInline
 831     public byte minLanes(VectorMask<Byte> m) {
 832         return ByteVector.broadcast(SPECIES, Byte.MAX_VALUE).blend(this, m).minLanes();
 833     }
 834 
 835     @Override
 836     @ForceInline
 837     public byte maxLanes(VectorMask<Byte> m) {
 838         return ByteVector.broadcast(SPECIES, Byte.MIN_VALUE).blend(this, m).maxLanes();
 839     }
 840 
 841     @Override
 842     @ForceInline
 843     public VectorShuffle<Byte> toShuffle() {
 844         byte[] 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_BYTE_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         byte[] 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<Byte> o, FUnCon f) {
1050         boolean[] mbits = ((ByteMaxMask)o).getBits();
1051         forEach((i, a) -> {
1052             if (mbits[i]) { f.apply(i, a); }
1053         });
1054     }
1055 
1056 
1057 
1058     @Override
1059     public ByteMaxVector rotateLanesLeft(int j) {
1060         byte[] vec = getElements();
1061         byte[] res = new byte[length()];
1062         for (int i = 0; i < length(); i++){
1063             res[(j + i) % length()] = vec[i];
1064         }
1065         return new ByteMaxVector(res);
1066     }
1067 
1068     @Override
1069     public ByteMaxVector rotateLanesRight(int j) {
1070         byte[] vec = getElements();
1071         byte[] res = new byte[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 ByteMaxVector(res);
1081     }
1082 
1083     @Override
1084     public ByteMaxVector shiftLanesLeft(int j) {
1085         byte[] vec = getElements();
1086         byte[] res = new byte[length()];
1087         for (int i = 0; i < length() - j; i++) {
1088             res[i] = vec[i + j];
1089         }
1090         return new ByteMaxVector(res);
1091     }
1092 
1093     @Override
1094     public ByteMaxVector shiftLanesRight(int j) {
1095         byte[] vec = getElements();
1096         byte[] res = new byte[length()];
1097         for (int i = 0; i < length() - j; i++){
1098             res[i + j] = vec[i];
1099         }
1100         return new ByteMaxVector(res);
1101     }
1102 
1103     @Override
1104     @ForceInline
1105     public ByteMaxVector rearrange(Vector<Byte> v,
1106                                   VectorShuffle<Byte> s, VectorMask<Byte> m) {
1107         return this.rearrange(s).blend(v.rearrange(s), m);
1108     }
1109 
1110     @Override
1111     @ForceInline
1112     public ByteMaxVector rearrange(VectorShuffle<Byte> o1) {
1113         Objects.requireNonNull(o1);
1114         ByteMaxShuffle s =  (ByteMaxShuffle)o1;


< prev index next >