< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template

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


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


 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else if (stype == double.class) {
 295             return VectorIntrinsics.reinterpret(
 296                 $vectortype$.class,
 297                 $type$.class, LENGTH,
 298                 Double$bits$Vector.class,
 299                 double.class, Double$bits$Vector.LENGTH,
 300                 this, s,
 301                 (species, vector) -> vector.defaultReinterpret(species)
 302             );
 303         } else {
 304             throw new UnsupportedOperationException("Bad lane type for casting.");
 305         }
 306     }
 307 
 308     @Override
 309     @ForceInline
 310     public $abstractvectortype$ reshape(VectorSpecies<$Boxtype$> s) {
 311         Objects.requireNonNull(s);
 312         if (s.bitSize() == 64 && (s.boxType() == $Type$64Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 $vectortype$.class,
 315                 $type$.class, LENGTH,
 316                 $Type$64Vector.class,
 317                 $type$.class, $Type$64Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 128 && (s.boxType() == $Type$128Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 $vectortype$.class,
 324                 $type$.class, LENGTH,
 325                 $Type$128Vector.class,
 326                 $type$.class, $Type$128Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 256 && (s.boxType() == $Type$256Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 $vectortype$.class,
 333                 $type$.class, LENGTH,
 334                 $Type$256Vector.class,
 335                 $type$.class, $Type$256Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 338             );
 339         } else if (s.bitSize() == 512 && (s.boxType() == $Type$512Vector.class)) {
 340             return VectorIntrinsics.reinterpret(
 341                 $vectortype$.class,
 342                 $type$.class, LENGTH,
 343                 $Type$512Vector.class,
 344                 $type$.class, $Type$512Vector.LENGTH,
 345                 this, s,
 346                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 347             );
 348         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 349                 && (s.bitSize() % 128 == 0) && (s.boxType() == $Type$MaxVector.class)) {
 350             return VectorIntrinsics.reinterpret(
 351                 $vectortype$.class,
 352                 $type$.class, LENGTH,
 353                 $Type$MaxVector.class,
 354                 $type$.class, $Type$MaxVector.LENGTH,
 355                 this, s,
 356                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 357             );
 358         } else {
 359             throw new InternalError("Unimplemented size");
 360         }
 361     }
 362 
 363     // Binary operations with scalars
 364 
 365     @Override
 366     @ForceInline
 367     public $abstractvectortype$ add($type$ o) {
 368         return add(($vectortype$)$abstractvectortype$.broadcast(SPECIES, o));
 369     }


 929     public $vectortype$ and(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 930         return blend(and(v), m);
 931     }
 932 
 933     @Override
 934     @ForceInline
 935     public $vectortype$ or(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 936         return blend(or(v), m);
 937     }
 938 
 939     @Override
 940     @ForceInline
 941     public $vectortype$ xor(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 942         return blend(xor(v), m);
 943     }
 944 #end[BITWISE]
 945 
 946 #if[byte]
 947     @Override
 948     @ForceInline
 949     public $vectortype$ shiftL(int s) {
 950         return VectorIntrinsics.broadcastInt(
 951             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 952             this, s,
 953             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 7))));
 954     }
 955 
 956     @Override
 957     @ForceInline
 958     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
 959         return blend(shiftL(s), m);
 960     }
 961 
 962     @Override
 963     @ForceInline
 964     public $vectortype$ shiftR(int s) {









 965         return VectorIntrinsics.broadcastInt(
 966             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
 967             this, s,
 968             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFF) >>> (i & 7))));
 969     }
 970 
 971     @Override
 972     @ForceInline
 973     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
 974         return blend(shiftR(s), m);
 975     }
 976 
 977     @Override
 978     @ForceInline
 979     public $vectortype$ aShiftR(int s) {









 980         return VectorIntrinsics.broadcastInt(
 981             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
 982             this, s,
 983             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 7))));
 984     }
 985 
 986     @Override
 987     @ForceInline
 988     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
 989         return blend(aShiftR(s), m);
 990     }










 991 #end[byte]
 992 #if[short]
 993     @Override
 994     @ForceInline
 995     public $vectortype$ shiftL(int s) {
 996         return VectorIntrinsics.broadcastInt(
 997             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 998             this, s,
 999             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 15))));
1000     }
1001 
1002     @Override
1003     @ForceInline
1004     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
1005         return blend(shiftL(s), m);
1006     }
1007 
1008     @Override
1009     @ForceInline
1010     public $vectortype$ shiftR(int s) {









1011         return VectorIntrinsics.broadcastInt(
1012             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1013             this, s,
1014             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFFFF) >>> (i & 15))));






1015     }
1016 
1017     @Override
1018     @ForceInline
1019     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
1020         return blend(shiftR(s), m);



1021     }
1022 
1023     @Override
1024     @ForceInline
1025     public $vectortype$ aShiftR(int s) {
1026         return VectorIntrinsics.broadcastInt(
1027             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1028             this, s,
1029             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 15))));
1030     }
1031 
1032     @Override
1033     @ForceInline
1034     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
1035         return blend(aShiftR(s), m);









1036     }
1037 #end[short]
1038 #if[intOrLong]
1039     @Override
1040     @ForceInline
1041     public $vectortype$ shiftL(int s) {
1042         return VectorIntrinsics.broadcastInt(
1043             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1044             this, s,
1045             (v, i) -> v.uOp((__, a) -> ($type$) (a << i)));
1046     }
1047 
1048     @Override
1049     @ForceInline
1050     public $vectortype$ shiftL(int s, VectorMask<$Boxtype$> m) {
1051         return blend(shiftL(s), m);
1052     }
1053 
1054     @Override
1055     @ForceInline
1056     public $vectortype$ shiftR(int s) {
1057         return VectorIntrinsics.broadcastInt(
1058             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1059             this, s,
1060             (v, i) -> v.uOp((__, a) -> ($type$) (a >>> i)));
1061     }
1062 
1063     @Override
1064     @ForceInline
1065     public $vectortype$ shiftR(int s, VectorMask<$Boxtype$> m) {
1066         return blend(shiftR(s), m);
1067     }
1068 
1069     @Override
1070     @ForceInline
1071     public $vectortype$ aShiftR(int s) {
1072         return VectorIntrinsics.broadcastInt(
1073             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1074             this, s,
1075             (v, i) -> v.uOp((__, a) -> ($type$) (a >> i)));
1076     }
1077 
1078     @Override
1079     @ForceInline
1080     public $vectortype$ aShiftR(int s, VectorMask<$Boxtype$> m) {
1081         return blend(aShiftR(s), m);
1082     }
1083 
1084     @Override
1085     @ForceInline
1086     public $vectortype$ shiftL(Vector<$Boxtype$> s) {
1087         $vectortype$ shiftv = ($vectortype$)s;
1088         // As per shift specification for Java, mask the shift count.
1089         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1090         return VectorIntrinsics.binaryOp(
1091             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1092             this, shiftv,
1093             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a << b)));
1094     }
1095 
1096     @Override
1097     @ForceInline
1098     public $vectortype$ shiftR(Vector<$Boxtype$> s) {
1099         $vectortype$ shiftv = ($vectortype$)s;
1100         // As per shift specification for Java, mask the shift count.
1101         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1102         return VectorIntrinsics.binaryOp(
1103             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1104             this, shiftv,
1105             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >>> b)));
1106     }
1107 
1108     @Override
1109     @ForceInline
1110     public $vectortype$ aShiftR(Vector<$Boxtype$> s) {
1111         $vectortype$ shiftv = ($vectortype$)s;
1112         // As per shift specification for Java, mask the shift count.
1113         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1114         return VectorIntrinsics.binaryOp(
1115             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1116             this, shiftv,
1117             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >> b)));
1118     }
1119 #end[intOrLong]
1120     // Ternary operations
1121 
1122 #if[FP]
1123     @Override
1124     @ForceInline
1125     public $vectortype$ fma(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2) {
1126         Objects.requireNonNull(o1);
1127         Objects.requireNonNull(o2);
1128         $vectortype$ v1 = ($vectortype$)o1;
1129         $vectortype$ v2 = ($vectortype$)o2;
1130         return VectorIntrinsics.ternaryOp(
1131             VECTOR_OP_FMA, $vectortype$.class, $type$.class, LENGTH,
1132             this, v1, v2,
1133             (w1, w2, w3) -> w1.tOp(w2, w3, (i, a, b, c) -> Math.fma(a, b, c)));
1134     }
1135 #end[FP]
1136 
1137     // Type specific horizontal reductions
1138 #if[BITWISE]
1139 
1140     @Override
1141     @ForceInline
1142     public $type$ addAll() {
1143         return ($type$) VectorIntrinsics.reductionCoerced(
1144             VECTOR_OP_ADD, $vectortype$.class, $type$.class, LENGTH,
1145             this,
1146             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a + b)));
1147     }
1148 
1149     @Override
1150     @ForceInline
1151     public $type$ andAll() {
1152         return ($type$) VectorIntrinsics.reductionCoerced(
1153             VECTOR_OP_AND, $vectortype$.class, $type$.class, LENGTH,
1154             this,
1155             v -> (long) v.rOp(($type$) -1, (i, a, b) -> ($type$) (a & b)));
1156     }
1157 
1158     @Override
1159     @ForceInline
1160     public $type$ andAll(VectorMask<$Boxtype$> m) {
1161         return $abstractvectortype$.broadcast(SPECIES, ($type$) -1).blend(this, m).andAll();
1162     }
1163 
1164     @Override
1165     @ForceInline
1166     public $type$ minAll() {
1167         return ($type$) VectorIntrinsics.reductionCoerced(
1168             VECTOR_OP_MIN, $vectortype$.class, $type$.class, LENGTH,
1169             this,
1170             v -> (long) v.rOp($Boxtype$.MAX_VALUE , (i, a, b) -> ($type$) Math.min(a, b)));
1171     }
1172 
1173     @Override
1174     @ForceInline
1175     public $type$ maxAll() {
1176         return ($type$) VectorIntrinsics.reductionCoerced(
1177             VECTOR_OP_MAX, $vectortype$.class, $type$.class, LENGTH,
1178             this,
1179             v -> (long) v.rOp($Boxtype$.MIN_VALUE , (i, a, b) -> ($type$) Math.max(a, b)));
1180     }
1181 
1182     @Override
1183     @ForceInline
1184     public $type$ mulAll() {
1185         return ($type$) VectorIntrinsics.reductionCoerced(
1186             VECTOR_OP_MUL, $vectortype$.class, $type$.class, LENGTH,
1187             this,
1188             v -> (long) v.rOp(($type$) 1, (i, a, b) -> ($type$) (a * b)));
1189     }
1190 
1191     @Override
1192     @ForceInline
1193     public $type$ orAll() {
1194         return ($type$) VectorIntrinsics.reductionCoerced(
1195             VECTOR_OP_OR, $vectortype$.class, $type$.class, LENGTH,
1196             this,
1197             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a | b)));
1198     }
1199 
1200     @Override
1201     @ForceInline
1202     public $type$ orAll(VectorMask<$Boxtype$> m) {
1203         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).orAll();
1204     }
1205 
1206     @Override
1207     @ForceInline
1208     public $type$ xorAll() {
1209         return ($type$) VectorIntrinsics.reductionCoerced(
1210             VECTOR_OP_XOR, $vectortype$.class, $type$.class, LENGTH,
1211             this,
1212             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a ^ b)));
1213     }
1214 
1215     @Override
1216     @ForceInline
1217     public $type$ xorAll(VectorMask<$Boxtype$> m) {
1218         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).xorAll();
1219     }
1220 #end[BITWISE]
1221 
1222 #if[FP]
1223     @Override
1224     @ForceInline
1225     public $type$ addAll() {
1226         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1227                                 VECTOR_OP_ADD, $vectortype$.class, $type$.class, LENGTH,
1228                                 this,
1229                                 v -> {
1230                                     $type$ r = v.rOp(($type$) 0, (i, a, b) -> ($type$) (a + b));
1231                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1232                                 });
1233         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1234     }
1235 
1236     @Override
1237     @ForceInline
1238     public $type$ mulAll() {
1239         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1240                                 VECTOR_OP_MUL, $vectortype$.class, $type$.class, LENGTH,
1241                                 this,
1242                                 v -> {
1243                                     $type$ r = v.rOp(($type$) 1, (i, a, b) -> ($type$) (a * b));
1244                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1245                                 });
1246         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1247     }
1248 
1249     @Override
1250     @ForceInline
1251     public $type$ minAll() {
1252         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1253                                 VECTOR_OP_MIN, $vectortype$.class, $type$.class, LENGTH,
1254                                 this,
1255                                 v -> {
1256                                     $type$ r = v.rOp($Boxtype$.POSITIVE_INFINITY , (i, a, b) -> ($type$) Math.min(a, b));
1257                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1258                                 });
1259         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1260     }
1261 
1262     @Override
1263     @ForceInline
1264     public $type$ maxAll() {
1265         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1266                                 VECTOR_OP_MAX, $vectortype$.class, $type$.class, LENGTH,
1267                                 this,
1268                                 v -> {
1269                                     $type$ r = v.rOp($Boxtype$.NEGATIVE_INFINITY, (i, a, b) -> ($type$) Math.max(a, b));
1270                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1271                                 });
1272         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1273     }
1274 
1275 #end[FP]
1276 
1277     @Override
1278     @ForceInline
1279     public $type$ addAll(VectorMask<$Boxtype$> m) {
1280         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).addAll();
1281     }
1282 
1283 
1284     @Override
1285     @ForceInline
1286     public $type$ mulAll(VectorMask<$Boxtype$> m) {
1287         return $abstractvectortype$.broadcast(SPECIES, ($type$) 1).blend(this, m).mulAll();
1288     }
1289 
1290     @Override
1291     @ForceInline
1292     public $type$ minAll(VectorMask<$Boxtype$> m) {
1293         return $abstractvectortype$.broadcast(SPECIES, $Boxtype$.MAX_VALUE).blend(this, m).minAll();
1294     }
1295 
1296     @Override
1297     @ForceInline
1298     public $type$ maxAll(VectorMask<$Boxtype$> m) {
1299         return $abstractvectortype$.broadcast(SPECIES, $Boxtype$.MIN_VALUE).blend(this, m).maxAll();
1300     }
1301 
1302     @Override
1303     @ForceInline
1304     public VectorShuffle<$Boxtype$> toShuffle() {
1305         $type$[] a = toArray();
1306         int[] sa = new int[a.length];
1307         for (int i = 0; i < a.length; i++) {
1308             sa[i] = (int) a[i];
1309         }
1310         return VectorShuffle.fromArray(SPECIES, sa, 0);
1311     }
1312 
1313     // Memory operations
1314 
1315     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_$TYPE$_INDEX_SCALE);
1316     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
1317 
1318     @Override
1319     @ForceInline


1552         $bitstype$[] res = new $bitstype$[this.species().length()];
1553         for(int i = 0; i < this.species().length(); i++){
1554             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1555         }
1556         return new $bitsvectortype$(res);
1557     }
1558 #end[FP]
1559 
1560 #if[intOrLong]
1561     $fpvectortype$ toFP() {
1562         $type$[] vec = getElements();
1563         $fptype$[] res = new $fptype$[this.species().length()];
1564         for(int i = 0; i < this.species().length(); i++){
1565             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1566         }
1567         return new $fpvectortype$(res);
1568     }
1569 #end[intOrLong]
1570 
1571     @Override
1572     public $vectortype$ rotateEL(int j) {
1573         $type$[] vec = getElements();
1574         $type$[] res = new $type$[length()];
1575         for (int i = 0; i < length(); i++){
1576             res[(j + i) % length()] = vec[i];
1577         }
1578         return new $vectortype$(res);
1579     }
1580 
1581     @Override
1582     public $vectortype$ rotateER(int j) {
1583         $type$[] vec = getElements();
1584         $type$[] res = new $type$[length()];
1585         for (int i = 0; i < length(); i++){
1586             int z = i - j;
1587             if(j < 0) {
1588                 res[length() + z] = vec[i];
1589             } else {
1590                 res[z] = vec[i];
1591             }
1592         }
1593         return new $vectortype$(res);
1594     }
1595 
1596     @Override
1597     public $vectortype$ shiftEL(int j) {
1598         $type$[] vec = getElements();
1599         $type$[] res = new $type$[length()];
1600         for (int i = 0; i < length() - j; i++) {
1601             res[i] = vec[i + j];
1602         }
1603         return new $vectortype$(res);
1604     }
1605 
1606     @Override
1607     public $vectortype$ shiftER(int j) {
1608         $type$[] vec = getElements();
1609         $type$[] res = new $type$[length()];
1610         for (int i = 0; i < length() - j; i++){
1611             res[i + j] = vec[i];
1612         }
1613         return new $vectortype$(res);
1614     }
1615 
1616     @Override
1617     @ForceInline
1618     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1619                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1620         return this.rearrange(s).blend(v.rearrange(s), m);
1621     }
1622 
1623     @Override
1624     @ForceInline
1625     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1626         Objects.requireNonNull(o1);
1627         $shuffletype$ s =  ($shuffletype$)o1;




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


 292                 (species, vector) -> vector.defaultReinterpret(species)
 293             );
 294         } else if (stype == double.class) {
 295             return VectorIntrinsics.reinterpret(
 296                 $vectortype$.class,
 297                 $type$.class, LENGTH,
 298                 Double$bits$Vector.class,
 299                 double.class, Double$bits$Vector.LENGTH,
 300                 this, s,
 301                 (species, vector) -> vector.defaultReinterpret(species)
 302             );
 303         } else {
 304             throw new UnsupportedOperationException("Bad lane type for casting.");
 305         }
 306     }
 307 
 308     @Override
 309     @ForceInline
 310     public $abstractvectortype$ reshape(VectorSpecies<$Boxtype$> s) {
 311         Objects.requireNonNull(s);
 312         if (s.bitSize() == 64 && (s.vectorType() == $Type$64Vector.class)) {
 313             return VectorIntrinsics.reinterpret(
 314                 $vectortype$.class,
 315                 $type$.class, LENGTH,
 316                 $Type$64Vector.class,
 317                 $type$.class, $Type$64Vector.LENGTH,
 318                 this, s,
 319                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 320             );
 321         } else if (s.bitSize() == 128 && (s.vectorType() == $Type$128Vector.class)) {
 322             return VectorIntrinsics.reinterpret(
 323                 $vectortype$.class,
 324                 $type$.class, LENGTH,
 325                 $Type$128Vector.class,
 326                 $type$.class, $Type$128Vector.LENGTH,
 327                 this, s,
 328                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 329             );
 330         } else if (s.bitSize() == 256 && (s.vectorType() == $Type$256Vector.class)) {
 331             return VectorIntrinsics.reinterpret(
 332                 $vectortype$.class,
 333                 $type$.class, LENGTH,
 334                 $Type$256Vector.class,
 335                 $type$.class, $Type$256Vector.LENGTH,
 336                 this, s,
 337                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 338             );
 339         } else if (s.bitSize() == 512 && (s.vectorType() == $Type$512Vector.class)) {
 340             return VectorIntrinsics.reinterpret(
 341                 $vectortype$.class,
 342                 $type$.class, LENGTH,
 343                 $Type$512Vector.class,
 344                 $type$.class, $Type$512Vector.LENGTH,
 345                 this, s,
 346                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 347             );
 348         } else if ((s.bitSize() > 0) && (s.bitSize() <= 2048)
 349                 && (s.bitSize() % 128 == 0) && (s.vectorType() == $Type$MaxVector.class)) {
 350             return VectorIntrinsics.reinterpret(
 351                 $vectortype$.class,
 352                 $type$.class, LENGTH,
 353                 $Type$MaxVector.class,
 354                 $type$.class, $Type$MaxVector.LENGTH,
 355                 this, s,
 356                 (species, vector) -> ($abstractvectortype$) vector.defaultReinterpret(species)
 357             );
 358         } else {
 359             throw new InternalError("Unimplemented size");
 360         }
 361     }
 362 
 363     // Binary operations with scalars
 364 
 365     @Override
 366     @ForceInline
 367     public $abstractvectortype$ add($type$ o) {
 368         return add(($vectortype$)$abstractvectortype$.broadcast(SPECIES, o));
 369     }


 929     public $vectortype$ and(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 930         return blend(and(v), m);
 931     }
 932 
 933     @Override
 934     @ForceInline
 935     public $vectortype$ or(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 936         return blend(or(v), m);
 937     }
 938 
 939     @Override
 940     @ForceInline
 941     public $vectortype$ xor(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) {
 942         return blend(xor(v), m);
 943     }
 944 #end[BITWISE]
 945 
 946 #if[byte]
 947     @Override
 948     @ForceInline
 949     public $vectortype$ shiftLeft(int s) {
 950         return VectorIntrinsics.broadcastInt(
 951             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
 952             this, s,
 953             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 0x7))));
 954     }
 955 
 956     @Override
 957     @ForceInline
 958     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
 959         return blend(shiftLeft(s), m);
 960     }
 961 
 962     @Override
 963     @ForceInline
 964     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
 965         $vectortype$ shiftv = ($vectortype$)s;
 966         // As per shift specification for Java, mask the shift count.
 967         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
 968         return this.bOp(shiftv, (i, a, b) -> ($type$) (a << (b & 0x7)));
 969     }
 970 
 971     @Override
 972     @ForceInline
 973     public $vectortype$ shiftRight(int s) {
 974         return VectorIntrinsics.broadcastInt(
 975             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
 976             this, s,
 977             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFF) >>> (i & 0x7))));
 978     }
 979 
 980     @Override
 981     @ForceInline
 982     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
 983         return blend(shiftRight(s), m);
 984     }
 985 
 986     @Override
 987     @ForceInline
 988     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
 989         $vectortype$ shiftv = ($vectortype$)s;
 990         // As per shift specification for Java, mask the shift count.
 991         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
 992         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >>> (b & 0x7)));
 993     }
 994 
 995     @Override
 996     @ForceInline
 997     public $vectortype$ shiftArithmeticRight(int s) {
 998         return VectorIntrinsics.broadcastInt(
 999             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1000             this, s,
1001             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 0x7))));
1002     }
1003 
1004     @Override
1005     @ForceInline
1006     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1007         return blend(shiftArithmeticRight(s), m);
1008     }
1009 
1010     @Override
1011     @ForceInline
1012     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1013         $vectortype$ shiftv = ($vectortype$)s;
1014         // As per shift specification for Java, mask the shift count.
1015         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0x7));
1016         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >> (b & 0x7)));
1017     }
1018 
1019 #end[byte]
1020 #if[short]
1021     @Override
1022     @ForceInline
1023     public $vectortype$ shiftLeft(int s) {
1024         return VectorIntrinsics.broadcastInt(
1025             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1026             this, s,
1027             (v, i) -> v.uOp((__, a) -> ($type$) (a << (i & 0xF))));
1028     }
1029 
1030     @Override
1031     @ForceInline
1032     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
1033         return blend(shiftLeft(s), m);
1034     }
1035 
1036     @Override
1037     @ForceInline
1038     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
1039         $vectortype$ shiftv = ($vectortype$)s;
1040         // As per shift specification for Java, mask the shift count.
1041         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1042         return this.bOp(shiftv, (i, a, b) -> ($type$) (a << (b & 0xF)));
1043     }
1044 
1045     @Override
1046     @ForceInline
1047     public $vectortype$ shiftRight(int s) {
1048         return VectorIntrinsics.broadcastInt(
1049             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1050             this, s,
1051             (v, i) -> v.uOp((__, a) -> ($type$) ((a & 0xFFFF) >>> (i & 0xF))));
1052     }
1053 
1054     @Override
1055     @ForceInline
1056     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
1057         return blend(shiftRight(s), m);
1058     }
1059 
1060     @Override
1061     @ForceInline
1062     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
1063         $vectortype$ shiftv = ($vectortype$)s;
1064         // As per shift specification for Java, mask the shift count.
1065         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1066         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >>> (b & 0xF)));
1067     }
1068 
1069     @Override
1070     @ForceInline
1071     public $vectortype$ shiftArithmeticRight(int s) {
1072         return VectorIntrinsics.broadcastInt(
1073             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1074             this, s,
1075             (v, i) -> v.uOp((__, a) -> ($type$) (a >> (i & 0xF))));
1076     }
1077 
1078     @Override
1079     @ForceInline
1080     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1081         return blend(shiftArithmeticRight(s), m);
1082     }
1083 
1084     @Override
1085     @ForceInline
1086     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1087         $vectortype$ shiftv = ($vectortype$)s;
1088         // As per shift specification for Java, mask the shift count.
1089         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, ($type$) 0xF));
1090         return this.bOp(shiftv, (i, a, b) -> ($type$) (a >> (b & 0xF)));
1091     }
1092 #end[short]
1093 #if[intOrLong]
1094     @Override
1095     @ForceInline
1096     public $vectortype$ shiftLeft(int s) {
1097         return VectorIntrinsics.broadcastInt(
1098             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1099             this, s,
1100             (v, i) -> v.uOp((__, a) -> ($type$) (a << i)));
1101     }
1102 
1103     @Override
1104     @ForceInline
1105     public $vectortype$ shiftLeft(int s, VectorMask<$Boxtype$> m) {
1106         return blend(shiftLeft(s), m);
1107     }
1108 
1109     @Override
1110     @ForceInline
1111     public $vectortype$ shiftRight(int s) {
1112         return VectorIntrinsics.broadcastInt(
1113             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1114             this, s,
1115             (v, i) -> v.uOp((__, a) -> ($type$) (a >>> i)));
1116     }
1117 
1118     @Override
1119     @ForceInline
1120     public $vectortype$ shiftRight(int s, VectorMask<$Boxtype$> m) {
1121         return blend(shiftRight(s), m);
1122     }
1123 
1124     @Override
1125     @ForceInline
1126     public $vectortype$ shiftArithmeticRight(int s) {
1127         return VectorIntrinsics.broadcastInt(
1128             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1129             this, s,
1130             (v, i) -> v.uOp((__, a) -> ($type$) (a >> i)));
1131     }
1132 
1133     @Override
1134     @ForceInline
1135     public $vectortype$ shiftArithmeticRight(int s, VectorMask<$Boxtype$> m) {
1136         return blend(shiftArithmeticRight(s), m);
1137     }
1138 
1139     @Override
1140     @ForceInline
1141     public $vectortype$ shiftLeft(Vector<$Boxtype$> s) {
1142         $vectortype$ shiftv = ($vectortype$)s;
1143         // As per shift specification for Java, mask the shift count.
1144         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1145         return VectorIntrinsics.binaryOp(
1146             VECTOR_OP_LSHIFT, $vectortype$.class, $type$.class, LENGTH,
1147             this, shiftv,
1148             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a << b)));
1149     }
1150 
1151     @Override
1152     @ForceInline
1153     public $vectortype$ shiftRight(Vector<$Boxtype$> s) {
1154         $vectortype$ shiftv = ($vectortype$)s;
1155         // As per shift specification for Java, mask the shift count.
1156         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1157         return VectorIntrinsics.binaryOp(
1158             VECTOR_OP_URSHIFT, $vectortype$.class, $type$.class, LENGTH,
1159             this, shiftv,
1160             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >>> b)));
1161     }
1162 
1163     @Override
1164     @ForceInline
1165     public $vectortype$ shiftArithmeticRight(Vector<$Boxtype$> s) {
1166         $vectortype$ shiftv = ($vectortype$)s;
1167         // As per shift specification for Java, mask the shift count.
1168         shiftv = shiftv.and($abstractvectortype$.broadcast(SPECIES, {#if[int]?0x1f:0x3f}));
1169         return VectorIntrinsics.binaryOp(
1170             VECTOR_OP_RSHIFT, $vectortype$.class, $type$.class, LENGTH,
1171             this, shiftv,
1172             (v1, v2) -> v1.bOp(v2,(i,a, b) -> ($type$) (a >> b)));
1173     }
1174 #end[intOrLong]
1175     // Ternary operations
1176 
1177 #if[FP]
1178     @Override
1179     @ForceInline
1180     public $vectortype$ fma(Vector<$Boxtype$> o1, Vector<$Boxtype$> o2) {
1181         Objects.requireNonNull(o1);
1182         Objects.requireNonNull(o2);
1183         $vectortype$ v1 = ($vectortype$)o1;
1184         $vectortype$ v2 = ($vectortype$)o2;
1185         return VectorIntrinsics.ternaryOp(
1186             VECTOR_OP_FMA, $vectortype$.class, $type$.class, LENGTH,
1187             this, v1, v2,
1188             (w1, w2, w3) -> w1.tOp(w2, w3, (i, a, b, c) -> Math.fma(a, b, c)));
1189     }
1190 #end[FP]
1191 
1192     // Type specific horizontal reductions
1193 #if[BITWISE]
1194 
1195     @Override
1196     @ForceInline
1197     public $type$ addLanes() {
1198         return ($type$) VectorIntrinsics.reductionCoerced(
1199             VECTOR_OP_ADD, $vectortype$.class, $type$.class, LENGTH,
1200             this,
1201             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a + b)));
1202     }
1203 
1204     @Override
1205     @ForceInline
1206     public $type$ andLanes() {
1207         return ($type$) VectorIntrinsics.reductionCoerced(
1208             VECTOR_OP_AND, $vectortype$.class, $type$.class, LENGTH,
1209             this,
1210             v -> (long) v.rOp(($type$) -1, (i, a, b) -> ($type$) (a & b)));
1211     }
1212 
1213     @Override
1214     @ForceInline
1215     public $type$ andLanes(VectorMask<$Boxtype$> m) {
1216         return $abstractvectortype$.broadcast(SPECIES, ($type$) -1).blend(this, m).andLanes();
1217     }
1218 
1219     @Override
1220     @ForceInline
1221     public $type$ minLanes() {
1222         return ($type$) VectorIntrinsics.reductionCoerced(
1223             VECTOR_OP_MIN, $vectortype$.class, $type$.class, LENGTH,
1224             this,
1225             v -> (long) v.rOp($Boxtype$.MAX_VALUE , (i, a, b) -> ($type$) Math.min(a, b)));
1226     }
1227 
1228     @Override
1229     @ForceInline
1230     public $type$ maxLanes() {
1231         return ($type$) VectorIntrinsics.reductionCoerced(
1232             VECTOR_OP_MAX, $vectortype$.class, $type$.class, LENGTH,
1233             this,
1234             v -> (long) v.rOp($Boxtype$.MIN_VALUE , (i, a, b) -> ($type$) Math.max(a, b)));
1235     }
1236 
1237     @Override
1238     @ForceInline
1239     public $type$ mulLanes() {
1240         return ($type$) VectorIntrinsics.reductionCoerced(
1241             VECTOR_OP_MUL, $vectortype$.class, $type$.class, LENGTH,
1242             this,
1243             v -> (long) v.rOp(($type$) 1, (i, a, b) -> ($type$) (a * b)));
1244     }
1245 
1246     @Override
1247     @ForceInline
1248     public $type$ orLanes() {
1249         return ($type$) VectorIntrinsics.reductionCoerced(
1250             VECTOR_OP_OR, $vectortype$.class, $type$.class, LENGTH,
1251             this,
1252             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a | b)));
1253     }
1254 
1255     @Override
1256     @ForceInline
1257     public $type$ orLanes(VectorMask<$Boxtype$> m) {
1258         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).orLanes();
1259     }
1260 
1261     @Override
1262     @ForceInline
1263     public $type$ xorLanes() {
1264         return ($type$) VectorIntrinsics.reductionCoerced(
1265             VECTOR_OP_XOR, $vectortype$.class, $type$.class, LENGTH,
1266             this,
1267             v -> (long) v.rOp(($type$) 0, (i, a, b) -> ($type$) (a ^ b)));
1268     }
1269 
1270     @Override
1271     @ForceInline
1272     public $type$ xorLanes(VectorMask<$Boxtype$> m) {
1273         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).xorLanes();
1274     }
1275 #end[BITWISE]
1276 
1277 #if[FP]
1278     @Override
1279     @ForceInline
1280     public $type$ addLanes() {
1281         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1282                                 VECTOR_OP_ADD, $vectortype$.class, $type$.class, LENGTH,
1283                                 this,
1284                                 v -> {
1285                                     $type$ r = v.rOp(($type$) 0, (i, a, b) -> ($type$) (a + b));
1286                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1287                                 });
1288         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1289     }
1290 
1291     @Override
1292     @ForceInline
1293     public $type$ mulLanes() {
1294         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1295                                 VECTOR_OP_MUL, $vectortype$.class, $type$.class, LENGTH,
1296                                 this,
1297                                 v -> {
1298                                     $type$ r = v.rOp(($type$) 1, (i, a, b) -> ($type$) (a * b));
1299                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1300                                 });
1301         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1302     }
1303 
1304     @Override
1305     @ForceInline
1306     public $type$ minLanes() {
1307         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1308                                 VECTOR_OP_MIN, $vectortype$.class, $type$.class, LENGTH,
1309                                 this,
1310                                 v -> {
1311                                     $type$ r = v.rOp($Boxtype$.POSITIVE_INFINITY , (i, a, b) -> ($type$) Math.min(a, b));
1312                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1313                                 });
1314         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1315     }
1316 
1317     @Override
1318     @ForceInline
1319     public $type$ maxLanes() {
1320         $bitstype$ bits = ($bitstype$) VectorIntrinsics.reductionCoerced(
1321                                 VECTOR_OP_MAX, $vectortype$.class, $type$.class, LENGTH,
1322                                 this,
1323                                 v -> {
1324                                     $type$ r = v.rOp($Boxtype$.NEGATIVE_INFINITY, (i, a, b) -> ($type$) Math.max(a, b));
1325                                     return (long)$Type$.$type$To$Bitstype$Bits(r);
1326                                 });
1327         return $Type$.$bitstype$BitsTo$Fptype$(bits);
1328     }
1329 
1330 #end[FP]
1331 
1332     @Override
1333     @ForceInline
1334     public $type$ addLanes(VectorMask<$Boxtype$> m) {
1335         return $abstractvectortype$.broadcast(SPECIES, ($type$) 0).blend(this, m).addLanes();
1336     }
1337 
1338 
1339     @Override
1340     @ForceInline
1341     public $type$ mulLanes(VectorMask<$Boxtype$> m) {
1342         return $abstractvectortype$.broadcast(SPECIES, ($type$) 1).blend(this, m).mulLanes();
1343     }
1344 
1345     @Override
1346     @ForceInline
1347     public $type$ minLanes(VectorMask<$Boxtype$> m) {
1348         return $abstractvectortype$.broadcast(SPECIES, $Boxtype$.MAX_VALUE).blend(this, m).minLanes();
1349     }
1350 
1351     @Override
1352     @ForceInline
1353     public $type$ maxLanes(VectorMask<$Boxtype$> m) {
1354         return $abstractvectortype$.broadcast(SPECIES, $Boxtype$.MIN_VALUE).blend(this, m).maxLanes();
1355     }
1356 
1357     @Override
1358     @ForceInline
1359     public VectorShuffle<$Boxtype$> toShuffle() {
1360         $type$[] a = toArray();
1361         int[] sa = new int[a.length];
1362         for (int i = 0; i < a.length; i++) {
1363             sa[i] = (int) a[i];
1364         }
1365         return VectorShuffle.fromArray(SPECIES, sa, 0);
1366     }
1367 
1368     // Memory operations
1369 
1370     private static final int ARRAY_SHIFT         = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_$TYPE$_INDEX_SCALE);
1371     private static final int BOOLEAN_ARRAY_SHIFT = 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
1372 
1373     @Override
1374     @ForceInline


1607         $bitstype$[] res = new $bitstype$[this.species().length()];
1608         for(int i = 0; i < this.species().length(); i++){
1609             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1610         }
1611         return new $bitsvectortype$(res);
1612     }
1613 #end[FP]
1614 
1615 #if[intOrLong]
1616     $fpvectortype$ toFP() {
1617         $type$[] vec = getElements();
1618         $fptype$[] res = new $fptype$[this.species().length()];
1619         for(int i = 0; i < this.species().length(); i++){
1620             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1621         }
1622         return new $fpvectortype$(res);
1623     }
1624 #end[intOrLong]
1625 
1626     @Override
1627     public $vectortype$ rotateLanesLeft(int j) {
1628         $type$[] vec = getElements();
1629         $type$[] res = new $type$[length()];
1630         for (int i = 0; i < length(); i++){
1631             res[(j + i) % length()] = vec[i];
1632         }
1633         return new $vectortype$(res);
1634     }
1635 
1636     @Override
1637     public $vectortype$ rotateLanesRight(int j) {
1638         $type$[] vec = getElements();
1639         $type$[] res = new $type$[length()];
1640         for (int i = 0; i < length(); i++){
1641             int z = i - j;
1642             if(j < 0) {
1643                 res[length() + z] = vec[i];
1644             } else {
1645                 res[z] = vec[i];
1646             }
1647         }
1648         return new $vectortype$(res);
1649     }
1650 
1651     @Override
1652     public $vectortype$ shiftLanesLeft(int j) {
1653         $type$[] vec = getElements();
1654         $type$[] res = new $type$[length()];
1655         for (int i = 0; i < length() - j; i++) {
1656             res[i] = vec[i + j];
1657         }
1658         return new $vectortype$(res);
1659     }
1660 
1661     @Override
1662     public $vectortype$ shiftLanesRight(int j) {
1663         $type$[] vec = getElements();
1664         $type$[] res = new $type$[length()];
1665         for (int i = 0; i < length() - j; i++){
1666             res[i + j] = vec[i];
1667         }
1668         return new $vectortype$(res);
1669     }
1670 
1671     @Override
1672     @ForceInline
1673     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1674                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1675         return this.rearrange(s).blend(v.rearrange(s), m);
1676     }
1677 
1678     @Override
1679     @ForceInline
1680     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1681         Objects.requireNonNull(o1);
1682         $shuffletype$ s =  ($shuffletype$)o1;


< prev index next >