146
147 @Override
148 long rOp(long v, FBinOp f) {
149 long[] 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 LongMaxVector.class,
165 long.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 LongMaxVector.class,
289 long.class, LENGTH,
290 DoubleMaxVector.class,
291 double.class, DoubleMaxVector.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 LongVector reshape(VectorSpecies<Long> s) {
303 Objects.requireNonNull(s);
304 if (s.bitSize() == 64 && (s.boxType() == Long64Vector.class)) {
305 return VectorIntrinsics.reinterpret(
306 LongMaxVector.class,
307 long.class, LENGTH,
308 Long64Vector.class,
309 long.class, Long64Vector.LENGTH,
310 this, s,
311 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
312 );
313 } else if (s.bitSize() == 128 && (s.boxType() == Long128Vector.class)) {
314 return VectorIntrinsics.reinterpret(
315 LongMaxVector.class,
316 long.class, LENGTH,
317 Long128Vector.class,
318 long.class, Long128Vector.LENGTH,
319 this, s,
320 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
321 );
322 } else if (s.bitSize() == 256 && (s.boxType() == Long256Vector.class)) {
323 return VectorIntrinsics.reinterpret(
324 LongMaxVector.class,
325 long.class, LENGTH,
326 Long256Vector.class,
327 long.class, Long256Vector.LENGTH,
328 this, s,
329 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
330 );
331 } else if (s.bitSize() == 512 && (s.boxType() == Long512Vector.class)) {
332 return VectorIntrinsics.reinterpret(
333 LongMaxVector.class,
334 long.class, LENGTH,
335 Long512Vector.class,
336 long.class, Long512Vector.LENGTH,
337 this, s,
338 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
339 );
340 } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
341 && (s.bitSize() % 128 == 0) && (s.boxType() == LongMaxVector.class)) {
342 return VectorIntrinsics.reinterpret(
343 LongMaxVector.class,
344 long.class, LENGTH,
345 LongMaxVector.class,
346 long.class, LongMaxVector.LENGTH,
347 this, s,
348 (species, vector) -> (LongVector) 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 LongVector add(long o) {
360 return add((LongMaxVector)LongVector.broadcast(SPECIES, o));
361 }
648 @Override
649 @ForceInline
650 public LongMaxVector and(Vector<Long> v, VectorMask<Long> m) {
651 return blend(and(v), m);
652 }
653
654 @Override
655 @ForceInline
656 public LongMaxVector or(Vector<Long> v, VectorMask<Long> m) {
657 return blend(or(v), m);
658 }
659
660 @Override
661 @ForceInline
662 public LongMaxVector xor(Vector<Long> v, VectorMask<Long> m) {
663 return blend(xor(v), m);
664 }
665
666 @Override
667 @ForceInline
668 public LongMaxVector shiftL(int s) {
669 return VectorIntrinsics.broadcastInt(
670 VECTOR_OP_LSHIFT, LongMaxVector.class, long.class, LENGTH,
671 this, s,
672 (v, i) -> v.uOp((__, a) -> (long) (a << i)));
673 }
674
675 @Override
676 @ForceInline
677 public LongMaxVector shiftL(int s, VectorMask<Long> m) {
678 return blend(shiftL(s), m);
679 }
680
681 @Override
682 @ForceInline
683 public LongMaxVector shiftR(int s) {
684 return VectorIntrinsics.broadcastInt(
685 VECTOR_OP_URSHIFT, LongMaxVector.class, long.class, LENGTH,
686 this, s,
687 (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
688 }
689
690 @Override
691 @ForceInline
692 public LongMaxVector shiftR(int s, VectorMask<Long> m) {
693 return blend(shiftR(s), m);
694 }
695
696 @Override
697 @ForceInline
698 public LongMaxVector aShiftR(int s) {
699 return VectorIntrinsics.broadcastInt(
700 VECTOR_OP_RSHIFT, LongMaxVector.class, long.class, LENGTH,
701 this, s,
702 (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
703 }
704
705 @Override
706 @ForceInline
707 public LongMaxVector aShiftR(int s, VectorMask<Long> m) {
708 return blend(aShiftR(s), m);
709 }
710
711 @Override
712 @ForceInline
713 public LongMaxVector shiftL(Vector<Long> s) {
714 LongMaxVector shiftv = (LongMaxVector)s;
715 // As per shift specification for Java, mask the shift count.
716 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
717 return VectorIntrinsics.binaryOp(
718 VECTOR_OP_LSHIFT, LongMaxVector.class, long.class, LENGTH,
719 this, shiftv,
720 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
721 }
722
723 @Override
724 @ForceInline
725 public LongMaxVector shiftR(Vector<Long> s) {
726 LongMaxVector shiftv = (LongMaxVector)s;
727 // As per shift specification for Java, mask the shift count.
728 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
729 return VectorIntrinsics.binaryOp(
730 VECTOR_OP_URSHIFT, LongMaxVector.class, long.class, LENGTH,
731 this, shiftv,
732 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
733 }
734
735 @Override
736 @ForceInline
737 public LongMaxVector aShiftR(Vector<Long> s) {
738 LongMaxVector shiftv = (LongMaxVector)s;
739 // As per shift specification for Java, mask the shift count.
740 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
741 return VectorIntrinsics.binaryOp(
742 VECTOR_OP_RSHIFT, LongMaxVector.class, long.class, LENGTH,
743 this, shiftv,
744 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
745 }
746 // Ternary operations
747
748
749 // Type specific horizontal reductions
750
751 @Override
752 @ForceInline
753 public long addAll() {
754 return (long) VectorIntrinsics.reductionCoerced(
755 VECTOR_OP_ADD, LongMaxVector.class, long.class, LENGTH,
756 this,
757 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));
758 }
759
760 @Override
761 @ForceInline
762 public long andAll() {
763 return (long) VectorIntrinsics.reductionCoerced(
764 VECTOR_OP_AND, LongMaxVector.class, long.class, LENGTH,
765 this,
766 v -> (long) v.rOp((long) -1, (i, a, b) -> (long) (a & b)));
767 }
768
769 @Override
770 @ForceInline
771 public long andAll(VectorMask<Long> m) {
772 return LongVector.broadcast(SPECIES, (long) -1).blend(this, m).andAll();
773 }
774
775 @Override
776 @ForceInline
777 public long minAll() {
778 return (long) VectorIntrinsics.reductionCoerced(
779 VECTOR_OP_MIN, LongMaxVector.class, long.class, LENGTH,
780 this,
781 v -> (long) v.rOp(Long.MAX_VALUE , (i, a, b) -> (long) Math.min(a, b)));
782 }
783
784 @Override
785 @ForceInline
786 public long maxAll() {
787 return (long) VectorIntrinsics.reductionCoerced(
788 VECTOR_OP_MAX, LongMaxVector.class, long.class, LENGTH,
789 this,
790 v -> (long) v.rOp(Long.MIN_VALUE , (i, a, b) -> (long) Math.max(a, b)));
791 }
792
793 @Override
794 @ForceInline
795 public long mulAll() {
796 return (long) VectorIntrinsics.reductionCoerced(
797 VECTOR_OP_MUL, LongMaxVector.class, long.class, LENGTH,
798 this,
799 v -> (long) v.rOp((long) 1, (i, a, b) -> (long) (a * b)));
800 }
801
802 @Override
803 @ForceInline
804 public long orAll() {
805 return (long) VectorIntrinsics.reductionCoerced(
806 VECTOR_OP_OR, LongMaxVector.class, long.class, LENGTH,
807 this,
808 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a | b)));
809 }
810
811 @Override
812 @ForceInline
813 public long orAll(VectorMask<Long> m) {
814 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).orAll();
815 }
816
817 @Override
818 @ForceInline
819 public long xorAll() {
820 return (long) VectorIntrinsics.reductionCoerced(
821 VECTOR_OP_XOR, LongMaxVector.class, long.class, LENGTH,
822 this,
823 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a ^ b)));
824 }
825
826 @Override
827 @ForceInline
828 public long xorAll(VectorMask<Long> m) {
829 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).xorAll();
830 }
831
832
833 @Override
834 @ForceInline
835 public long addAll(VectorMask<Long> m) {
836 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).addAll();
837 }
838
839
840 @Override
841 @ForceInline
842 public long mulAll(VectorMask<Long> m) {
843 return LongVector.broadcast(SPECIES, (long) 1).blend(this, m).mulAll();
844 }
845
846 @Override
847 @ForceInline
848 public long minAll(VectorMask<Long> m) {
849 return LongVector.broadcast(SPECIES, Long.MAX_VALUE).blend(this, m).minAll();
850 }
851
852 @Override
853 @ForceInline
854 public long maxAll(VectorMask<Long> m) {
855 return LongVector.broadcast(SPECIES, Long.MIN_VALUE).blend(this, m).maxAll();
856 }
857
858 @Override
859 @ForceInline
860 public VectorShuffle<Long> toShuffle() {
861 long[] 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_LONG_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<Long> o, FUnCon f) {
1093 boolean[] mbits = ((LongMaxMask)o).getBits();
1094 forEach((i, a) -> {
1095 if (mbits[i]) { f.apply(i, a); }
1096 });
1097 }
1098
1099
1100 DoubleMaxVector toFP() {
1101 long[] vec = getElements();
1102 double[] res = new double[this.species().length()];
1103 for(int i = 0; i < this.species().length(); i++){
1104 res[i] = Double.longBitsToDouble(vec[i]);
1105 }
1106 return new DoubleMaxVector(res);
1107 }
1108
1109 @Override
1110 public LongMaxVector rotateEL(int j) {
1111 long[] vec = getElements();
1112 long[] res = new long[length()];
1113 for (int i = 0; i < length(); i++){
1114 res[(j + i) % length()] = vec[i];
1115 }
1116 return new LongMaxVector(res);
1117 }
1118
1119 @Override
1120 public LongMaxVector rotateER(int j) {
1121 long[] vec = getElements();
1122 long[] res = new long[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 LongMaxVector(res);
1132 }
1133
1134 @Override
1135 public LongMaxVector shiftEL(int j) {
1136 long[] vec = getElements();
1137 long[] res = new long[length()];
1138 for (int i = 0; i < length() - j; i++) {
1139 res[i] = vec[i + j];
1140 }
1141 return new LongMaxVector(res);
1142 }
1143
1144 @Override
1145 public LongMaxVector shiftER(int j) {
1146 long[] vec = getElements();
1147 long[] res = new long[length()];
1148 for (int i = 0; i < length() - j; i++){
1149 res[i + j] = vec[i];
1150 }
1151 return new LongMaxVector(res);
1152 }
1153
1154 @Override
1155 @ForceInline
1156 public LongMaxVector rearrange(Vector<Long> v,
1157 VectorShuffle<Long> s, VectorMask<Long> m) {
1158 return this.rearrange(s).blend(v.rearrange(s), m);
1159 }
1160
1161 @Override
1162 @ForceInline
1163 public LongMaxVector rearrange(VectorShuffle<Long> o1) {
1164 Objects.requireNonNull(o1);
1165 LongMaxShuffle s = (LongMaxShuffle)o1;
|
146
147 @Override
148 long rOp(long v, FBinOp f) {
149 long[] 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 LongMaxVector.class,
165 long.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 LongMaxVector.class,
289 long.class, LENGTH,
290 DoubleMaxVector.class,
291 double.class, DoubleMaxVector.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 LongVector reshape(VectorSpecies<Long> s) {
303 Objects.requireNonNull(s);
304 if (s.bitSize() == 64 && (s.vectorType() == Long64Vector.class)) {
305 return VectorIntrinsics.reinterpret(
306 LongMaxVector.class,
307 long.class, LENGTH,
308 Long64Vector.class,
309 long.class, Long64Vector.LENGTH,
310 this, s,
311 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
312 );
313 } else if (s.bitSize() == 128 && (s.vectorType() == Long128Vector.class)) {
314 return VectorIntrinsics.reinterpret(
315 LongMaxVector.class,
316 long.class, LENGTH,
317 Long128Vector.class,
318 long.class, Long128Vector.LENGTH,
319 this, s,
320 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
321 );
322 } else if (s.bitSize() == 256 && (s.vectorType() == Long256Vector.class)) {
323 return VectorIntrinsics.reinterpret(
324 LongMaxVector.class,
325 long.class, LENGTH,
326 Long256Vector.class,
327 long.class, Long256Vector.LENGTH,
328 this, s,
329 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
330 );
331 } else if (s.bitSize() == 512 && (s.vectorType() == Long512Vector.class)) {
332 return VectorIntrinsics.reinterpret(
333 LongMaxVector.class,
334 long.class, LENGTH,
335 Long512Vector.class,
336 long.class, Long512Vector.LENGTH,
337 this, s,
338 (species, vector) -> (LongVector) vector.defaultReinterpret(species)
339 );
340 } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
341 && (s.bitSize() % 128 == 0) && (s.vectorType() == LongMaxVector.class)) {
342 return VectorIntrinsics.reinterpret(
343 LongMaxVector.class,
344 long.class, LENGTH,
345 LongMaxVector.class,
346 long.class, LongMaxVector.LENGTH,
347 this, s,
348 (species, vector) -> (LongVector) 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 LongVector add(long o) {
360 return add((LongMaxVector)LongVector.broadcast(SPECIES, o));
361 }
648 @Override
649 @ForceInline
650 public LongMaxVector and(Vector<Long> v, VectorMask<Long> m) {
651 return blend(and(v), m);
652 }
653
654 @Override
655 @ForceInline
656 public LongMaxVector or(Vector<Long> v, VectorMask<Long> m) {
657 return blend(or(v), m);
658 }
659
660 @Override
661 @ForceInline
662 public LongMaxVector xor(Vector<Long> v, VectorMask<Long> m) {
663 return blend(xor(v), m);
664 }
665
666 @Override
667 @ForceInline
668 public LongMaxVector shiftLeft(int s) {
669 return VectorIntrinsics.broadcastInt(
670 VECTOR_OP_LSHIFT, LongMaxVector.class, long.class, LENGTH,
671 this, s,
672 (v, i) -> v.uOp((__, a) -> (long) (a << i)));
673 }
674
675 @Override
676 @ForceInline
677 public LongMaxVector shiftLeft(int s, VectorMask<Long> m) {
678 return blend(shiftLeft(s), m);
679 }
680
681 @Override
682 @ForceInline
683 public LongMaxVector shiftRight(int s) {
684 return VectorIntrinsics.broadcastInt(
685 VECTOR_OP_URSHIFT, LongMaxVector.class, long.class, LENGTH,
686 this, s,
687 (v, i) -> v.uOp((__, a) -> (long) (a >>> i)));
688 }
689
690 @Override
691 @ForceInline
692 public LongMaxVector shiftRight(int s, VectorMask<Long> m) {
693 return blend(shiftRight(s), m);
694 }
695
696 @Override
697 @ForceInline
698 public LongMaxVector shiftArithmeticRight(int s) {
699 return VectorIntrinsics.broadcastInt(
700 VECTOR_OP_RSHIFT, LongMaxVector.class, long.class, LENGTH,
701 this, s,
702 (v, i) -> v.uOp((__, a) -> (long) (a >> i)));
703 }
704
705 @Override
706 @ForceInline
707 public LongMaxVector shiftArithmeticRight(int s, VectorMask<Long> m) {
708 return blend(shiftArithmeticRight(s), m);
709 }
710
711 @Override
712 @ForceInline
713 public LongMaxVector shiftLeft(Vector<Long> s) {
714 LongMaxVector shiftv = (LongMaxVector)s;
715 // As per shift specification for Java, mask the shift count.
716 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
717 return VectorIntrinsics.binaryOp(
718 VECTOR_OP_LSHIFT, LongMaxVector.class, long.class, LENGTH,
719 this, shiftv,
720 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a << b)));
721 }
722
723 @Override
724 @ForceInline
725 public LongMaxVector shiftRight(Vector<Long> s) {
726 LongMaxVector shiftv = (LongMaxVector)s;
727 // As per shift specification for Java, mask the shift count.
728 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
729 return VectorIntrinsics.binaryOp(
730 VECTOR_OP_URSHIFT, LongMaxVector.class, long.class, LENGTH,
731 this, shiftv,
732 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >>> b)));
733 }
734
735 @Override
736 @ForceInline
737 public LongMaxVector shiftArithmeticRight(Vector<Long> s) {
738 LongMaxVector shiftv = (LongMaxVector)s;
739 // As per shift specification for Java, mask the shift count.
740 shiftv = shiftv.and(LongVector.broadcast(SPECIES, 0x3f));
741 return VectorIntrinsics.binaryOp(
742 VECTOR_OP_RSHIFT, LongMaxVector.class, long.class, LENGTH,
743 this, shiftv,
744 (v1, v2) -> v1.bOp(v2,(i,a, b) -> (long) (a >> b)));
745 }
746 // Ternary operations
747
748
749 // Type specific horizontal reductions
750
751 @Override
752 @ForceInline
753 public long addLanes() {
754 return (long) VectorIntrinsics.reductionCoerced(
755 VECTOR_OP_ADD, LongMaxVector.class, long.class, LENGTH,
756 this,
757 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a + b)));
758 }
759
760 @Override
761 @ForceInline
762 public long andLanes() {
763 return (long) VectorIntrinsics.reductionCoerced(
764 VECTOR_OP_AND, LongMaxVector.class, long.class, LENGTH,
765 this,
766 v -> (long) v.rOp((long) -1, (i, a, b) -> (long) (a & b)));
767 }
768
769 @Override
770 @ForceInline
771 public long andLanes(VectorMask<Long> m) {
772 return LongVector.broadcast(SPECIES, (long) -1).blend(this, m).andLanes();
773 }
774
775 @Override
776 @ForceInline
777 public long minLanes() {
778 return (long) VectorIntrinsics.reductionCoerced(
779 VECTOR_OP_MIN, LongMaxVector.class, long.class, LENGTH,
780 this,
781 v -> (long) v.rOp(Long.MAX_VALUE , (i, a, b) -> (long) Math.min(a, b)));
782 }
783
784 @Override
785 @ForceInline
786 public long maxLanes() {
787 return (long) VectorIntrinsics.reductionCoerced(
788 VECTOR_OP_MAX, LongMaxVector.class, long.class, LENGTH,
789 this,
790 v -> (long) v.rOp(Long.MIN_VALUE , (i, a, b) -> (long) Math.max(a, b)));
791 }
792
793 @Override
794 @ForceInline
795 public long mulLanes() {
796 return (long) VectorIntrinsics.reductionCoerced(
797 VECTOR_OP_MUL, LongMaxVector.class, long.class, LENGTH,
798 this,
799 v -> (long) v.rOp((long) 1, (i, a, b) -> (long) (a * b)));
800 }
801
802 @Override
803 @ForceInline
804 public long orLanes() {
805 return (long) VectorIntrinsics.reductionCoerced(
806 VECTOR_OP_OR, LongMaxVector.class, long.class, LENGTH,
807 this,
808 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a | b)));
809 }
810
811 @Override
812 @ForceInline
813 public long orLanes(VectorMask<Long> m) {
814 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).orLanes();
815 }
816
817 @Override
818 @ForceInline
819 public long xorLanes() {
820 return (long) VectorIntrinsics.reductionCoerced(
821 VECTOR_OP_XOR, LongMaxVector.class, long.class, LENGTH,
822 this,
823 v -> (long) v.rOp((long) 0, (i, a, b) -> (long) (a ^ b)));
824 }
825
826 @Override
827 @ForceInline
828 public long xorLanes(VectorMask<Long> m) {
829 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).xorLanes();
830 }
831
832
833 @Override
834 @ForceInline
835 public long addLanes(VectorMask<Long> m) {
836 return LongVector.broadcast(SPECIES, (long) 0).blend(this, m).addLanes();
837 }
838
839
840 @Override
841 @ForceInline
842 public long mulLanes(VectorMask<Long> m) {
843 return LongVector.broadcast(SPECIES, (long) 1).blend(this, m).mulLanes();
844 }
845
846 @Override
847 @ForceInline
848 public long minLanes(VectorMask<Long> m) {
849 return LongVector.broadcast(SPECIES, Long.MAX_VALUE).blend(this, m).minLanes();
850 }
851
852 @Override
853 @ForceInline
854 public long maxLanes(VectorMask<Long> m) {
855 return LongVector.broadcast(SPECIES, Long.MIN_VALUE).blend(this, m).maxLanes();
856 }
857
858 @Override
859 @ForceInline
860 public VectorShuffle<Long> toShuffle() {
861 long[] 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_LONG_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<Long> o, FUnCon f) {
1093 boolean[] mbits = ((LongMaxMask)o).getBits();
1094 forEach((i, a) -> {
1095 if (mbits[i]) { f.apply(i, a); }
1096 });
1097 }
1098
1099
1100 DoubleMaxVector toFP() {
1101 long[] vec = getElements();
1102 double[] res = new double[this.species().length()];
1103 for(int i = 0; i < this.species().length(); i++){
1104 res[i] = Double.longBitsToDouble(vec[i]);
1105 }
1106 return new DoubleMaxVector(res);
1107 }
1108
1109 @Override
1110 public LongMaxVector rotateLanesLeft(int j) {
1111 long[] vec = getElements();
1112 long[] res = new long[length()];
1113 for (int i = 0; i < length(); i++){
1114 res[(j + i) % length()] = vec[i];
1115 }
1116 return new LongMaxVector(res);
1117 }
1118
1119 @Override
1120 public LongMaxVector rotateLanesRight(int j) {
1121 long[] vec = getElements();
1122 long[] res = new long[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 LongMaxVector(res);
1132 }
1133
1134 @Override
1135 public LongMaxVector shiftLanesLeft(int j) {
1136 long[] vec = getElements();
1137 long[] res = new long[length()];
1138 for (int i = 0; i < length() - j; i++) {
1139 res[i] = vec[i + j];
1140 }
1141 return new LongMaxVector(res);
1142 }
1143
1144 @Override
1145 public LongMaxVector shiftLanesRight(int j) {
1146 long[] vec = getElements();
1147 long[] res = new long[length()];
1148 for (int i = 0; i < length() - j; i++){
1149 res[i + j] = vec[i];
1150 }
1151 return new LongMaxVector(res);
1152 }
1153
1154 @Override
1155 @ForceInline
1156 public LongMaxVector rearrange(Vector<Long> v,
1157 VectorShuffle<Long> s, VectorMask<Long> m) {
1158 return this.rearrange(s).blend(v.rearrange(s), m);
1159 }
1160
1161 @Override
1162 @ForceInline
1163 public LongMaxVector rearrange(VectorShuffle<Long> o1) {
1164 Objects.requireNonNull(o1);
1165 LongMaxShuffle s = (LongMaxShuffle)o1;
|