< prev index next >

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


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


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


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


1090 
1091     @Override
1092     void forEach(VectorMask<Integer> o, FUnCon f) {
1093         boolean[] mbits = ((Int256Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Float256Vector toFP() {
1101         int[] vec = getElements();
1102         float[] res = new float[this.species().length()];
1103         for(int i = 0; i < this.species().length(); i++){
1104             res[i] = Float.intBitsToFloat(vec[i]);
1105         }
1106         return new Float256Vector(res);
1107     }
1108 
1109     @Override
1110     public Int256Vector rotateEL(int j) {
1111         int[] vec = getElements();
1112         int[] res = new int[length()];
1113         for (int i = 0; i < length(); i++){
1114             res[(j + i) % length()] = vec[i];
1115         }
1116         return new Int256Vector(res);
1117     }
1118 
1119     @Override
1120     public Int256Vector rotateER(int j) {
1121         int[] vec = getElements();
1122         int[] res = new int[length()];
1123         for (int i = 0; i < length(); i++){
1124             int z = i - j;
1125             if(j < 0) {
1126                 res[length() + z] = vec[i];
1127             } else {
1128                 res[z] = vec[i];
1129             }
1130         }
1131         return new Int256Vector(res);
1132     }
1133 
1134     @Override
1135     public Int256Vector shiftEL(int j) {
1136         int[] vec = getElements();
1137         int[] res = new int[length()];
1138         for (int i = 0; i < length() - j; i++) {
1139             res[i] = vec[i + j];
1140         }
1141         return new Int256Vector(res);
1142     }
1143 
1144     @Override
1145     public Int256Vector shiftER(int j) {
1146         int[] vec = getElements();
1147         int[] res = new int[length()];
1148         for (int i = 0; i < length() - j; i++){
1149             res[i + j] = vec[i];
1150         }
1151         return new Int256Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Int256Vector rearrange(Vector<Integer> v,
1157                                   VectorShuffle<Integer> s, VectorMask<Integer> m) {
1158         return this.rearrange(s).blend(v.rearrange(s), m);
1159     }
1160 
1161     @Override
1162     @ForceInline
1163     public Int256Vector rearrange(VectorShuffle<Integer> o1) {
1164         Objects.requireNonNull(o1);
1165         Int256Shuffle s =  (Int256Shuffle)o1;




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


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


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


1090 
1091     @Override
1092     void forEach(VectorMask<Integer> o, FUnCon f) {
1093         boolean[] mbits = ((Int256Mask)o).getBits();
1094         forEach((i, a) -> {
1095             if (mbits[i]) { f.apply(i, a); }
1096         });
1097     }
1098 
1099 
1100     Float256Vector toFP() {
1101         int[] vec = getElements();
1102         float[] res = new float[this.species().length()];
1103         for(int i = 0; i < this.species().length(); i++){
1104             res[i] = Float.intBitsToFloat(vec[i]);
1105         }
1106         return new Float256Vector(res);
1107     }
1108 
1109     @Override
1110     public Int256Vector rotateLanesLeft(int j) {
1111         int[] vec = getElements();
1112         int[] res = new int[length()];
1113         for (int i = 0; i < length(); i++){
1114             res[(j + i) % length()] = vec[i];
1115         }
1116         return new Int256Vector(res);
1117     }
1118 
1119     @Override
1120     public Int256Vector rotateLanesRight(int j) {
1121         int[] vec = getElements();
1122         int[] res = new int[length()];
1123         for (int i = 0; i < length(); i++){
1124             int z = i - j;
1125             if(j < 0) {
1126                 res[length() + z] = vec[i];
1127             } else {
1128                 res[z] = vec[i];
1129             }
1130         }
1131         return new Int256Vector(res);
1132     }
1133 
1134     @Override
1135     public Int256Vector shiftLanesLeft(int j) {
1136         int[] vec = getElements();
1137         int[] res = new int[length()];
1138         for (int i = 0; i < length() - j; i++) {
1139             res[i] = vec[i + j];
1140         }
1141         return new Int256Vector(res);
1142     }
1143 
1144     @Override
1145     public Int256Vector shiftLanesRight(int j) {
1146         int[] vec = getElements();
1147         int[] res = new int[length()];
1148         for (int i = 0; i < length() - j; i++){
1149             res[i + j] = vec[i];
1150         }
1151         return new Int256Vector(res);
1152     }
1153 
1154     @Override
1155     @ForceInline
1156     public Int256Vector rearrange(Vector<Integer> v,
1157                                   VectorShuffle<Integer> s, VectorMask<Integer> m) {
1158         return this.rearrange(s).blend(v.rearrange(s), m);
1159     }
1160 
1161     @Override
1162     @ForceInline
1163     public Int256Vector rearrange(VectorShuffle<Integer> o1) {
1164         Objects.requireNonNull(o1);
1165         Int256Shuffle s =  (Int256Shuffle)o1;


< prev index next >