1 /*
   2  * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 import jdk.incubator.vector.*;
  24 import jdk.internal.vm.annotation.ForceInline;
  25 import org.testng.Assert;
  26 import org.testng.annotations.Test;
  27 import org.testng.annotations.DataProvider;
  28 
  29 import java.lang.invoke.MethodHandles;
  30 import java.lang.invoke.VarHandle;
  31 import java.nio.ByteOrder;
  32 import java.util.Arrays;
  33 import java.util.List;
  34 import java.util.function.IntFunction;
  35 import jdk.incubator.vector.VectorShape;
  36 import jdk.incubator.vector.VectorSpecies;
  37 
  38 /**
  39  * @test
  40  * @modules jdk.incubator.vector
  41  * @modules java.base/jdk.internal.vm.annotation
  42  * @run testng/othervm/timeout=240 --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
  43  *      -XX:-TieredCompilation VectorReshapeTests
  44  */
  45 
  46 @Test
  47 public class VectorReshapeTests {
  48     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  49     static final int NUM_ITER = 200 * INVOC_COUNT;
  50 
  51     static final VectorShape S_Max_BIT = getMaxBit();
  52 
  53     static final VectorSpecies<Integer> ispec64 = IntVector.SPECIES_64;
  54     static final VectorSpecies<Float> fspec64 = FloatVector.SPECIES_64;
  55     static final VectorSpecies<Long> lspec64 = LongVector.SPECIES_64;
  56     static final VectorSpecies<Double> dspec64 = DoubleVector.SPECIES_64;
  57     static final VectorSpecies<Byte> bspec64 = ByteVector.SPECIES_64;
  58     static final VectorSpecies<Short> sspec64 = ShortVector.SPECIES_64;
  59 
  60     static final VectorSpecies<Integer> ispec128 = IntVector.SPECIES_128;
  61     static final VectorSpecies<Float> fspec128 = FloatVector.SPECIES_128;
  62     static final VectorSpecies<Long> lspec128 = LongVector.SPECIES_128;
  63     static final VectorSpecies<Double> dspec128 = DoubleVector.SPECIES_128;
  64     static final VectorSpecies<Byte> bspec128 = ByteVector.SPECIES_128;
  65     static final VectorSpecies<Short> sspec128 = ShortVector.SPECIES_128;
  66 
  67     static final VectorSpecies<Integer> ispec256 = IntVector.SPECIES_256;
  68     static final VectorSpecies<Float> fspec256 = FloatVector.SPECIES_256;
  69     static final VectorSpecies<Long> lspec256 = LongVector.SPECIES_256;
  70     static final VectorSpecies<Double> dspec256 = DoubleVector.SPECIES_256;
  71     static final VectorSpecies<Byte> bspec256 = ByteVector.SPECIES_256;
  72     static final VectorSpecies<Short> sspec256 = ShortVector.SPECIES_256;
  73 
  74     static final VectorSpecies<Integer> ispec512 = IntVector.SPECIES_512;
  75     static final VectorSpecies<Float> fspec512 = FloatVector.SPECIES_512;
  76     static final VectorSpecies<Long> lspec512 = LongVector.SPECIES_512;
  77     static final VectorSpecies<Double> dspec512 = DoubleVector.SPECIES_512;
  78     static final VectorSpecies<Byte> bspec512 = ByteVector.SPECIES_512;
  79     static final VectorSpecies<Short> sspec512 = ShortVector.SPECIES_512;
  80 
  81     static final VectorSpecies<Integer> ispecMax = IntVector.SPECIES_MAX;
  82     static final VectorSpecies<Float> fspecMax = FloatVector.SPECIES_MAX;
  83     static final VectorSpecies<Long> lspecMax = LongVector.SPECIES_MAX;
  84     static final VectorSpecies<Double> dspecMax = DoubleVector.SPECIES_MAX;
  85     static final VectorSpecies<Byte> bspecMax = ByteVector.SPECIES_MAX;
  86     static final VectorSpecies<Short> sspecMax = ShortVector.SPECIES_MAX;
  87 
  88     static VectorShape getMaxBit() {
  89         return VectorShape.S_Max_BIT;
  90     }
  91 
  92     static <T> IntFunction<T> withToString(String s, IntFunction<T> f) {
  93         return new IntFunction<T>() {
  94             @Override
  95             public T apply(int v) {
  96                 return f.apply(v);
  97             }
  98 
  99             @Override
 100             public String toString() {
 101                 return s;
 102             }
 103         };
 104     }
 105 
 106     interface ToByteF {
 107         byte apply(int i);
 108     }
 109 
 110     static byte[] fill_byte(int s , ToByteF f) {
 111         return fill_byte(new byte[s], f);
 112     }
 113 
 114     static byte[] fill_byte(byte[] a, ToByteF f) {
 115         for (int i = 0; i < a.length; i++) {
 116             a[i] = f.apply(i);
 117         }
 118         return a;
 119     }
 120 
 121     interface ToBoolF {
 122         boolean apply(int i);
 123     }
 124 
 125     static boolean[] fill_bool(int s , ToBoolF f) {
 126         return fill_bool(new boolean[s], f);
 127     }
 128 
 129     static boolean[] fill_bool(boolean[] a, ToBoolF f) {
 130         for (int i = 0; i < a.length; i++) {
 131             a[i] = f.apply(i);
 132         }
 133         return a;
 134     }
 135 
 136     interface ToShortF {
 137         short apply(int i);
 138     }
 139 
 140     static short[] fill_short(int s , ToShortF f) {
 141         return fill_short(new short[s], f);
 142     }
 143 
 144     static short[] fill_short(short[] a, ToShortF f) {
 145         for (int i = 0; i < a.length; i++) {
 146             a[i] = f.apply(i);
 147         }
 148         return a;
 149     }
 150 
 151     interface ToIntF {
 152         int apply(int i);
 153     }
 154 
 155     static int[] fill_int(int s , ToIntF f) {
 156         return fill_int(new int[s], f);
 157     }
 158 
 159     static int[] fill_int(int[] a, ToIntF f) {
 160         for (int i = 0; i < a.length; i++) {
 161             a[i] = f.apply(i);
 162         }
 163         return a;
 164     }
 165 
 166     interface ToLongF {
 167         long apply(int i);
 168     }
 169 
 170     static long[] fill_long(int s , ToLongF f) {
 171         return fill_long(new long[s], f);
 172     }
 173 
 174     static long[] fill_long(long[] a, ToLongF f) {
 175         for (int i = 0; i < a.length; i++) {
 176             a[i] = f.apply(i);
 177         }
 178         return a;
 179     }
 180 
 181     interface ToFloatF {
 182         float apply(int i);
 183     }
 184 
 185     static float[] fill_float(int s , ToFloatF f) {
 186         return fill_float(new float[s], f);
 187     }
 188 
 189     static float[] fill_float(float[] a, ToFloatF f) {
 190         for (int i = 0; i < a.length; i++) {
 191             a[i] = f.apply(i);
 192         }
 193         return a;
 194     }
 195 
 196     interface ToDoubleF {
 197         double apply(int i);
 198     }
 199 
 200     static double[] fill_double(int s , ToDoubleF f) {
 201         return fill_double(new double[s], f);
 202     }
 203 
 204     static double[] fill_double(double[] a, ToDoubleF f) {
 205         for (int i = 0; i < a.length; i++) {
 206             a[i] = f.apply(i);
 207         }
 208         return a;
 209     }
 210 
 211     static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of(
 212             withToString("byte(i)", (int s) -> {
 213                 return fill_byte(s, i -> (byte)(i+1));
 214             })
 215     );
 216 
 217     @DataProvider
 218     public Object[][] byteUnaryOpProvider() {
 219         return BYTE_GENERATORS.stream().
 220                 map(f -> new Object[]{f}).
 221                 toArray(Object[][]::new);
 222     }
 223 
 224     static final List<IntFunction<boolean[]>> BOOL_GENERATORS = List.of(
 225         withToString("boolean(i%3)", (int s) -> {
 226             return fill_bool(s, i -> i % 3 == 0);
 227         })
 228     );
 229 
 230     @DataProvider
 231     public Object[][] booleanUnaryOpProvider() {
 232         return BOOL_GENERATORS.stream().
 233                 map(f -> new Object[]{f}).
 234                 toArray(Object[][]::new);
 235     }
 236 
 237     static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
 238             withToString("short(i)", (int s) -> {
 239                 return fill_short(s, i -> (short)(i*100+1));
 240             })
 241     );
 242 
 243     @DataProvider
 244     public Object[][] shortUnaryOpProvider() {
 245         return SHORT_GENERATORS.stream().
 246                 map(f -> new Object[]{f}).
 247                 toArray(Object[][]::new);
 248     }
 249 
 250     static final List<IntFunction<int[]>> INT_GENERATORS = List.of(
 251             withToString("int(i)", (int s) -> {
 252                 return fill_int(s, i -> (int)(i^((i&1)-1)));
 253             })
 254     );
 255 
 256     @DataProvider
 257     public Object[][] intUnaryOpProvider() {
 258         return INT_GENERATORS.stream().
 259                 map(f -> new Object[]{f}).
 260                 toArray(Object[][]::new);
 261     }
 262 
 263     static final List<IntFunction<long[]>> LONG_GENERATORS = List.of(
 264             withToString("long(i)", (int s) -> {
 265                 return fill_long(s, i -> (long)(i^((i&1)-1)));
 266             })
 267     );
 268 
 269     @DataProvider
 270     public Object[][] longUnaryOpProvider() {
 271         return LONG_GENERATORS.stream().
 272                 map(f -> new Object[]{f}).
 273                 toArray(Object[][]::new);
 274     }
 275 
 276     static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of(
 277             withToString("float(i)", (int s) -> {
 278                 return fill_float(s, i -> (float)(i * 10 + 0.1));
 279             })
 280     );
 281 
 282     @DataProvider
 283     public Object[][] floatUnaryOpProvider() {
 284         return FLOAT_GENERATORS.stream().
 285                 map(f -> new Object[]{f}).
 286                 toArray(Object[][]::new);
 287     }
 288 
 289     static final List<IntFunction<double[]>> DOUBLE_GENERATORS = List.of(
 290             withToString("double(i)", (int s) -> {
 291                 return fill_double(s, i -> (double)(i * 10 + 0.1));
 292             })
 293     );
 294 
 295     @DataProvider
 296     public Object[][] doubleUnaryOpProvider() {
 297         return DOUBLE_GENERATORS.stream().
 298                 map(f -> new Object[]{f}).
 299                 toArray(Object[][]::new);
 300     }
 301 
 302     static int partLimit(VectorSpecies<?> a, VectorSpecies<?> b, boolean lanewise) {
 303         int partLimit = a.partLimit(b, lanewise);
 304         // Check it:
 305         int parts = (partLimit >= 0 ? Math.max(1, partLimit) : -partLimit);
 306         int asize = a.vectorByteSize(), bsize = b.vectorByteSize();
 307         if (lanewise) {
 308             asize *= b.elementSize();
 309             asize /= a.elementSize();
 310         }
 311         int larger = Math.max(asize, bsize);
 312         int smaller = Math.min(asize, bsize);
 313         assert(parts == larger / smaller) : Arrays.asList(partLimit, parts, a+":"+asize, b+":"+bsize);
 314         if (asize > bsize) assert(partLimit > 0);
 315         else if (asize < bsize) assert(partLimit < 0);
 316         else  assert(partLimit == 0);
 317         return partLimit;
 318     }
 319 
 320     @ForceInline
 321     static <E>
 322     void testVectorReshape(VectorSpecies<E> a, VectorSpecies<E> b, byte[] input, byte[] output) {
 323         testVectorReshape(a, b, input, output, false);
 324         testVectorReshapeLanewise(a, b, input, output);
 325     }
 326     @ForceInline
 327     static <E>
 328     void testVectorReshapeLanewise(VectorSpecies<E> a, VectorSpecies<E> b, byte[] input, byte[] output) {
 329         testVectorReshape(a, b, input, output, true);
 330     }
 331     @ForceInline
 332     static <E>
 333     void testVectorReshape(VectorSpecies<E> a, VectorSpecies<E> b, byte[] input, byte[] output, boolean lanewise) {
 334         Class<?> atype = a.elementType(), btype = b.elementType();
 335         Vector<E> av = a.fromByteArray(input, 0, ByteOrder.nativeOrder());
 336         int partLimit = partLimit(a, b, lanewise);
 337         int block = Math.min(a.vectorByteSize(), b.vectorByteSize());
 338         if (false)
 339             System.out.println("testing "+a+"->"+b+
 340                                (lanewise?" (lanewise)":" (reinterpret)")+
 341                                ", partLimit=" + partLimit +
 342                                ", block=" + block);
 343         byte[] expected;
 344         int origin;
 345         if (partLimit > 0) {
 346             for (int part = 0; part < partLimit; part++) {
 347                 Vector<E> bv = (lanewise
 348                                 ? av.castShape(b, part)
 349                                 : av.reinterpretShape(b, part));
 350                 bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 351                 // expansion: slice some of the input
 352                 origin = part * block;
 353                 expected = Arrays.copyOfRange(input, origin, origin + block);
 354                 if (lanewise) {
 355                     expected = castByteArrayData(expected, atype, btype);
 356                 }
 357                 checkPartialResult(a, b, input, output, expected,
 358                                    lanewise, part, origin);
 359             }
 360         } else if (partLimit < 0) {
 361             for (int part = 0; part > partLimit; part--) {
 362                 Vector<E> bv = (lanewise
 363                                 ? av.castShape(b, part)
 364                                 : av.reinterpretShape(b, part));
 365                 bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 366                 // contraction: unslice the input into part of the output
 367                 byte[] logical = input;
 368                 if (lanewise) {
 369                     logical = castByteArrayData(input, atype, btype);
 370                 }
 371                 assert(logical.length == block);
 372                 expected = new byte[output.length];
 373                 origin = -part * block;
 374                 System.arraycopy(logical, 0, expected, origin, block);
 375                 checkPartialResult(a, b, input, output, expected,
 376                                    lanewise, part, origin);
 377             }
 378         } else {
 379             int part = 0;
 380             Vector<E> bv = (lanewise
 381                             ? av.castShape(b, part)
 382                             : av.reinterpretShape(b, part));
 383             bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 384             // in-place copy, no resize
 385             expected = input;
 386             origin = 0;
 387             if (lanewise) {
 388                 expected = castByteArrayData(expected, atype, btype);
 389             }
 390             checkPartialResult(a, b, input, output, expected,
 391                                lanewise, part, origin);
 392         }
 393     }
 394 
 395     static
 396     void checkPartialResult(VectorSpecies<?> a, VectorSpecies<?> b,
 397                             byte[] input, byte[] output, byte[] expected,
 398                             boolean lanewise, int part, int origin) {
 399         if (Arrays.equals(expected, output)) {
 400             return;
 401         }
 402         int partLimit = partLimit(a, b, lanewise);
 403         int block;
 404         if (!lanewise)
 405             block = Math.min(a.vectorByteSize(), b.vectorByteSize());
 406         else if (partLimit >= 0)
 407             block = a.vectorByteSize() / Math.max(1, partLimit);
 408         else
 409             block = b.vectorByteSize() / -partLimit;
 410         System.out.println("input:  "+Arrays.toString(input));
 411         System.out.println("Failing with "+a+"->"+b+
 412                            (lanewise?" (lanewise)":" (reinterpret)")+
 413                            ", partLimit=" + partLimit +
 414                            ", block=" + block +
 415                            ", part=" + part +
 416                            ", origin=" + origin);
 417         System.out.println("expect: "+Arrays.toString(expected));
 418         System.out.println("output: "+Arrays.toString(output));
 419         Assert.assertEquals(output, expected);
 420     }
 421 
 422     @Test(dataProvider = "byteUnaryOpProvider")
 423     static void testReshapeByte(IntFunction<byte[]> fa) {
 424         byte[] bin64 = fa.apply(64/Byte.SIZE);
 425         byte[] bin128 = fa.apply(128/Byte.SIZE);
 426         byte[] bin256 = fa.apply(256/Byte.SIZE);
 427         byte[] bin512 = fa.apply(512/Byte.SIZE);
 428         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 429         byte[] bout64 = new byte[bin64.length];
 430         byte[] bout128 = new byte[bin128.length];
 431         byte[] bout256 = new byte[bin256.length];
 432         byte[] bout512 = new byte[bin512.length];
 433         byte[] boutMax = new byte[binMax.length];
 434 
 435         for (int i = 0; i < NUM_ITER; i++) {
 436             testVectorReshape(bspec64, bspec64, bin64, bout64);
 437             testVectorReshape(bspec64, bspec128, bin64, bout128);
 438             testVectorReshape(bspec64, bspec256, bin64, bout256);
 439             testVectorReshape(bspec64, bspec512, bin64, bout512);
 440             testVectorReshape(bspec64, bspecMax, bin64, boutMax);
 441 
 442             testVectorReshape(bspec128, bspec64, bin128, bout64);
 443             testVectorReshape(bspec128, bspec128, bin128, bout128);
 444             testVectorReshape(bspec128, bspec256, bin128, bout256);
 445             testVectorReshape(bspec128, bspec512, bin128, bout512);
 446             testVectorReshape(bspec128, bspecMax, bin128, boutMax);
 447 
 448             testVectorReshape(bspec256, bspec64, bin256, bout64);
 449             testVectorReshape(bspec256, bspec128, bin256, bout128);
 450             testVectorReshape(bspec256, bspec256, bin256, bout256);
 451             testVectorReshape(bspec256, bspec512, bin256, bout512);
 452             testVectorReshape(bspec256, bspecMax, bin256, boutMax);
 453 
 454             testVectorReshape(bspec512, bspec64, bin512, bout64);
 455             testVectorReshape(bspec512, bspec128, bin512, bout128);
 456             testVectorReshape(bspec512, bspec256, bin512, bout256);
 457             testVectorReshape(bspec512, bspec512, bin512, bout512);
 458             testVectorReshape(bspec512, bspecMax, bin512, boutMax);
 459 
 460             testVectorReshape(bspecMax, bspec64, binMax, bout64);
 461             testVectorReshape(bspecMax, bspec128, binMax, bout128);
 462             testVectorReshape(bspecMax, bspec256, binMax, bout256);
 463             testVectorReshape(bspecMax, bspec512, binMax, bout512);
 464             testVectorReshape(bspecMax, bspecMax, binMax, boutMax);
 465         }
 466     }
 467 
 468     @Test(dataProvider = "byteUnaryOpProvider")
 469     static void testReshapeShort(IntFunction<byte[]> fa) {
 470         byte[] bin64 = fa.apply(64/Byte.SIZE);
 471         byte[] bin128 = fa.apply(128/Byte.SIZE);
 472         byte[] bin256 = fa.apply(256/Byte.SIZE);
 473         byte[] bin512 = fa.apply(512/Byte.SIZE);
 474         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 475         byte[] bout64 = new byte[bin64.length];
 476         byte[] bout128 = new byte[bin128.length];
 477         byte[] bout256 = new byte[bin256.length];
 478         byte[] bout512 = new byte[bin512.length];
 479         byte[] boutMax = new byte[binMax.length];
 480 
 481         for (int i = 0; i < NUM_ITER; i++) {
 482             testVectorReshape(sspec64, sspec64, bin64, bout64);
 483             testVectorReshape(sspec64, sspec128, bin64, bout128);
 484             testVectorReshape(sspec64, sspec256, bin64, bout256);
 485             testVectorReshape(sspec64, sspec512, bin64, bout512);
 486             testVectorReshape(sspec64, sspecMax, bin64, boutMax);
 487 
 488             testVectorReshape(sspec128, sspec64, bin128, bout64);
 489             testVectorReshape(sspec128, sspec128, bin128, bout128);
 490             testVectorReshape(sspec128, sspec256, bin128, bout256);
 491             testVectorReshape(sspec128, sspec512, bin128, bout512);
 492             testVectorReshape(sspec128, sspecMax, bin128, boutMax);
 493 
 494             testVectorReshape(sspec256, sspec64, bin256, bout64);
 495             testVectorReshape(sspec256, sspec128, bin256, bout128);
 496             testVectorReshape(sspec256, sspec256, bin256, bout256);
 497             testVectorReshape(sspec256, sspec512, bin256, bout512);
 498             testVectorReshape(sspec256, sspecMax, bin256, boutMax);
 499 
 500             testVectorReshape(sspec512, sspec64, bin512, bout64);
 501             testVectorReshape(sspec512, sspec128, bin512, bout128);
 502             testVectorReshape(sspec512, sspec256, bin512, bout256);
 503             testVectorReshape(sspec512, sspec512, bin512, bout512);
 504             testVectorReshape(sspec512, sspecMax, bin512, boutMax);
 505 
 506             testVectorReshape(sspecMax, sspec64, binMax, bout64);
 507             testVectorReshape(sspecMax, sspec128, binMax, bout128);
 508             testVectorReshape(sspecMax, sspec256, binMax, bout256);
 509             testVectorReshape(sspecMax, sspec512, binMax, bout512);
 510             testVectorReshape(sspecMax, sspecMax, binMax, boutMax);
 511         }
 512     }
 513 
 514     @Test(dataProvider = "byteUnaryOpProvider")
 515     static void testReshapeInt(IntFunction<byte[]> fa) {
 516         byte[] bin64 = fa.apply(64/Byte.SIZE);
 517         byte[] bin128 = fa.apply(128/Byte.SIZE);
 518         byte[] bin256 = fa.apply(256/Byte.SIZE);
 519         byte[] bin512 = fa.apply(512/Byte.SIZE);
 520         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 521         byte[] bout64 = new byte[bin64.length];
 522         byte[] bout128 = new byte[bin128.length];
 523         byte[] bout256 = new byte[bin256.length];
 524         byte[] bout512 = new byte[bin512.length];
 525         byte[] boutMax = new byte[binMax.length];
 526 
 527         for (int i = 0; i < NUM_ITER; i++) {
 528             testVectorReshape(ispec64, ispec64, bin64, bout64);
 529             testVectorReshape(ispec64, ispec128, bin64, bout128);
 530             testVectorReshape(ispec64, ispec256, bin64, bout256);
 531             testVectorReshape(ispec64, ispec512, bin64, bout512);
 532             testVectorReshape(ispec64, ispecMax, bin64, boutMax);
 533 
 534             testVectorReshape(ispec128, ispec64, bin128, bout64);
 535             testVectorReshape(ispec128, ispec128, bin128, bout128);
 536             testVectorReshape(ispec128, ispec256, bin128, bout256);
 537             testVectorReshape(ispec128, ispec512, bin128, bout512);
 538             testVectorReshape(ispec128, ispecMax, bin128, boutMax);
 539 
 540             testVectorReshape(ispec256, ispec64, bin256, bout64);
 541             testVectorReshape(ispec256, ispec128, bin256, bout128);
 542             testVectorReshape(ispec256, ispec256, bin256, bout256);
 543             testVectorReshape(ispec256, ispec512, bin256, bout512);
 544             testVectorReshape(ispec256, ispecMax, bin256, boutMax);
 545 
 546             testVectorReshape(ispec512, ispec64, bin512, bout64);
 547             testVectorReshape(ispec512, ispec128, bin512, bout128);
 548             testVectorReshape(ispec512, ispec256, bin512, bout256);
 549             testVectorReshape(ispec512, ispec512, bin512, bout512);
 550             testVectorReshape(ispec512, ispecMax, bin512, boutMax);
 551 
 552             testVectorReshape(ispecMax, ispec64, binMax, bout64);
 553             testVectorReshape(ispecMax, ispec128, binMax, bout128);
 554             testVectorReshape(ispecMax, ispec256, binMax, bout256);
 555             testVectorReshape(ispecMax, ispec512, binMax, bout512);
 556             testVectorReshape(ispecMax, ispecMax, binMax, boutMax);
 557         }
 558     }
 559 
 560     @Test(dataProvider = "byteUnaryOpProvider")
 561     static void testReshapeLong(IntFunction<byte[]> fa) {
 562         byte[] bin64 = fa.apply(64/Byte.SIZE);
 563         byte[] bin128 = fa.apply(128/Byte.SIZE);
 564         byte[] bin256 = fa.apply(256/Byte.SIZE);
 565         byte[] bin512 = fa.apply(512/Byte.SIZE);
 566         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 567         byte[] bout64 = new byte[bin64.length];
 568         byte[] bout128 = new byte[bin128.length];
 569         byte[] bout256 = new byte[bin256.length];
 570         byte[] bout512 = new byte[bin512.length];
 571         byte[] boutMax = new byte[binMax.length];
 572 
 573         for (int i = 0; i < NUM_ITER; i++) {
 574             testVectorReshape(lspec64, lspec64, bin64, bout64);
 575             testVectorReshape(lspec64, lspec128, bin64, bout128);
 576             testVectorReshape(lspec64, lspec256, bin64, bout256);
 577             testVectorReshape(lspec64, lspec512, bin64, bout512);
 578             testVectorReshape(lspec64, lspecMax, bin64, boutMax);
 579 
 580             testVectorReshape(lspec128, lspec64, bin128, bout64);
 581             testVectorReshape(lspec128, lspec128, bin128, bout128);
 582             testVectorReshape(lspec128, lspec256, bin128, bout256);
 583             testVectorReshape(lspec128, lspec512, bin128, bout512);
 584             testVectorReshape(lspec128, lspecMax, bin128, boutMax);
 585 
 586             testVectorReshape(lspec256, lspec64, bin256, bout64);
 587             testVectorReshape(lspec256, lspec128, bin256, bout128);
 588             testVectorReshape(lspec256, lspec256, bin256, bout256);
 589             testVectorReshape(lspec256, lspec512, bin256, bout512);
 590             testVectorReshape(lspec256, lspecMax, bin256, boutMax);
 591 
 592             testVectorReshape(lspec512, lspec64, bin512, bout64);
 593             testVectorReshape(lspec512, lspec128, bin512, bout128);
 594             testVectorReshape(lspec512, lspec256, bin512, bout256);
 595             testVectorReshape(lspec512, lspec512, bin512, bout512);
 596             testVectorReshape(lspec512, lspecMax, bin512, boutMax);
 597 
 598             testVectorReshape(lspecMax, lspec64, binMax, bout64);
 599             testVectorReshape(lspecMax, lspec128, binMax, bout128);
 600             testVectorReshape(lspecMax, lspec256, binMax, bout256);
 601             testVectorReshape(lspecMax, lspec512, binMax, bout512);
 602             testVectorReshape(lspecMax, lspecMax, binMax, boutMax);
 603         }
 604     }
 605 
 606     @Test(dataProvider = "byteUnaryOpProvider")
 607     static void testReshapeFloat(IntFunction<byte[]> fa) {
 608         byte[] bin64 = fa.apply(64/Byte.SIZE);
 609         byte[] bin128 = fa.apply(128/Byte.SIZE);
 610         byte[] bin256 = fa.apply(256/Byte.SIZE);
 611         byte[] bin512 = fa.apply(512/Byte.SIZE);
 612         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 613         byte[] bout64 = new byte[bin64.length];
 614         byte[] bout128 = new byte[bin128.length];
 615         byte[] bout256 = new byte[bin256.length];
 616         byte[] bout512 = new byte[bin512.length];
 617         byte[] boutMax = new byte[binMax.length];
 618 
 619         for (int i = 0; i < NUM_ITER; i++) {
 620             testVectorReshape(fspec64, fspec64, bin64, bout64);
 621             testVectorReshape(fspec64, fspec128, bin64, bout128);
 622             testVectorReshape(fspec64, fspec256, bin64, bout256);
 623             testVectorReshape(fspec64, fspec512, bin64, bout512);
 624             testVectorReshape(fspec64, fspecMax, bin64, boutMax);
 625 
 626             testVectorReshape(fspec128, fspec64, bin128, bout64);
 627             testVectorReshape(fspec128, fspec128, bin128, bout128);
 628             testVectorReshape(fspec128, fspec256, bin128, bout256);
 629             testVectorReshape(fspec128, fspec512, bin128, bout512);
 630             testVectorReshape(fspec128, fspecMax, bin128, boutMax);
 631 
 632             testVectorReshape(fspec256, fspec64, bin256, bout64);
 633             testVectorReshape(fspec256, fspec128, bin256, bout128);
 634             testVectorReshape(fspec256, fspec256, bin256, bout256);
 635             testVectorReshape(fspec256, fspec512, bin256, bout512);
 636             testVectorReshape(fspec256, fspecMax, bin256, boutMax);
 637 
 638             testVectorReshape(fspec512, fspec64, bin512, bout64);
 639             testVectorReshape(fspec512, fspec128, bin512, bout128);
 640             testVectorReshape(fspec512, fspec256, bin512, bout256);
 641             testVectorReshape(fspec512, fspec512, bin512, bout512);
 642             testVectorReshape(fspec512, fspecMax, bin512, boutMax);
 643 
 644             testVectorReshape(fspecMax, fspec64, binMax, bout64);
 645             testVectorReshape(fspecMax, fspec128, binMax, bout128);
 646             testVectorReshape(fspecMax, fspec256, binMax, bout256);
 647             testVectorReshape(fspecMax, fspec512, binMax, bout512);
 648             testVectorReshape(fspecMax, fspecMax, binMax, boutMax);
 649         }
 650     }
 651 
 652     @Test(dataProvider = "byteUnaryOpProvider")
 653     static void testReshapeDouble(IntFunction<byte[]> fa) {
 654         byte[] bin64 = fa.apply(64/Byte.SIZE);
 655         byte[] bin128 = fa.apply(128/Byte.SIZE);
 656         byte[] bin256 = fa.apply(256/Byte.SIZE);
 657         byte[] bin512 = fa.apply(512/Byte.SIZE);
 658         byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
 659         byte[] bout64 = new byte[bin64.length];
 660         byte[] bout128 = new byte[bin128.length];
 661         byte[] bout256 = new byte[bin256.length];
 662         byte[] bout512 = new byte[bin512.length];
 663         byte[] boutMax = new byte[binMax.length];
 664 
 665         for (int i = 0; i < NUM_ITER; i++) {
 666             testVectorReshape(dspec64, dspec64, bin64, bout64);
 667             testVectorReshape(dspec64, dspec128, bin64, bout128);
 668             testVectorReshape(dspec64, dspec256, bin64, bout256);
 669             testVectorReshape(dspec64, dspec512, bin64, bout512);
 670             testVectorReshape(dspec64, dspecMax, bin64, boutMax);
 671 
 672             testVectorReshape(dspec128, dspec64, bin128, bout64);
 673             testVectorReshape(dspec128, dspec128, bin128, bout128);
 674             testVectorReshape(dspec128, dspec256, bin128, bout256);
 675             testVectorReshape(dspec128, dspec512, bin128, bout512);
 676             testVectorReshape(dspec128, dspecMax, bin128, boutMax);
 677 
 678             testVectorReshape(dspec256, dspec64, bin256, bout64);
 679             testVectorReshape(dspec256, dspec128, bin256, bout128);
 680             testVectorReshape(dspec256, dspec256, bin256, bout256);
 681             testVectorReshape(dspec256, dspec512, bin256, bout512);
 682             testVectorReshape(dspec256, dspecMax, bin256, boutMax);
 683 
 684             testVectorReshape(dspec512, dspec64, bin512, bout64);
 685             testVectorReshape(dspec512, dspec128, bin512, bout128);
 686             testVectorReshape(dspec512, dspec256, bin512, bout256);
 687             testVectorReshape(dspec512, dspec512, bin512, bout512);
 688             testVectorReshape(dspec512, dspecMax, bin512, boutMax);
 689 
 690             testVectorReshape(dspecMax, dspec64, binMax, bout64);
 691             testVectorReshape(dspecMax, dspec128, binMax, bout128);
 692             testVectorReshape(dspecMax, dspec256, binMax, bout256);
 693             testVectorReshape(dspecMax, dspec512, binMax, bout512);
 694             testVectorReshape(dspecMax, dspecMax, binMax, boutMax);
 695         }
 696     }
 697     @ForceInline
 698     static <E,F>
 699     void testVectorRebracket(VectorSpecies<E> a, VectorSpecies<F> b, byte[] input, byte[] output) {
 700         testVectorRebracket(a, b, input, output, false);
 701         testVectorRebracketLanewise(a, b, input, output);
 702     }
 703     @ForceInline
 704     static <E,F>
 705     void testVectorRebracketLanewise(VectorSpecies<E> a, VectorSpecies<F> b, byte[] input, byte[] output) {
 706         testVectorRebracket(a, b, input, output, true);
 707     }
 708     @ForceInline
 709     static <E,F>
 710     void testVectorRebracket(VectorSpecies<E> a, VectorSpecies<F> b, byte[] input, byte[] output, boolean lanewise) {
 711         Class<?> atype = a.elementType(), btype = b.elementType();
 712         Vector<E> av = a.fromByteArray(input, 0, ByteOrder.nativeOrder());
 713         int partLimit = partLimit(a, b, lanewise);
 714         int block;
 715         assert(input.length == output.length);
 716         if (!lanewise)
 717             block = Math.min(a.vectorByteSize(), b.vectorByteSize());
 718         else if (partLimit >= 0)
 719             block = a.vectorByteSize() / Math.max(1, partLimit);
 720         else
 721             block = b.vectorByteSize() / -partLimit;
 722         if (lanewise) {
 723             if (atype == btype)  return;
 724             if (atype == float.class || atype == double.class)  return;
 725             if (btype == float.class || btype == double.class)  return;
 726         }
 727         if (false)
 728             System.out.println("testing "+a+"->"+b+
 729                                (lanewise?" (lanewise)":" (reinterpret)")+
 730                                ", partLimit=" + partLimit +
 731                                ", block=" + block);
 732         byte[] expected;
 733         int origin;
 734         if (partLimit > 0) {
 735             for (int part = 0; part < partLimit; part++) {
 736                 Vector<F> bv = (lanewise
 737                                 ? av.castShape(b, part)
 738                                 : av.reinterpretShape(b, part));
 739                 bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 740                 // expansion: slice some of the input
 741                 origin = part * block;
 742                 expected = Arrays.copyOfRange(input, origin, origin + block);
 743                 if (lanewise) {
 744                     expected = castByteArrayData(expected, atype, btype);
 745                 }
 746                 checkPartialResult(a, b, input, output, expected,
 747                                    lanewise, part, origin);
 748             }
 749         } else if (partLimit < 0) {
 750             for (int part = 0; part > partLimit; part--) {
 751                 Vector<F> bv = (lanewise
 752                                 ? av.castShape(b, part)
 753                                 : av.reinterpretShape(b, part));
 754                 bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 755                 // contraction: unslice the input into part of the output
 756                 byte[] logical = input;
 757                 if (lanewise) {
 758                     logical = castByteArrayData(input, atype, btype);
 759                 }
 760                 assert(logical.length == block);
 761                 expected = new byte[output.length];
 762                 origin = -part * block;
 763                 System.arraycopy(logical, 0, expected, origin, block);
 764                 checkPartialResult(a, b, input, output, expected,
 765                                    lanewise, part, origin);
 766             }
 767         } else {
 768             int part = 0;
 769             Vector<F> bv = (lanewise
 770                             ? av.castShape(b, part)
 771                             : av.reinterpretShape(b, part));
 772             bv.intoByteArray(output, 0, ByteOrder.nativeOrder());
 773             // in-place copy, no resize
 774             expected = input;
 775             origin = 0;
 776             if (lanewise) {
 777                 expected = castByteArrayData(expected, atype, btype);
 778             }
 779             checkPartialResult(a, b, input, output, expected,
 780                                lanewise, part, origin);
 781         }
 782     }
 783 
 784     static int decodeType(Class<?> type) {
 785         switch (type.getName().charAt(0)) {
 786         case 'b': return 1;
 787         case 's': return 2;
 788         case 'i': return 4;
 789         case 'l': return 8;
 790         case 'f': return -4;
 791         case 'd': return -8;
 792         }
 793         throw new AssertionError(type);
 794     }
 795 
 796     static byte[] castByteArrayData(byte[] data, Class<?> atype, Class<?> btype) {
 797         if (atype == btype)  return data;
 798         int asize = decodeType(atype), bsize = decodeType(btype);
 799         assert((asize | bsize) > 0);  // no float or double
 800         int count = data.length / asize;
 801         assert(data.length == count * asize);
 802         byte[] result = new byte[count * bsize];
 803 
 804         int minsize = Math.min(asize, bsize);
 805         int size_diff = bsize - asize;
 806         ByteOrder bo = ByteOrder.nativeOrder();
 807         int rp = 0, dp = 0;
 808         for (int i = 0; i < count; i++) {
 809             if (bo == ByteOrder.BIG_ENDIAN) {
 810                 if (size_diff > 0) {
 811                     byte sign = (byte)(data[dp] >> 7); // sign extend
 812                     for (int j = 0; j < size_diff; j++) {
 813                         result[rp++] = sign;
 814                     }
 815                 } else {
 816                     dp -= size_diff; // step forward if needed
 817                 }
 818             }
 819             byte b = 0;
 820             for (int j = 0; j < minsize; j++) {
 821                 b = data[dp++];
 822                 result[rp++] = b;
 823             }
 824             if (bo == ByteOrder.LITTLE_ENDIAN) {
 825                 if (size_diff > 0) {
 826                     byte sign = (byte)(b >> 7); // sign extend
 827                     for (int j = 0; j < size_diff; j++) {
 828                         result[rp++] = sign;
 829                     }
 830                 } else {
 831                     dp -= size_diff; // step forward if needed
 832                 }
 833             }
 834         }
 835         assert(dp == data.length);
 836         assert(rp == result.length);
 837 
 838         return result;
 839     }
 840 
 841     @Test(dataProvider = "byteUnaryOpProvider")
 842     static void testRebracket64(IntFunction<byte[]> fa) {
 843         byte[] barr = fa.apply(64/Byte.SIZE);
 844         byte[] bout = new byte[barr.length];
 845         for (int i = 0; i < NUM_ITER; i++) {
 846             testVectorRebracket(bspec64, bspec64, barr, bout);
 847             testVectorRebracket(bspec64, sspec64, barr, bout);
 848             testVectorRebracket(bspec64, ispec64, barr, bout);
 849             testVectorRebracket(bspec64, lspec64, barr, bout);
 850             testVectorRebracket(bspec64, fspec64, barr, bout);
 851             testVectorRebracket(bspec64, dspec64, barr, bout);
 852 
 853             testVectorRebracket(sspec64, bspec64, barr, bout);
 854             testVectorRebracket(sspec64, sspec64, barr, bout);
 855             testVectorRebracket(sspec64, ispec64, barr, bout);
 856             testVectorRebracket(sspec64, lspec64, barr, bout);
 857             testVectorRebracket(sspec64, fspec64, barr, bout);
 858             testVectorRebracket(sspec64, dspec64, barr, bout);
 859 
 860             testVectorRebracket(ispec64, bspec64, barr, bout);
 861             testVectorRebracket(ispec64, sspec64, barr, bout);
 862             testVectorRebracket(ispec64, ispec64, barr, bout);
 863             testVectorRebracket(ispec64, lspec64, barr, bout);
 864             testVectorRebracket(ispec64, fspec64, barr, bout);
 865             testVectorRebracket(ispec64, dspec64, barr, bout);
 866 
 867             testVectorRebracket(lspec64, bspec64, barr, bout);
 868             testVectorRebracket(lspec64, sspec64, barr, bout);
 869             testVectorRebracket(lspec64, ispec64, barr, bout);
 870             testVectorRebracket(lspec64, lspec64, barr, bout);
 871             testVectorRebracket(lspec64, fspec64, barr, bout);
 872             testVectorRebracket(lspec64, dspec64, barr, bout);
 873 
 874             testVectorRebracket(fspec64, bspec64, barr, bout);
 875             testVectorRebracket(fspec64, sspec64, barr, bout);
 876             testVectorRebracket(fspec64, ispec64, barr, bout);
 877             testVectorRebracket(fspec64, lspec64, barr, bout);
 878             testVectorRebracket(fspec64, fspec64, barr, bout);
 879             testVectorRebracket(fspec64, dspec64, barr, bout);
 880 
 881             testVectorRebracket(dspec64, bspec64, barr, bout);
 882             testVectorRebracket(dspec64, sspec64, barr, bout);
 883             testVectorRebracket(dspec64, ispec64, barr, bout);
 884             testVectorRebracket(dspec64, lspec64, barr, bout);
 885             testVectorRebracket(dspec64, fspec64, barr, bout);
 886             testVectorRebracket(dspec64, dspec64, barr, bout);
 887         }
 888     }
 889 
 890     @Test(dataProvider = "byteUnaryOpProvider")
 891     static void testRebracket128(IntFunction<byte[]> fa) {
 892         byte[] barr = fa.apply(128/Byte.SIZE);
 893         byte[] bout = new byte[barr.length];
 894         for (int i = 0; i < NUM_ITER; i++) {
 895             testVectorRebracket(bspec128, bspec128, barr, bout);
 896             testVectorRebracket(bspec128, sspec128, barr, bout);
 897             testVectorRebracket(bspec128, ispec128, barr, bout);
 898             testVectorRebracket(bspec128, lspec128, barr, bout);
 899             testVectorRebracket(bspec128, fspec128, barr, bout);
 900             testVectorRebracket(bspec128, dspec128, barr, bout);
 901 
 902             testVectorRebracket(sspec128, bspec128, barr, bout);
 903             testVectorRebracket(sspec128, sspec128, barr, bout);
 904             testVectorRebracket(sspec128, ispec128, barr, bout);
 905             testVectorRebracket(sspec128, lspec128, barr, bout);
 906             testVectorRebracket(sspec128, fspec128, barr, bout);
 907             testVectorRebracket(sspec128, dspec128, barr, bout);
 908 
 909             testVectorRebracket(ispec128, bspec128, barr, bout);
 910             testVectorRebracket(ispec128, sspec128, barr, bout);
 911             testVectorRebracket(ispec128, ispec128, barr, bout);
 912             testVectorRebracket(ispec128, lspec128, barr, bout);
 913             testVectorRebracket(ispec128, fspec128, barr, bout);
 914             testVectorRebracket(ispec128, dspec128, barr, bout);
 915 
 916             testVectorRebracket(lspec128, bspec128, barr, bout);
 917             testVectorRebracket(lspec128, sspec128, barr, bout);
 918             testVectorRebracket(lspec128, ispec128, barr, bout);
 919             testVectorRebracket(lspec128, lspec128, barr, bout);
 920             testVectorRebracket(lspec128, fspec128, barr, bout);
 921             testVectorRebracket(lspec128, dspec128, barr, bout);
 922 
 923             testVectorRebracket(fspec128, bspec128, barr, bout);
 924             testVectorRebracket(fspec128, sspec128, barr, bout);
 925             testVectorRebracket(fspec128, ispec128, barr, bout);
 926             testVectorRebracket(fspec128, lspec128, barr, bout);
 927             testVectorRebracket(fspec128, fspec128, barr, bout);
 928             testVectorRebracket(fspec128, dspec128, barr, bout);
 929 
 930             testVectorRebracket(dspec128, bspec128, barr, bout);
 931             testVectorRebracket(dspec128, sspec128, barr, bout);
 932             testVectorRebracket(dspec128, ispec128, barr, bout);
 933             testVectorRebracket(dspec128, lspec128, barr, bout);
 934             testVectorRebracket(dspec128, fspec128, barr, bout);
 935             testVectorRebracket(dspec128, dspec128, barr, bout);
 936         }
 937     }
 938 
 939     @Test(dataProvider = "byteUnaryOpProvider")
 940     static void testRebracket256(IntFunction<byte[]> fa) {
 941         byte[] barr = fa.apply(256/Byte.SIZE);
 942         byte[] bout = new byte[barr.length];
 943         for (int i = 0; i < NUM_ITER; i++) {
 944             testVectorRebracket(bspec256, bspec256, barr, bout);
 945             testVectorRebracket(bspec256, sspec256, barr, bout);
 946             testVectorRebracket(bspec256, ispec256, barr, bout);
 947             testVectorRebracket(bspec256, lspec256, barr, bout);
 948             testVectorRebracket(bspec256, fspec256, barr, bout);
 949             testVectorRebracket(bspec256, dspec256, barr, bout);
 950 
 951             testVectorRebracket(sspec256, bspec256, barr, bout);
 952             testVectorRebracket(sspec256, sspec256, barr, bout);
 953             testVectorRebracket(sspec256, ispec256, barr, bout);
 954             testVectorRebracket(sspec256, lspec256, barr, bout);
 955             testVectorRebracket(sspec256, fspec256, barr, bout);
 956             testVectorRebracket(sspec256, dspec256, barr, bout);
 957 
 958             testVectorRebracket(ispec256, bspec256, barr, bout);
 959             testVectorRebracket(ispec256, sspec256, barr, bout);
 960             testVectorRebracket(ispec256, ispec256, barr, bout);
 961             testVectorRebracket(ispec256, lspec256, barr, bout);
 962             testVectorRebracket(ispec256, fspec256, barr, bout);
 963             testVectorRebracket(ispec256, dspec256, barr, bout);
 964 
 965             testVectorRebracket(lspec256, bspec256, barr, bout);
 966             testVectorRebracket(lspec256, sspec256, barr, bout);
 967             testVectorRebracket(lspec256, ispec256, barr, bout);
 968             testVectorRebracket(lspec256, lspec256, barr, bout);
 969             testVectorRebracket(lspec256, fspec256, barr, bout);
 970             testVectorRebracket(lspec256, dspec256, barr, bout);
 971 
 972             testVectorRebracket(fspec256, bspec256, barr, bout);
 973             testVectorRebracket(fspec256, sspec256, barr, bout);
 974             testVectorRebracket(fspec256, ispec256, barr, bout);
 975             testVectorRebracket(fspec256, lspec256, barr, bout);
 976             testVectorRebracket(fspec256, fspec256, barr, bout);
 977             testVectorRebracket(fspec256, dspec256, barr, bout);
 978 
 979             testVectorRebracket(dspec256, bspec256, barr, bout);
 980             testVectorRebracket(dspec256, sspec256, barr, bout);
 981             testVectorRebracket(dspec256, ispec256, barr, bout);
 982             testVectorRebracket(dspec256, lspec256, barr, bout);
 983             testVectorRebracket(dspec256, fspec256, barr, bout);
 984             testVectorRebracket(dspec256, dspec256, barr, bout);
 985         }
 986     }
 987 
 988     @Test(dataProvider = "byteUnaryOpProvider")
 989     static void testRebracket512(IntFunction<byte[]> fa) {
 990         byte[] barr = fa.apply(512/Byte.SIZE);
 991         byte[] bout = new byte[barr.length];
 992         for (int i = 0; i < NUM_ITER; i++) {
 993             testVectorRebracket(bspec512, bspec512, barr, bout);
 994             testVectorRebracket(bspec512, sspec512, barr, bout);
 995             testVectorRebracket(bspec512, ispec512, barr, bout);
 996             testVectorRebracket(bspec512, lspec512, barr, bout);
 997             testVectorRebracket(bspec512, fspec512, barr, bout);
 998             testVectorRebracket(bspec512, dspec512, barr, bout);
 999 
1000             testVectorRebracket(sspec512, bspec512, barr, bout);
1001             testVectorRebracket(sspec512, sspec512, barr, bout);
1002             testVectorRebracket(sspec512, ispec512, barr, bout);
1003             testVectorRebracket(sspec512, lspec512, barr, bout);
1004             testVectorRebracket(sspec512, fspec512, barr, bout);
1005             testVectorRebracket(sspec512, dspec512, barr, bout);
1006 
1007             testVectorRebracket(ispec512, bspec512, barr, bout);
1008             testVectorRebracket(ispec512, sspec512, barr, bout);
1009             testVectorRebracket(ispec512, ispec512, barr, bout);
1010             testVectorRebracket(ispec512, lspec512, barr, bout);
1011             testVectorRebracket(ispec512, fspec512, barr, bout);
1012             testVectorRebracket(ispec512, dspec512, barr, bout);
1013 
1014             testVectorRebracket(lspec512, bspec512, barr, bout);
1015             testVectorRebracket(lspec512, sspec512, barr, bout);
1016             testVectorRebracket(lspec512, ispec512, barr, bout);
1017             testVectorRebracket(lspec512, lspec512, barr, bout);
1018             testVectorRebracket(lspec512, fspec512, barr, bout);
1019             testVectorRebracket(lspec512, dspec512, barr, bout);
1020 
1021             testVectorRebracket(fspec512, bspec512, barr, bout);
1022             testVectorRebracket(fspec512, sspec512, barr, bout);
1023             testVectorRebracket(fspec512, ispec512, barr, bout);
1024             testVectorRebracket(fspec512, lspec512, barr, bout);
1025             testVectorRebracket(fspec512, fspec512, barr, bout);
1026             testVectorRebracket(fspec512, dspec512, barr, bout);
1027 
1028             testVectorRebracket(dspec512, bspec512, barr, bout);
1029             testVectorRebracket(dspec512, sspec512, barr, bout);
1030             testVectorRebracket(dspec512, ispec512, barr, bout);
1031             testVectorRebracket(dspec512, lspec512, barr, bout);
1032             testVectorRebracket(dspec512, fspec512, barr, bout);
1033             testVectorRebracket(dspec512, dspec512, barr, bout);
1034         }
1035     }
1036 
1037     @Test(dataProvider = "byteUnaryOpProvider")
1038     static void testRebracketMax(IntFunction<byte[]> fa) {
1039         byte[] barr = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
1040         byte[] bout = new byte[barr.length];
1041         for (int i = 0; i < NUM_ITER; i++) {
1042             testVectorRebracket(bspecMax, bspecMax, barr, bout);
1043             testVectorRebracket(bspecMax, sspecMax, barr, bout);
1044             testVectorRebracket(bspecMax, ispecMax, barr, bout);
1045             testVectorRebracket(bspecMax, lspecMax, barr, bout);
1046             testVectorRebracket(bspecMax, fspecMax, barr, bout);
1047             testVectorRebracket(bspecMax, dspecMax, barr, bout);
1048 
1049             testVectorRebracket(sspecMax, bspecMax, barr, bout);
1050             testVectorRebracket(sspecMax, sspecMax, barr, bout);
1051             testVectorRebracket(sspecMax, ispecMax, barr, bout);
1052             testVectorRebracket(sspecMax, lspecMax, barr, bout);
1053             testVectorRebracket(sspecMax, fspecMax, barr, bout);
1054             testVectorRebracket(sspecMax, dspecMax, barr, bout);
1055 
1056             testVectorRebracket(ispecMax, bspecMax, barr, bout);
1057             testVectorRebracket(ispecMax, sspecMax, barr, bout);
1058             testVectorRebracket(ispecMax, ispecMax, barr, bout);
1059             testVectorRebracket(ispecMax, lspecMax, barr, bout);
1060             testVectorRebracket(ispecMax, fspecMax, barr, bout);
1061             testVectorRebracket(ispecMax, dspecMax, barr, bout);
1062 
1063             testVectorRebracket(lspecMax, bspecMax, barr, bout);
1064             testVectorRebracket(lspecMax, sspecMax, barr, bout);
1065             testVectorRebracket(lspecMax, ispecMax, barr, bout);
1066             testVectorRebracket(lspecMax, lspecMax, barr, bout);
1067             testVectorRebracket(lspecMax, fspecMax, barr, bout);
1068             testVectorRebracket(lspecMax, dspecMax, barr, bout);
1069 
1070             testVectorRebracket(fspecMax, bspecMax, barr, bout);
1071             testVectorRebracket(fspecMax, sspecMax, barr, bout);
1072             testVectorRebracket(fspecMax, ispecMax, barr, bout);
1073             testVectorRebracket(fspecMax, lspecMax, barr, bout);
1074             testVectorRebracket(fspecMax, fspecMax, barr, bout);
1075             testVectorRebracket(fspecMax, dspecMax, barr, bout);
1076 
1077             testVectorRebracket(dspecMax, bspecMax, barr, bout);
1078             testVectorRebracket(dspecMax, sspecMax, barr, bout);
1079             testVectorRebracket(dspecMax, ispecMax, barr, bout);
1080             testVectorRebracket(dspecMax, lspecMax, barr, bout);
1081             testVectorRebracket(dspecMax, fspecMax, barr, bout);
1082             testVectorRebracket(dspecMax, dspecMax, barr, bout);
1083         }
1084     }
1085 
1086     @ForceInline
1087     static
1088     void testVectorCastByteToFloat(VectorSpecies<Byte> a, VectorSpecies<Float> b, byte[] input, float[] output) {
1089         assert(input.length == a.length());
1090         assert(output.length == b.length());
1091 
1092         ByteVector av = ByteVector.fromArray(a, input, 0);
1093         FloatVector bv = (FloatVector) av.castShape(b, 0);
1094         bv.intoArray(output, 0);
1095 
1096         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1097             Assert.assertEquals(output[i], (float)input[i]);
1098         }
1099         for(int i = input.length; i < output.length; i++) {
1100             Assert.assertEquals(output[i], (float)0);
1101         }
1102     }
1103 
1104     @ForceInline
1105     static
1106     void testVectorCastByteToFloatFail(VectorSpecies<Byte> a, VectorSpecies<Float> b, byte[] input) {
1107         assert(input.length == a.length());
1108 
1109         ByteVector av = ByteVector.fromArray(a, input, 0);
1110         try {
1111             av.castShape(b, 0);
1112             Assert.fail(String.format(
1113                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1114                     a, b));
1115         } catch (ClassCastException e) {
1116         }
1117     }
1118 
1119     @ForceInline
1120     static
1121     void testVectorCastShortToFloat(VectorSpecies<Short> a, VectorSpecies<Float> b, short[] input, float[] output) {
1122         assert(input.length == a.length());
1123         assert(output.length == b.length());
1124 
1125         ShortVector av = ShortVector.fromArray(a, input, 0);
1126         FloatVector bv = (FloatVector) av.castShape(b, 0);
1127         bv.intoArray(output, 0);
1128 
1129         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1130             Assert.assertEquals(output[i], (float)input[i]);
1131         }
1132         for(int i = input.length; i < output.length; i++) {
1133             Assert.assertEquals(output[i], (float)0);
1134         }
1135     }
1136 
1137     @ForceInline
1138     static
1139     void testVectorCastShortToFloatFail(VectorSpecies<Short> a, VectorSpecies<Float> b, short[] input) {
1140         assert(input.length == a.length());
1141 
1142         ShortVector av = ShortVector.fromArray(a, input, 0);
1143         try {
1144             av.castShape(b, 0);
1145             Assert.fail(String.format(
1146                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1147                     a, b));
1148         } catch (ClassCastException e) {
1149         }
1150     }
1151 
1152     @ForceInline
1153     static
1154     void testVectorCastIntToFloat(VectorSpecies<Integer> a, VectorSpecies<Float> b, int[] input, float[] output) {
1155         assert(input.length == a.length());
1156         assert(output.length == b.length());
1157 
1158         IntVector av = IntVector.fromArray(a, input, 0);
1159         FloatVector bv = (FloatVector) av.castShape(b, 0);
1160         bv.intoArray(output, 0);
1161 
1162         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1163             Assert.assertEquals(output[i], (float)input[i]);
1164         }
1165         for(int i = input.length; i < output.length; i++) {
1166             Assert.assertEquals(output[i], (float)0);
1167         }
1168     }
1169 
1170     @ForceInline
1171     static
1172     void testVectorCastIntToFloatFail(VectorSpecies<Integer> a, VectorSpecies<Float> b, int[] input) {
1173         assert(input.length == a.length());
1174 
1175         IntVector av = IntVector.fromArray(a, input, 0);
1176         try {
1177             av.castShape(b, 0);
1178             Assert.fail(String.format(
1179                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1180                     a, b));
1181         } catch (ClassCastException e) {
1182         }
1183     }
1184 
1185     @ForceInline
1186     static
1187     void testVectorCastLongToFloat(VectorSpecies<Long> a, VectorSpecies<Float> b, long[] input, float[] output) {
1188         assert(input.length == a.length());
1189         assert(output.length == b.length());
1190 
1191         LongVector av = LongVector.fromArray(a, input, 0);
1192         FloatVector bv = (FloatVector) av.castShape(b, 0);
1193         bv.intoArray(output, 0);
1194 
1195         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1196             Assert.assertEquals(output[i], (float)input[i]);
1197         }
1198         for(int i = input.length; i < output.length; i++) {
1199             Assert.assertEquals(output[i], (float)0);
1200         }
1201     }
1202 
1203     @ForceInline
1204     static
1205     void testVectorCastLongToFloatFail(VectorSpecies<Long> a, VectorSpecies<Float> b, long[] input) {
1206         assert(input.length == a.length());
1207 
1208         LongVector av = LongVector.fromArray(a, input, 0);
1209         try {
1210             av.castShape(b, 0);
1211             Assert.fail(String.format(
1212                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1213                     a, b));
1214         } catch (ClassCastException e) {
1215         }
1216     }
1217 
1218     @ForceInline
1219     static
1220     void testVectorCastFloatToFloat(VectorSpecies<Float> a, VectorSpecies<Float> b, float[] input, float[] output) {
1221         assert(input.length == a.length());
1222         assert(output.length == b.length());
1223 
1224         FloatVector av = FloatVector.fromArray(a, input, 0);
1225         FloatVector bv = (FloatVector) av.castShape(b, 0);
1226         bv.intoArray(output, 0);
1227 
1228         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1229             Assert.assertEquals(output[i], (float)input[i]);
1230         }
1231         for(int i = input.length; i < output.length; i++) {
1232             Assert.assertEquals(output[i], (float)0);
1233         }
1234     }
1235 
1236     @ForceInline
1237     static
1238     void testVectorCastFloatToFloatFail(VectorSpecies<Float> a, VectorSpecies<Float> b, float[] input) {
1239         assert(input.length == a.length());
1240 
1241         FloatVector av = FloatVector.fromArray(a, input, 0);
1242         try {
1243             av.castShape(b, 0);
1244             Assert.fail(String.format(
1245                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1246                     a, b));
1247         } catch (ClassCastException e) {
1248         }
1249     }
1250 
1251     @ForceInline
1252     static
1253     void testVectorCastDoubleToFloat(VectorSpecies<Double> a, VectorSpecies<Float> b, double[] input, float[] output) {
1254         assert(input.length == a.length());
1255         assert(output.length == b.length());
1256 
1257         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1258         FloatVector bv = (FloatVector) av.castShape(b, 0);
1259         bv.intoArray(output, 0);
1260 
1261         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1262             Assert.assertEquals(output[i], (float)input[i]);
1263         }
1264         for(int i = input.length; i < output.length; i++) {
1265             Assert.assertEquals(output[i], (float)0);
1266         }
1267     }
1268 
1269     @ForceInline
1270     static
1271     void testVectorCastDoubleToFloatFail(VectorSpecies<Double> a, VectorSpecies<Float> b, double[] input) {
1272         assert(input.length == a.length());
1273 
1274         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1275         try {
1276             av.castShape(b, 0);
1277             Assert.fail(String.format(
1278                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1279                     a, b));
1280         } catch (ClassCastException e) {
1281         }
1282     }
1283 
1284     @ForceInline
1285     static
1286     void testVectorCastByteToByte(VectorSpecies<Byte> a, VectorSpecies<Byte> b, byte[] input, byte[] output) {
1287         assert(input.length == a.length());
1288         assert(output.length == b.length());
1289 
1290         ByteVector av = ByteVector.fromArray(a, input, 0);
1291         ByteVector bv = (ByteVector) av.castShape(b, 0);
1292         bv.intoArray(output, 0);
1293 
1294         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1295             Assert.assertEquals(output[i], (byte)input[i]);
1296         }
1297         for(int i = input.length; i < output.length; i++) {
1298             Assert.assertEquals(output[i], (byte)0);
1299         }
1300     }
1301 
1302     @ForceInline
1303     static
1304     void testVectorCastByteToByteFail(VectorSpecies<Byte> a, VectorSpecies<Byte> b, byte[] input) {
1305         assert(input.length == a.length());
1306 
1307         ByteVector av = ByteVector.fromArray(a, input, 0);
1308         try {
1309             av.castShape(b, 0);
1310             Assert.fail(String.format(
1311                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1312                     a, b));
1313         } catch (ClassCastException e) {
1314         }
1315     }
1316 
1317     @ForceInline
1318     static
1319     void testVectorCastShortToByte(VectorSpecies<Short> a, VectorSpecies<Byte> b, short[] input, byte[] output) {
1320         assert(input.length == a.length());
1321         assert(output.length == b.length());
1322 
1323         ShortVector av = ShortVector.fromArray(a, input, 0);
1324         ByteVector bv = (ByteVector) av.castShape(b, 0);
1325         bv.intoArray(output, 0);
1326 
1327         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1328             Assert.assertEquals(output[i], (byte)input[i]);
1329         }
1330         for(int i = input.length; i < output.length; i++) {
1331             Assert.assertEquals(output[i], (byte)0);
1332         }
1333     }
1334 
1335     @ForceInline
1336     static
1337     void testVectorCastShortToByteFail(VectorSpecies<Short> a, VectorSpecies<Byte> b, short[] input) {
1338         assert(input.length == a.length());
1339 
1340         ShortVector av = ShortVector.fromArray(a, input, 0);
1341         try {
1342             av.castShape(b, 0);
1343             Assert.fail(String.format(
1344                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1345                     a, b));
1346         } catch (ClassCastException e) {
1347         }
1348     }
1349 
1350     @ForceInline
1351     static
1352     void testVectorCastIntToByte(VectorSpecies<Integer> a, VectorSpecies<Byte> b, int[] input, byte[] output) {
1353         assert(input.length == a.length());
1354         assert(output.length == b.length());
1355 
1356         IntVector av = IntVector.fromArray(a, input, 0);
1357         ByteVector bv = (ByteVector) av.castShape(b, 0);
1358         bv.intoArray(output, 0);
1359 
1360         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1361             Assert.assertEquals(output[i], (byte)input[i]);
1362         }
1363         for(int i = input.length; i < output.length; i++) {
1364             Assert.assertEquals(output[i], (byte)0);
1365         }
1366     }
1367 
1368     @ForceInline
1369     static
1370     void testVectorCastIntToByteFail(VectorSpecies<Integer> a, VectorSpecies<Byte> b, int[] input) {
1371         assert(input.length == a.length());
1372 
1373         IntVector av = IntVector.fromArray(a, input, 0);
1374         try {
1375             av.castShape(b, 0);
1376             Assert.fail(String.format(
1377                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1378                     a, b));
1379         } catch (ClassCastException e) {
1380         }
1381     }
1382 
1383     @ForceInline
1384     static
1385     void testVectorCastLongToByte(VectorSpecies<Long> a, VectorSpecies<Byte> b, long[] input, byte[] output) {
1386         assert(input.length == a.length());
1387         assert(output.length == b.length());
1388 
1389         LongVector av = LongVector.fromArray(a, input, 0);
1390         ByteVector bv = (ByteVector) av.castShape(b, 0);
1391         bv.intoArray(output, 0);
1392 
1393         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1394             Assert.assertEquals(output[i], (byte)input[i]);
1395         }
1396         for(int i = input.length; i < output.length; i++) {
1397             Assert.assertEquals(output[i], (byte)0);
1398         }
1399     }
1400 
1401     @ForceInline
1402     static
1403     void testVectorCastLongToByteFail(VectorSpecies<Long> a, VectorSpecies<Byte> b, long[] input) {
1404         assert(input.length == a.length());
1405 
1406         LongVector av = LongVector.fromArray(a, input, 0);
1407         try {
1408             av.castShape(b, 0);
1409             Assert.fail(String.format(
1410                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1411                     a, b));
1412         } catch (ClassCastException e) {
1413         }
1414     }
1415 
1416     @ForceInline
1417     static
1418     void testVectorCastFloatToByte(VectorSpecies<Float> a, VectorSpecies<Byte> b, float[] input, byte[] output) {
1419         assert(input.length == a.length());
1420         assert(output.length == b.length());
1421 
1422         FloatVector av = FloatVector.fromArray(a, input, 0);
1423         ByteVector bv = (ByteVector) av.castShape(b, 0);
1424         bv.intoArray(output, 0);
1425 
1426         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1427             Assert.assertEquals(output[i], (byte)input[i]);
1428         }
1429         for(int i = input.length; i < output.length; i++) {
1430             Assert.assertEquals(output[i], (byte)0);
1431         }
1432     }
1433 
1434     @ForceInline
1435     static
1436     void testVectorCastFloatToByteFail(VectorSpecies<Float> a, VectorSpecies<Byte> b, float[] input) {
1437         assert(input.length == a.length());
1438 
1439         FloatVector av = FloatVector.fromArray(a, input, 0);
1440         try {
1441             av.castShape(b, 0);
1442             Assert.fail(String.format(
1443                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1444                     a, b));
1445         } catch (ClassCastException e) {
1446         }
1447     }
1448 
1449     @ForceInline
1450     static
1451     void testVectorCastDoubleToByte(VectorSpecies<Double> a, VectorSpecies<Byte> b, double[] input, byte[] output) {
1452         assert(input.length == a.length());
1453         assert(output.length == b.length());
1454 
1455         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1456         ByteVector bv = (ByteVector) av.castShape(b, 0);
1457         bv.intoArray(output, 0);
1458 
1459         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1460             Assert.assertEquals(output[i], (byte)input[i]);
1461         }
1462         for(int i = input.length; i < output.length; i++) {
1463             Assert.assertEquals(output[i], (byte)0);
1464         }
1465     }
1466 
1467     @ForceInline
1468     static
1469     void testVectorCastDoubleToByteFail(VectorSpecies<Double> a, VectorSpecies<Byte> b, double[] input) {
1470         assert(input.length == a.length());
1471 
1472         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1473         try {
1474             av.castShape(b, 0);
1475             Assert.fail(String.format(
1476                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1477                     a, b));
1478         } catch (ClassCastException e) {
1479         }
1480     }
1481 
1482     @ForceInline
1483     static
1484     void testVectorCastByteToShort(VectorSpecies<Byte> a, VectorSpecies<Short> b, byte[] input, short[] output) {
1485         assert(input.length == a.length());
1486         assert(output.length == b.length());
1487 
1488         ByteVector av = ByteVector.fromArray(a, input, 0);
1489         ShortVector bv = (ShortVector) av.castShape(b, 0);
1490         bv.intoArray(output, 0);
1491 
1492         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1493             Assert.assertEquals(output[i], (short)input[i]);
1494         }
1495         for(int i = input.length; i < output.length; i++) {
1496             Assert.assertEquals(output[i], (short)0);
1497         }
1498     }
1499 
1500     @ForceInline
1501     static
1502     void testVectorCastByteToShortFail(VectorSpecies<Byte> a, VectorSpecies<Short> b, byte[] input) {
1503         assert(input.length == a.length());
1504 
1505         ByteVector av = ByteVector.fromArray(a, input, 0);
1506         try {
1507             av.castShape(b, 0);
1508             Assert.fail(String.format(
1509                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1510                     a, b));
1511         } catch (ClassCastException e) {
1512         }
1513     }
1514 
1515     @ForceInline
1516     static
1517     void testVectorCastShortToShort(VectorSpecies<Short> a, VectorSpecies<Short> b, short[] input, short[] output) {
1518         assert(input.length == a.length());
1519         assert(output.length == b.length());
1520 
1521         ShortVector av = ShortVector.fromArray(a, input, 0);
1522         ShortVector bv = (ShortVector) av.castShape(b, 0);
1523         bv.intoArray(output, 0);
1524 
1525         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1526             Assert.assertEquals(output[i], (short)input[i]);
1527         }
1528         for(int i = input.length; i < output.length; i++) {
1529             Assert.assertEquals(output[i], (short)0);
1530         }
1531     }
1532 
1533     @ForceInline
1534     static
1535     void testVectorCastShortToShortFail(VectorSpecies<Short> a, VectorSpecies<Short> b, short[] input) {
1536         assert(input.length == a.length());
1537 
1538         ShortVector av = ShortVector.fromArray(a, input, 0);
1539         try {
1540             av.castShape(b, 0);
1541             Assert.fail(String.format(
1542                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1543                     a, b));
1544         } catch (ClassCastException e) {
1545         }
1546     }
1547 
1548     @ForceInline
1549     static
1550     void testVectorCastIntToShort(VectorSpecies<Integer> a, VectorSpecies<Short> b, int[] input, short[] output) {
1551         assert(input.length == a.length());
1552         assert(output.length == b.length());
1553 
1554         IntVector av = IntVector.fromArray(a, input, 0);
1555         ShortVector bv = (ShortVector) av.castShape(b, 0);
1556         bv.intoArray(output, 0);
1557 
1558         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1559             Assert.assertEquals(output[i], (short)input[i]);
1560         }
1561         for(int i = input.length; i < output.length; i++) {
1562             Assert.assertEquals(output[i], (short)0);
1563         }
1564     }
1565 
1566     @ForceInline
1567     static
1568     void testVectorCastIntToShortFail(VectorSpecies<Integer> a, VectorSpecies<Short> b, int[] input) {
1569         assert(input.length == a.length());
1570 
1571         IntVector av = IntVector.fromArray(a, input, 0);
1572         try {
1573             av.castShape(b, 0);
1574             Assert.fail(String.format(
1575                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1576                     a, b));
1577         } catch (ClassCastException e) {
1578         }
1579     }
1580 
1581     @ForceInline
1582     static
1583     void testVectorCastLongToShort(VectorSpecies<Long> a, VectorSpecies<Short> b, long[] input, short[] output) {
1584         assert(input.length == a.length());
1585         assert(output.length == b.length());
1586 
1587         LongVector av = LongVector.fromArray(a, input, 0);
1588         ShortVector bv = (ShortVector) av.castShape(b, 0);
1589         bv.intoArray(output, 0);
1590 
1591         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1592             Assert.assertEquals(output[i], (short)input[i]);
1593         }
1594         for(int i = input.length; i < output.length; i++) {
1595             Assert.assertEquals(output[i], (short)0);
1596         }
1597     }
1598 
1599     @ForceInline
1600     static
1601     void testVectorCastLongToShortFail(VectorSpecies<Long> a, VectorSpecies<Short> b, long[] input) {
1602         assert(input.length == a.length());
1603 
1604         LongVector av = LongVector.fromArray(a, input, 0);
1605         try {
1606             av.castShape(b, 0);
1607             Assert.fail(String.format(
1608                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1609                     a, b));
1610         } catch (ClassCastException e) {
1611         }
1612     }
1613 
1614     @ForceInline
1615     static
1616     void testVectorCastFloatToShort(VectorSpecies<Float> a, VectorSpecies<Short> b, float[] input, short[] output) {
1617         assert(input.length == a.length());
1618         assert(output.length == b.length());
1619 
1620         FloatVector av = FloatVector.fromArray(a, input, 0);
1621         ShortVector bv = (ShortVector) av.castShape(b, 0);
1622         bv.intoArray(output, 0);
1623 
1624         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1625             Assert.assertEquals(output[i], (short)input[i]);
1626         }
1627         for(int i = input.length; i < output.length; i++) {
1628             Assert.assertEquals(output[i], (short)0);
1629         }
1630     }
1631 
1632     @ForceInline
1633     static
1634     void testVectorCastFloatToShortFail(VectorSpecies<Float> a, VectorSpecies<Short> b, float[] input) {
1635         assert(input.length == a.length());
1636 
1637         FloatVector av = FloatVector.fromArray(a, input, 0);
1638         try {
1639             av.castShape(b, 0);
1640             Assert.fail(String.format(
1641                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1642                     a, b));
1643         } catch (ClassCastException e) {
1644         }
1645     }
1646 
1647     @ForceInline
1648     static
1649     void testVectorCastDoubleToShort(VectorSpecies<Double> a, VectorSpecies<Short> b, double[] input, short[] output) {
1650         assert(input.length == a.length());
1651         assert(output.length == b.length());
1652 
1653         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1654         ShortVector bv = (ShortVector) av.castShape(b, 0);
1655         bv.intoArray(output, 0);
1656 
1657         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1658             Assert.assertEquals(output[i], (short)input[i]);
1659         }
1660         for(int i = input.length; i < output.length; i++) {
1661             Assert.assertEquals(output[i], (short)0);
1662         }
1663     }
1664 
1665     @ForceInline
1666     static
1667     void testVectorCastDoubleToShortFail(VectorSpecies<Double> a, VectorSpecies<Short> b, double[] input) {
1668         assert(input.length == a.length());
1669 
1670         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1671         try {
1672             av.castShape(b, 0);
1673             Assert.fail(String.format(
1674                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1675                     a, b));
1676         } catch (ClassCastException e) {
1677         }
1678     }
1679 
1680     @ForceInline
1681     static
1682     void testVectorCastByteToInt(VectorSpecies<Byte> a, VectorSpecies<Integer> b, byte[] input, int[] output) {
1683         assert(input.length == a.length());
1684         assert(output.length == b.length());
1685 
1686         ByteVector av = ByteVector.fromArray(a, input, 0);
1687         IntVector bv = (IntVector) av.castShape(b, 0);
1688         bv.intoArray(output, 0);
1689 
1690         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1691             Assert.assertEquals(output[i], (int)input[i]);
1692         }
1693         for(int i = input.length; i < output.length; i++) {
1694             Assert.assertEquals(output[i], (int)0);
1695         }
1696     }
1697 
1698     @ForceInline
1699     static
1700     void testVectorCastByteToIntFail(VectorSpecies<Byte> a, VectorSpecies<Integer> b, byte[] input) {
1701         assert(input.length == a.length());
1702 
1703         ByteVector av = ByteVector.fromArray(a, input, 0);
1704         try {
1705             av.castShape(b, 0);
1706             Assert.fail(String.format(
1707                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1708                     a, b));
1709         } catch (ClassCastException e) {
1710         }
1711     }
1712 
1713     @ForceInline
1714     static
1715     void testVectorCastShortToInt(VectorSpecies<Short> a, VectorSpecies<Integer> b, short[] input, int[] output) {
1716         assert(input.length == a.length());
1717         assert(output.length == b.length());
1718 
1719         ShortVector av = ShortVector.fromArray(a, input, 0);
1720         IntVector bv = (IntVector) av.castShape(b, 0);
1721         bv.intoArray(output, 0);
1722 
1723         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1724             Assert.assertEquals(output[i], (int)input[i]);
1725         }
1726         for(int i = input.length; i < output.length; i++) {
1727             Assert.assertEquals(output[i], (int)0);
1728         }
1729     }
1730 
1731     @ForceInline
1732     static
1733     void testVectorCastShortToIntFail(VectorSpecies<Short> a, VectorSpecies<Integer> b, short[] input) {
1734         assert(input.length == a.length());
1735 
1736         ShortVector av = ShortVector.fromArray(a, input, 0);
1737         try {
1738             av.castShape(b, 0);
1739             Assert.fail(String.format(
1740                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1741                     a, b));
1742         } catch (ClassCastException e) {
1743         }
1744     }
1745 
1746     @ForceInline
1747     static
1748     void testVectorCastIntToInt(VectorSpecies<Integer> a, VectorSpecies<Integer> b, int[] input, int[] output) {
1749         assert(input.length == a.length());
1750         assert(output.length == b.length());
1751 
1752         IntVector av = IntVector.fromArray(a, input, 0);
1753         IntVector bv = (IntVector) av.castShape(b, 0);
1754         bv.intoArray(output, 0);
1755 
1756         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1757             Assert.assertEquals(output[i], (int)input[i]);
1758         }
1759         for(int i = input.length; i < output.length; i++) {
1760             Assert.assertEquals(output[i], (int)0);
1761         }
1762     }
1763 
1764     @ForceInline
1765     static
1766     void testVectorCastIntToIntFail(VectorSpecies<Integer> a, VectorSpecies<Integer> b, int[] input) {
1767         assert(input.length == a.length());
1768 
1769         IntVector av = IntVector.fromArray(a, input, 0);
1770         try {
1771             av.castShape(b, 0);
1772             Assert.fail(String.format(
1773                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1774                     a, b));
1775         } catch (ClassCastException e) {
1776         }
1777     }
1778 
1779     @ForceInline
1780     static
1781     void testVectorCastLongToInt(VectorSpecies<Long> a, VectorSpecies<Integer> b, long[] input, int[] output) {
1782         assert(input.length == a.length());
1783         assert(output.length == b.length());
1784 
1785         LongVector av = LongVector.fromArray(a, input, 0);
1786         IntVector bv = (IntVector) av.castShape(b, 0);
1787         bv.intoArray(output, 0);
1788 
1789         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1790             Assert.assertEquals(output[i], (int)input[i]);
1791         }
1792         for(int i = input.length; i < output.length; i++) {
1793             Assert.assertEquals(output[i], (int)0);
1794         }
1795     }
1796 
1797     @ForceInline
1798     static
1799     void testVectorCastLongToIntFail(VectorSpecies<Long> a, VectorSpecies<Integer> b, long[] input) {
1800         assert(input.length == a.length());
1801 
1802         LongVector av = LongVector.fromArray(a, input, 0);
1803         try {
1804             av.castShape(b, 0);
1805             Assert.fail(String.format(
1806                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1807                     a, b));
1808         } catch (ClassCastException e) {
1809         }
1810     }
1811 
1812     @ForceInline
1813     static
1814     void testVectorCastFloatToInt(VectorSpecies<Float> a, VectorSpecies<Integer> b, float[] input, int[] output) {
1815         assert(input.length == a.length());
1816         assert(output.length == b.length());
1817 
1818         FloatVector av = FloatVector.fromArray(a, input, 0);
1819         IntVector bv = (IntVector) av.castShape(b, 0);
1820         bv.intoArray(output, 0);
1821 
1822         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1823             Assert.assertEquals(output[i], (int)input[i]);
1824         }
1825         for(int i = input.length; i < output.length; i++) {
1826             Assert.assertEquals(output[i], (int)0);
1827         }
1828     }
1829 
1830     @ForceInline
1831     static
1832     void testVectorCastFloatToIntFail(VectorSpecies<Float> a, VectorSpecies<Integer> b, float[] input) {
1833         assert(input.length == a.length());
1834 
1835         FloatVector av = FloatVector.fromArray(a, input, 0);
1836         try {
1837             av.castShape(b, 0);
1838             Assert.fail(String.format(
1839                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1840                     a, b));
1841         } catch (ClassCastException e) {
1842         }
1843     }
1844 
1845     @ForceInline
1846     static
1847     void testVectorCastDoubleToInt(VectorSpecies<Double> a, VectorSpecies<Integer> b, double[] input, int[] output) {
1848         assert(input.length == a.length());
1849         assert(output.length == b.length());
1850 
1851         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1852         IntVector bv = (IntVector) av.castShape(b, 0);
1853         bv.intoArray(output, 0);
1854 
1855         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1856             Assert.assertEquals(output[i], (int)input[i]);
1857         }
1858         for(int i = input.length; i < output.length; i++) {
1859             Assert.assertEquals(output[i], (int)0);
1860         }
1861     }
1862 
1863     @ForceInline
1864     static
1865     void testVectorCastDoubleToIntFail(VectorSpecies<Double> a, VectorSpecies<Integer> b, double[] input) {
1866         assert(input.length == a.length());
1867 
1868         DoubleVector av = DoubleVector.fromArray(a, input, 0);
1869         try {
1870             av.castShape(b, 0);
1871             Assert.fail(String.format(
1872                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1873                     a, b));
1874         } catch (ClassCastException e) {
1875         }
1876     }
1877 
1878     @ForceInline
1879     static
1880     void testVectorCastByteToLong(VectorSpecies<Byte> a, VectorSpecies<Long> b, byte[] input, long[] output) {
1881         assert(input.length == a.length());
1882         assert(output.length == b.length());
1883 
1884         ByteVector av = ByteVector.fromArray(a, input, 0);
1885         LongVector bv = (LongVector) av.castShape(b, 0);
1886         bv.intoArray(output, 0);
1887 
1888         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1889             Assert.assertEquals(output[i], (long)input[i]);
1890         }
1891         for(int i = input.length; i < output.length; i++) {
1892             Assert.assertEquals(output[i], (long)0);
1893         }
1894     }
1895 
1896     @ForceInline
1897     static
1898     void testVectorCastByteToLongFail(VectorSpecies<Byte> a, VectorSpecies<Long> b, byte[] input) {
1899         assert(input.length == a.length());
1900 
1901         ByteVector av = ByteVector.fromArray(a, input, 0);
1902         try {
1903             av.castShape(b, 0);
1904             Assert.fail(String.format(
1905                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1906                     a, b));
1907         } catch (ClassCastException e) {
1908         }
1909     }
1910 
1911     @ForceInline
1912     static
1913     void testVectorCastShortToLong(VectorSpecies<Short> a, VectorSpecies<Long> b, short[] input, long[] output) {
1914         assert(input.length == a.length());
1915         assert(output.length == b.length());
1916 
1917         ShortVector av = ShortVector.fromArray(a, input, 0);
1918         LongVector bv = (LongVector) av.castShape(b, 0);
1919         bv.intoArray(output, 0);
1920 
1921         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1922             Assert.assertEquals(output[i], (long)input[i]);
1923         }
1924         for(int i = input.length; i < output.length; i++) {
1925             Assert.assertEquals(output[i], (long)0);
1926         }
1927     }
1928 
1929     @ForceInline
1930     static
1931     void testVectorCastShortToLongFail(VectorSpecies<Short> a, VectorSpecies<Long> b, short[] input) {
1932         assert(input.length == a.length());
1933 
1934         ShortVector av = ShortVector.fromArray(a, input, 0);
1935         try {
1936             av.castShape(b, 0);
1937             Assert.fail(String.format(
1938                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1939                     a, b));
1940         } catch (ClassCastException e) {
1941         }
1942     }
1943 
1944     @ForceInline
1945     static
1946     void testVectorCastIntToLong(VectorSpecies<Integer> a, VectorSpecies<Long> b, int[] input, long[] output) {
1947         assert(input.length == a.length());
1948         assert(output.length == b.length());
1949 
1950         IntVector av = IntVector.fromArray(a, input, 0);
1951         LongVector bv = (LongVector) av.castShape(b, 0);
1952         bv.intoArray(output, 0);
1953 
1954         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1955             Assert.assertEquals(output[i], (long)input[i]);
1956         }
1957         for(int i = input.length; i < output.length; i++) {
1958             Assert.assertEquals(output[i], (long)0);
1959         }
1960     }
1961 
1962     @ForceInline
1963     static
1964     void testVectorCastIntToLongFail(VectorSpecies<Integer> a, VectorSpecies<Long> b, int[] input) {
1965         assert(input.length == a.length());
1966 
1967         IntVector av = IntVector.fromArray(a, input, 0);
1968         try {
1969             av.castShape(b, 0);
1970             Assert.fail(String.format(
1971                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
1972                     a, b));
1973         } catch (ClassCastException e) {
1974         }
1975     }
1976 
1977     @ForceInline
1978     static
1979     void testVectorCastLongToLong(VectorSpecies<Long> a, VectorSpecies<Long> b, long[] input, long[] output) {
1980         assert(input.length == a.length());
1981         assert(output.length == b.length());
1982 
1983         LongVector av = LongVector.fromArray(a, input, 0);
1984         LongVector bv = (LongVector) av.castShape(b, 0);
1985         bv.intoArray(output, 0);
1986 
1987         for (int i = 0; i < Math.min(input.length, output.length); i++) {
1988             Assert.assertEquals(output[i], (long)input[i]);
1989         }
1990         for(int i = input.length; i < output.length; i++) {
1991             Assert.assertEquals(output[i], (long)0);
1992         }
1993     }
1994 
1995     @ForceInline
1996     static
1997     void testVectorCastLongToLongFail(VectorSpecies<Long> a, VectorSpecies<Long> b, long[] input) {
1998         assert(input.length == a.length());
1999 
2000         LongVector av = LongVector.fromArray(a, input, 0);
2001         try {
2002             av.castShape(b, 0);
2003             Assert.fail(String.format(
2004                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2005                     a, b));
2006         } catch (ClassCastException e) {
2007         }
2008     }
2009 
2010     @ForceInline
2011     static
2012     void testVectorCastFloatToLong(VectorSpecies<Float> a, VectorSpecies<Long> b, float[] input, long[] output) {
2013         assert(input.length == a.length());
2014         assert(output.length == b.length());
2015 
2016         FloatVector av = FloatVector.fromArray(a, input, 0);
2017         LongVector bv = (LongVector) av.castShape(b, 0);
2018         bv.intoArray(output, 0);
2019 
2020         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2021             Assert.assertEquals(output[i], (long)input[i]);
2022         }
2023         for(int i = input.length; i < output.length; i++) {
2024             Assert.assertEquals(output[i], (long)0);
2025         }
2026     }
2027 
2028     @ForceInline
2029     static
2030     void testVectorCastFloatToLongFail(VectorSpecies<Float> a, VectorSpecies<Long> b, float[] input) {
2031         assert(input.length == a.length());
2032 
2033         FloatVector av = FloatVector.fromArray(a, input, 0);
2034         try {
2035             av.castShape(b, 0);
2036             Assert.fail(String.format(
2037                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2038                     a, b));
2039         } catch (ClassCastException e) {
2040         }
2041     }
2042 
2043     @ForceInline
2044     static
2045     void testVectorCastDoubleToLong(VectorSpecies<Double> a, VectorSpecies<Long> b, double[] input, long[] output) {
2046         assert(input.length == a.length());
2047         assert(output.length == b.length());
2048 
2049         DoubleVector av = DoubleVector.fromArray(a, input, 0);
2050         LongVector bv = (LongVector) av.castShape(b, 0);
2051         bv.intoArray(output, 0);
2052 
2053         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2054             Assert.assertEquals(output[i], (long)input[i]);
2055         }
2056         for(int i = input.length; i < output.length; i++) {
2057             Assert.assertEquals(output[i], (long)0);
2058         }
2059     }
2060 
2061     @ForceInline
2062     static
2063     void testVectorCastDoubleToLongFail(VectorSpecies<Double> a, VectorSpecies<Long> b, double[] input) {
2064         assert(input.length == a.length());
2065 
2066         DoubleVector av = DoubleVector.fromArray(a, input, 0);
2067         try {
2068             av.castShape(b, 0);
2069             Assert.fail(String.format(
2070                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2071                     a, b));
2072         } catch (ClassCastException e) {
2073         }
2074     }
2075 
2076     @ForceInline
2077     static
2078     void testVectorCastByteToDouble(VectorSpecies<Byte> a, VectorSpecies<Double> b, byte[] input, double[] output) {
2079         assert(input.length == a.length());
2080         assert(output.length == b.length());
2081 
2082         ByteVector av = ByteVector.fromArray(a, input, 0);
2083         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2084         bv.intoArray(output, 0);
2085 
2086         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2087             Assert.assertEquals(output[i], (double)input[i]);
2088         }
2089         for(int i = input.length; i < output.length; i++) {
2090             Assert.assertEquals(output[i], (double)0);
2091         }
2092     }
2093 
2094     @ForceInline
2095     static
2096     void testVectorCastByteToDoubleFail(VectorSpecies<Byte> a, VectorSpecies<Double> b, byte[] input) {
2097         assert(input.length == a.length());
2098 
2099         ByteVector av = ByteVector.fromArray(a, input, 0);
2100         try {
2101             av.castShape(b, 0);
2102             Assert.fail(String.format(
2103                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2104                     a, b));
2105         } catch (ClassCastException e) {
2106         }
2107     }
2108 
2109     @ForceInline
2110     static
2111     void testVectorCastShortToDouble(VectorSpecies<Short> a, VectorSpecies<Double> b, short[] input, double[] output) {
2112         assert(input.length == a.length());
2113         assert(output.length == b.length());
2114 
2115         ShortVector av = ShortVector.fromArray(a, input, 0);
2116         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2117         bv.intoArray(output, 0);
2118 
2119         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2120             Assert.assertEquals(output[i], (double)input[i]);
2121         }
2122         for(int i = input.length; i < output.length; i++) {
2123             Assert.assertEquals(output[i], (double)0);
2124         }
2125     }
2126 
2127     @ForceInline
2128     static
2129     void testVectorCastShortToDoubleFail(VectorSpecies<Short> a, VectorSpecies<Double> b, short[] input) {
2130         assert(input.length == a.length());
2131 
2132         ShortVector av = ShortVector.fromArray(a, input, 0);
2133         try {
2134             av.castShape(b, 0);
2135             Assert.fail(String.format(
2136                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2137                     a, b));
2138         } catch (ClassCastException e) {
2139         }
2140     }
2141 
2142     @ForceInline
2143     static
2144     void testVectorCastIntToDouble(VectorSpecies<Integer> a, VectorSpecies<Double> b, int[] input, double[] output) {
2145         assert(input.length == a.length());
2146         assert(output.length == b.length());
2147 
2148         IntVector av = IntVector.fromArray(a, input, 0);
2149         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2150         bv.intoArray(output, 0);
2151 
2152         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2153             Assert.assertEquals(output[i], (double)input[i]);
2154         }
2155         for(int i = input.length; i < output.length; i++) {
2156             Assert.assertEquals(output[i], (double)0);
2157         }
2158     }
2159 
2160     @ForceInline
2161     static
2162     void testVectorCastIntToDoubleFail(VectorSpecies<Integer> a, VectorSpecies<Double> b, int[] input) {
2163         assert(input.length == a.length());
2164 
2165         IntVector av = IntVector.fromArray(a, input, 0);
2166         try {
2167             av.castShape(b, 0);
2168             Assert.fail(String.format(
2169                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2170                     a, b));
2171         } catch (ClassCastException e) {
2172         }
2173     }
2174 
2175     @ForceInline
2176     static
2177     void testVectorCastLongToDouble(VectorSpecies<Long> a, VectorSpecies<Double> b, long[] input, double[] output) {
2178         assert(input.length == a.length());
2179         assert(output.length == b.length());
2180 
2181         LongVector av = LongVector.fromArray(a, input, 0);
2182         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2183         bv.intoArray(output, 0);
2184 
2185         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2186             Assert.assertEquals(output[i], (double)input[i]);
2187         }
2188         for(int i = input.length; i < output.length; i++) {
2189             Assert.assertEquals(output[i], (double)0);
2190         }
2191     }
2192 
2193     @ForceInline
2194     static
2195     void testVectorCastLongToDoubleFail(VectorSpecies<Long> a, VectorSpecies<Double> b, long[] input) {
2196         assert(input.length == a.length());
2197 
2198         LongVector av = LongVector.fromArray(a, input, 0);
2199         try {
2200             av.castShape(b, 0);
2201             Assert.fail(String.format(
2202                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2203                     a, b));
2204         } catch (ClassCastException e) {
2205         }
2206     }
2207 
2208     @ForceInline
2209     static
2210     void testVectorCastFloatToDouble(VectorSpecies<Float> a, VectorSpecies<Double> b, float[] input, double[] output) {
2211         assert(input.length == a.length());
2212         assert(output.length == b.length());
2213 
2214         FloatVector av = FloatVector.fromArray(a, input, 0);
2215         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2216         bv.intoArray(output, 0);
2217 
2218         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2219             Assert.assertEquals(output[i], (double)input[i]);
2220         }
2221         for(int i = input.length; i < output.length; i++) {
2222             Assert.assertEquals(output[i], (double)0);
2223         }
2224     }
2225 
2226     @ForceInline
2227     static
2228     void testVectorCastFloatToDoubleFail(VectorSpecies<Float> a, VectorSpecies<Double> b, float[] input) {
2229         assert(input.length == a.length());
2230 
2231         FloatVector av = FloatVector.fromArray(a, input, 0);
2232         try {
2233             av.castShape(b, 0);
2234             Assert.fail(String.format(
2235                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2236                     a, b));
2237         } catch (ClassCastException e) {
2238         }
2239     }
2240 
2241     @ForceInline
2242     static
2243     void testVectorCastDoubleToDouble(VectorSpecies<Double> a, VectorSpecies<Double> b, double[] input, double[] output) {
2244         assert(input.length == a.length());
2245         assert(output.length == b.length());
2246 
2247         DoubleVector av = DoubleVector.fromArray(a, input, 0);
2248         DoubleVector bv = (DoubleVector) av.castShape(b, 0);
2249         bv.intoArray(output, 0);
2250 
2251         for (int i = 0; i < Math.min(input.length, output.length); i++) {
2252             Assert.assertEquals(output[i], (double)input[i]);
2253         }
2254         for(int i = input.length; i < output.length; i++) {
2255             Assert.assertEquals(output[i], (double)0);
2256         }
2257     }
2258 
2259     @ForceInline
2260     static
2261     void testVectorCastDoubleToDoubleFail(VectorSpecies<Double> a, VectorSpecies<Double> b, double[] input) {
2262         assert(input.length == a.length());
2263 
2264         DoubleVector av = DoubleVector.fromArray(a, input, 0);
2265         try {
2266             av.castShape(b, 0);
2267             Assert.fail(String.format(
2268                     "Cast failed to throw ClassCastException for differing species lengths for %s and %s",
2269                     a, b));
2270         } catch (ClassCastException e) {
2271         }
2272     }
2273 
2274     @Test(dataProvider = "byteUnaryOpProvider")
2275     static void testCastFromByte(IntFunction<byte[]> fa) {
2276         byte[] bin64 = fa.apply(bspec64.length());
2277         byte[] bin128 = fa.apply(bspec128.length());
2278         byte[] bin256 = fa.apply(bspec256.length());
2279         byte[] bin512 = fa.apply(bspec512.length());
2280 
2281         byte[] bout64 = new byte[bspec64.length()];
2282         byte[] bout128 = new byte[bspec128.length()];
2283         byte[] bout256 = new byte[bspec256.length()];
2284         byte[] bout512 = new byte[bspec512.length()];
2285 
2286         short[] sout64 = new short[sspec64.length()];
2287         short[] sout128 = new short[sspec128.length()];
2288         short[] sout256 = new short[sspec256.length()];
2289         short[] sout512 = new short[sspec512.length()];
2290 
2291         int[] iout64 = new int[ispec64.length()];
2292         int[] iout128 = new int[ispec128.length()];
2293         int[] iout256 = new int[ispec256.length()];
2294         int[] iout512 = new int[ispec512.length()];
2295 
2296         long[] lout64 = new long[lspec64.length()];
2297         long[] lout128 = new long[lspec128.length()];
2298         long[] lout256 = new long[lspec256.length()];
2299         long[] lout512 = new long[lspec512.length()];
2300 
2301         float[] fout64 = new float[fspec64.length()];
2302         float[] fout128 = new float[fspec128.length()];
2303         float[] fout256 = new float[fspec256.length()];
2304         float[] fout512 = new float[fspec512.length()];
2305 
2306         double[] dout64 = new double[dspec64.length()];
2307         double[] dout128 = new double[dspec128.length()];
2308         double[] dout256 = new double[dspec256.length()];
2309         double[] dout512 = new double[dspec512.length()];
2310 
2311         for (int i = 0; i < NUM_ITER; i++) {
2312             // B2B exact fit
2313             testVectorCastByteToByte(bspec64, bspec64, bin64, bout64);
2314             testVectorCastByteToByte(bspec128, bspec128, bin128, bout128);
2315             testVectorCastByteToByte(bspec256, bspec256, bin256, bout256);
2316             testVectorCastByteToByte(bspec512, bspec512, bin512, bout512);
2317 
2318             // B2B expansion
2319             testVectorCastByteToByte(bspec128, bspec64, bin128, bout64);
2320             testVectorCastByteToByte(bspec256, bspec128, bin256, bout128);
2321             testVectorCastByteToByte(bspec512, bspec256, bin512, bout256);
2322 
2323             testVectorCastByteToByte(bspec256, bspec64, bin256, bout64);
2324             testVectorCastByteToByte(bspec512, bspec128, bin512, bout128);
2325 
2326             testVectorCastByteToByte(bspec512, bspec64, bin512, bout64);
2327 
2328             // B2B contraction
2329             testVectorCastByteToByte(bspec64, bspec128, bin64, bout128);
2330             testVectorCastByteToByte(bspec128, bspec256, bin128, bout256);
2331             testVectorCastByteToByte(bspec256, bspec512, bin256, bout512);
2332 
2333             testVectorCastByteToByte(bspec64, bspec256, bin64, bout256);
2334             testVectorCastByteToByte(bspec128, bspec512, bin128, bout512);
2335 
2336             testVectorCastByteToByte(bspec64, bspec512, bin64, bout512);
2337 
2338             // B2S exact fit
2339             testVectorCastByteToShort(bspec64, sspec128, bin64, sout128);
2340             testVectorCastByteToShort(bspec128, sspec256, bin128, sout256);
2341             testVectorCastByteToShort(bspec256, sspec512, bin256, sout512);
2342 
2343             // B2S expansion
2344             testVectorCastByteToShort(bspec64, sspec64, bin64, sout64);
2345             testVectorCastByteToShort(bspec128, sspec128, bin128, sout128);
2346             testVectorCastByteToShort(bspec256, sspec256, bin256, sout256);
2347             testVectorCastByteToShort(bspec512, sspec512, bin512, sout512);
2348 
2349             testVectorCastByteToShort(bspec128, sspec64, bin128, sout64);
2350             testVectorCastByteToShort(bspec256, sspec128, bin256, sout128);
2351             testVectorCastByteToShort(bspec512, sspec256, bin512, sout256);
2352 
2353             testVectorCastByteToShort(bspec256, sspec64, bin256, sout64);
2354             testVectorCastByteToShort(bspec512, sspec128, bin512, sout128);
2355 
2356             testVectorCastByteToShort(bspec512, sspec64, bin512, sout64);
2357 
2358             // B2S contraction
2359             testVectorCastByteToShort(bspec64, sspec256, bin64, sout256);
2360             testVectorCastByteToShort(bspec128, sspec512, bin128, sout512);
2361 
2362             testVectorCastByteToShort(bspec64, sspec512, bin64, sout512);
2363 
2364             // B2I exact fit
2365             testVectorCastByteToInt(bspec64, ispec256, bin64, iout256);
2366             testVectorCastByteToInt(bspec128, ispec512, bin128, iout512);
2367 
2368             // B2L exact fit
2369             testVectorCastByteToLong(bspec64, lspec512, bin64, lout512);
2370 
2371             // B2F exact fit
2372             testVectorCastByteToFloat(bspec64, fspec256, bin64, fout256);
2373             testVectorCastByteToFloat(bspec128, fspec512, bin128, fout512);
2374 
2375             // B2D exact fit
2376             testVectorCastByteToDouble(bspec64, dspec512, bin64, dout512);
2377 
2378             // Previous failure tests.
2379             testVectorCastByteToByte(bspec64, bspec128, bin64, bout128);
2380             testVectorCastByteToByte(bspec64, bspec256, bin64, bout256);
2381             testVectorCastByteToByte(bspec64, bspec512, bin64, bout512);
2382 
2383             testVectorCastByteToByte(bspec128, bspec64, bin128, bout64);
2384             testVectorCastByteToByte(bspec128, bspec256, bin128, bout256);
2385             testVectorCastByteToByte(bspec128, bspec512, bin128, bout512);
2386 
2387             testVectorCastByteToByte(bspec256, bspec64, bin256, bout64);
2388             testVectorCastByteToByte(bspec256, bspec128, bin256, bout128);
2389             testVectorCastByteToByte(bspec256, bspec512, bin256, bout512);
2390 
2391             testVectorCastByteToByte(bspec512, bspec64, bin512, bout64);
2392             testVectorCastByteToByte(bspec512, bspec128, bin512, bout128);
2393             testVectorCastByteToByte(bspec512, bspec256, bin512, bout256);
2394 
2395             testVectorCastByteToShort(bspec64, sspec64, bin64, sout64);
2396             testVectorCastByteToShort(bspec64, sspec256, bin64, sout256);
2397             testVectorCastByteToShort(bspec64, sspec512, bin64, sout512);
2398 
2399             testVectorCastByteToShort(bspec128, sspec64, bin128, sout64);
2400             testVectorCastByteToShort(bspec128, sspec128, bin128, sout128);
2401             testVectorCastByteToShort(bspec128, sspec512, bin128, sout512);
2402 
2403             testVectorCastByteToShort(bspec256, sspec64, bin256, sout64);
2404             testVectorCastByteToShort(bspec256, sspec128, bin256, sout128);
2405             testVectorCastByteToShort(bspec256, sspec256, bin256, sout256);
2406 
2407             testVectorCastByteToShort(bspec512, sspec64, bin512, sout64);
2408             testVectorCastByteToShort(bspec512, sspec128, bin512, sout128);
2409             testVectorCastByteToShort(bspec512, sspec256, bin512, sout256);
2410             testVectorCastByteToShort(bspec512, sspec512, bin512, sout512);
2411 
2412             testVectorCastByteToInt(bspec64, ispec64, bin64, iout64);
2413             testVectorCastByteToInt(bspec64, ispec128, bin64, iout128);
2414             testVectorCastByteToInt(bspec64, ispec512, bin64, iout512);
2415 
2416             testVectorCastByteToInt(bspec128, ispec64, bin128, iout64);
2417             testVectorCastByteToInt(bspec128, ispec128, bin128, iout128);
2418             testVectorCastByteToInt(bspec128, ispec256, bin128, iout256);
2419 
2420             testVectorCastByteToInt(bspec256, ispec64, bin256, iout64);
2421             testVectorCastByteToInt(bspec256, ispec128, bin256, iout128);
2422             testVectorCastByteToInt(bspec256, ispec256, bin256, iout256);
2423             testVectorCastByteToInt(bspec256, ispec512, bin256, iout512);
2424 
2425             testVectorCastByteToInt(bspec512, ispec64, bin512, iout64);
2426             testVectorCastByteToInt(bspec512, ispec128, bin512, iout128);
2427             testVectorCastByteToInt(bspec512, ispec256, bin512, iout256);
2428             testVectorCastByteToInt(bspec512, ispec512, bin512, iout512);
2429 
2430             testVectorCastByteToLong(bspec64, lspec64, bin64, lout64);
2431             testVectorCastByteToLong(bspec64, lspec128, bin64, lout128);
2432             testVectorCastByteToLong(bspec64, lspec256, bin64, lout256);
2433 
2434             testVectorCastByteToLong(bspec128, lspec64, bin128, lout64);
2435             testVectorCastByteToLong(bspec128, lspec128, bin128, lout128);
2436             testVectorCastByteToLong(bspec128, lspec256, bin128, lout256);
2437             testVectorCastByteToLong(bspec128, lspec512, bin128, lout512);
2438 
2439             testVectorCastByteToLong(bspec256, lspec64, bin256, lout64);
2440             testVectorCastByteToLong(bspec256, lspec128, bin256, lout128);
2441             testVectorCastByteToLong(bspec256, lspec256, bin256, lout256);
2442             testVectorCastByteToLong(bspec256, lspec512, bin256, lout512);
2443 
2444             testVectorCastByteToLong(bspec512, lspec64, bin512, lout64);
2445             testVectorCastByteToLong(bspec512, lspec128, bin512, lout128);
2446             testVectorCastByteToLong(bspec512, lspec256, bin512, lout256);
2447             testVectorCastByteToLong(bspec512, lspec512, bin512, lout512);
2448 
2449             testVectorCastByteToFloat(bspec64, fspec64, bin64, fout64);
2450             testVectorCastByteToFloat(bspec64, fspec128, bin64, fout128);
2451             testVectorCastByteToFloat(bspec64, fspec512, bin64, fout512);
2452 
2453             testVectorCastByteToFloat(bspec128, fspec64, bin128, fout64);
2454             testVectorCastByteToFloat(bspec128, fspec128, bin128, fout128);
2455             testVectorCastByteToFloat(bspec128, fspec256, bin128, fout256);
2456 
2457             testVectorCastByteToFloat(bspec256, fspec64, bin256, fout64);
2458             testVectorCastByteToFloat(bspec256, fspec128, bin256, fout128);
2459             testVectorCastByteToFloat(bspec256, fspec256, bin256, fout256);
2460             testVectorCastByteToFloat(bspec256, fspec512, bin256, fout512);
2461 
2462             testVectorCastByteToFloat(bspec512, fspec64, bin512, fout64);
2463             testVectorCastByteToFloat(bspec512, fspec128, bin512, fout128);
2464             testVectorCastByteToFloat(bspec512, fspec256, bin512, fout256);
2465             testVectorCastByteToFloat(bspec512, fspec512, bin512, fout512);
2466 
2467             testVectorCastByteToDouble(bspec64, dspec64, bin64, dout64);
2468             testVectorCastByteToDouble(bspec64, dspec128, bin64, dout128);
2469             testVectorCastByteToDouble(bspec64, dspec256, bin64, dout256);
2470 
2471             testVectorCastByteToDouble(bspec128, dspec64, bin128, dout64);
2472             testVectorCastByteToDouble(bspec128, dspec128, bin128, dout128);
2473             testVectorCastByteToDouble(bspec128, dspec256, bin128, dout256);
2474             testVectorCastByteToDouble(bspec128, dspec512, bin128, dout512);
2475 
2476             testVectorCastByteToDouble(bspec256, dspec64, bin256, dout64);
2477             testVectorCastByteToDouble(bspec256, dspec128, bin256, dout128);
2478             testVectorCastByteToDouble(bspec256, dspec256, bin256, dout256);
2479             testVectorCastByteToDouble(bspec256, dspec512, bin256, dout512);
2480 
2481             testVectorCastByteToDouble(bspec512, dspec64, bin512, dout64);
2482             testVectorCastByteToDouble(bspec512, dspec128, bin512, dout128);
2483             testVectorCastByteToDouble(bspec512, dspec256, bin512, dout256);
2484             testVectorCastByteToDouble(bspec512, dspec512, bin512, dout512);
2485         }
2486     }
2487 
2488     @Test(dataProvider = "shortUnaryOpProvider")
2489     static void testCastFromShort(IntFunction<short[]> fa) {
2490         short[] sin64 = fa.apply(sspec64.length());
2491         short[] sin128 = fa.apply(sspec128.length());
2492         short[] sin256 = fa.apply(sspec256.length());
2493         short[] sin512 = fa.apply(sspec512.length());
2494 
2495         byte[] bout64 = new byte[bspec64.length()];
2496         byte[] bout128 = new byte[bspec128.length()];
2497         byte[] bout256 = new byte[bspec256.length()];
2498 
2499         short[] sout64 = new short[sspec64.length()];
2500         short[] sout128 = new short[sspec128.length()];
2501         short[] sout256 = new short[sspec256.length()];
2502         short[] sout512 = new short[sspec512.length()];
2503 
2504         int[] iout128 = new int[ispec128.length()];
2505         int[] iout256 = new int[ispec256.length()];
2506         int[] iout512 = new int[ispec512.length()];
2507 
2508         long[] lout256 = new long[lspec256.length()];
2509         long[] lout512 = new long[lspec512.length()];
2510 
2511         float[] fout128 = new float[fspec128.length()];
2512         float[] fout256 = new float[fspec256.length()];
2513         float[] fout512 = new float[fspec512.length()];
2514 
2515         double[] dout256 = new double[dspec256.length()];
2516         double[] dout512 = new double[dspec512.length()];
2517 
2518         for (int i = 0; i < NUM_ITER; i++) {
2519             testVectorCastShortToByte(sspec128, bspec64, sin128, bout64);
2520             testVectorCastShortToByte(sspec256, bspec128, sin256, bout128);
2521             testVectorCastShortToByte(sspec512, bspec256, sin512, bout256);
2522 
2523             testVectorCastShortToShort(sspec64, sspec64, sin64, sout64);
2524             testVectorCastShortToShort(sspec128, sspec128, sin128, sout128);
2525             testVectorCastShortToShort(sspec256, sspec256, sin256, sout256);
2526             testVectorCastShortToShort(sspec512, sspec512, sin512, sout512);
2527 
2528             testVectorCastShortToInt(sspec64, ispec128, sin64, iout128);
2529             testVectorCastShortToInt(sspec128, ispec256, sin128, iout256);
2530             testVectorCastShortToInt(sspec256, ispec512, sin256, iout512);
2531 
2532             testVectorCastShortToLong(sspec64, lspec256, sin64, lout256);
2533             testVectorCastShortToLong(sspec128, lspec512, sin128, lout512);
2534 
2535             testVectorCastShortToFloat(sspec64, fspec128, sin64, fout128);
2536             testVectorCastShortToFloat(sspec128, fspec256, sin128, fout256);
2537             testVectorCastShortToFloat(sspec256, fspec512, sin256, fout512);
2538 
2539             testVectorCastShortToDouble(sspec64, dspec256, sin64, dout256);
2540             testVectorCastShortToDouble(sspec128, dspec512, sin128, dout512);
2541         }
2542     }
2543 
2544     //@Test()
2545     static void testCastFromShortFail() {
2546         short[] sin64 = new short[sspec64.length()];
2547         short[] sin128 = new short[sspec128.length()];
2548         short[] sin256 = new short[sspec256.length()];
2549         short[] sin512 = new short[sspec512.length()];
2550 
2551         for (int i = 0; i < INVOC_COUNT; i++) {
2552             testVectorCastShortToByteFail(sspec64, bspec64, sin64);
2553             testVectorCastShortToByteFail(sspec64, bspec128, sin64);
2554             testVectorCastShortToByteFail(sspec64, bspec256, sin64);
2555             testVectorCastShortToByteFail(sspec64, bspec512, sin64);
2556 
2557             testVectorCastShortToByteFail(sspec128, bspec128, sin128);
2558             testVectorCastShortToByteFail(sspec128, bspec256, sin128);
2559             testVectorCastShortToByteFail(sspec128, bspec512, sin128);
2560 
2561             testVectorCastShortToByteFail(sspec256, bspec64, sin256);
2562             testVectorCastShortToByteFail(sspec256, bspec256, sin256);
2563             testVectorCastShortToByteFail(sspec256, bspec512, sin256);
2564 
2565             testVectorCastShortToByteFail(sspec512, bspec64, sin512);
2566             testVectorCastShortToByteFail(sspec512, bspec128, sin512);
2567             testVectorCastShortToByteFail(sspec512, bspec512, sin512);
2568 
2569             testVectorCastShortToShortFail(sspec64, sspec128, sin64);
2570             testVectorCastShortToShortFail(sspec64, sspec256, sin64);
2571             testVectorCastShortToShortFail(sspec64, sspec512, sin64);
2572 
2573             testVectorCastShortToShortFail(sspec128, sspec64, sin128);
2574             testVectorCastShortToShortFail(sspec128, sspec256, sin128);
2575             testVectorCastShortToShortFail(sspec128, sspec512, sin128);
2576 
2577             testVectorCastShortToShortFail(sspec256, sspec64, sin256);
2578             testVectorCastShortToShortFail(sspec256, sspec128, sin256);
2579             testVectorCastShortToShortFail(sspec256, sspec512, sin256);
2580 
2581             testVectorCastShortToShortFail(sspec512, sspec64, sin512);
2582             testVectorCastShortToShortFail(sspec512, sspec128, sin512);
2583             testVectorCastShortToShortFail(sspec512, sspec256, sin512);
2584 
2585             testVectorCastShortToIntFail(sspec64, ispec64, sin64);
2586             testVectorCastShortToIntFail(sspec64, ispec256, sin64);
2587             testVectorCastShortToIntFail(sspec64, ispec512, sin64);
2588 
2589             testVectorCastShortToIntFail(sspec128, ispec64, sin128);
2590             testVectorCastShortToIntFail(sspec128, ispec128, sin128);
2591             testVectorCastShortToIntFail(sspec128, ispec512, sin128);
2592 
2593             testVectorCastShortToIntFail(sspec256, ispec64, sin256);
2594             testVectorCastShortToIntFail(sspec256, ispec128, sin256);
2595             testVectorCastShortToIntFail(sspec256, ispec256, sin256);
2596 
2597             testVectorCastShortToIntFail(sspec512, ispec64, sin512);
2598             testVectorCastShortToIntFail(sspec512, ispec128, sin512);
2599             testVectorCastShortToIntFail(sspec512, ispec256, sin512);
2600             testVectorCastShortToIntFail(sspec512, ispec512, sin512);
2601 
2602             testVectorCastShortToLongFail(sspec64, lspec64, sin64);
2603             testVectorCastShortToLongFail(sspec64, lspec128, sin64);
2604             testVectorCastShortToLongFail(sspec64, lspec512, sin64);
2605 
2606             testVectorCastShortToLongFail(sspec128, lspec64, sin128);
2607             testVectorCastShortToLongFail(sspec128, lspec128, sin128);
2608             testVectorCastShortToLongFail(sspec128, lspec256, sin128);
2609 
2610             testVectorCastShortToLongFail(sspec256, lspec64, sin256);
2611             testVectorCastShortToLongFail(sspec256, lspec128, sin256);
2612             testVectorCastShortToLongFail(sspec256, lspec256, sin256);
2613             testVectorCastShortToLongFail(sspec256, lspec512, sin256);
2614 
2615             testVectorCastShortToLongFail(sspec512, lspec64, sin512);
2616             testVectorCastShortToLongFail(sspec512, lspec128, sin512);
2617             testVectorCastShortToLongFail(sspec512, lspec256, sin512);
2618             testVectorCastShortToLongFail(sspec512, lspec512, sin512);
2619 
2620             testVectorCastShortToFloatFail(sspec64, fspec64, sin64);
2621             testVectorCastShortToFloatFail(sspec64, fspec256, sin64);
2622             testVectorCastShortToFloatFail(sspec64, fspec512, sin64);
2623 
2624             testVectorCastShortToFloatFail(sspec128, fspec64, sin128);
2625             testVectorCastShortToFloatFail(sspec128, fspec128, sin128);
2626             testVectorCastShortToFloatFail(sspec128, fspec512, sin128);
2627 
2628             testVectorCastShortToFloatFail(sspec256, fspec64, sin256);
2629             testVectorCastShortToFloatFail(sspec256, fspec128, sin256);
2630             testVectorCastShortToFloatFail(sspec256, fspec256, sin256);
2631 
2632             testVectorCastShortToFloatFail(sspec512, fspec64, sin512);
2633             testVectorCastShortToFloatFail(sspec512, fspec128, sin512);
2634             testVectorCastShortToFloatFail(sspec512, fspec256, sin512);
2635             testVectorCastShortToFloatFail(sspec512, fspec512, sin512);
2636 
2637             testVectorCastShortToDoubleFail(sspec64, dspec64, sin64);
2638             testVectorCastShortToDoubleFail(sspec64, dspec128, sin64);
2639             testVectorCastShortToDoubleFail(sspec64, dspec512, sin64);
2640 
2641             testVectorCastShortToDoubleFail(sspec128, dspec64, sin128);
2642             testVectorCastShortToDoubleFail(sspec128, dspec128, sin128);
2643             testVectorCastShortToDoubleFail(sspec128, dspec256, sin128);
2644 
2645             testVectorCastShortToDoubleFail(sspec256, dspec64, sin256);
2646             testVectorCastShortToDoubleFail(sspec256, dspec128, sin256);
2647             testVectorCastShortToDoubleFail(sspec256, dspec256, sin256);
2648             testVectorCastShortToDoubleFail(sspec256, dspec512, sin256);
2649 
2650             testVectorCastShortToDoubleFail(sspec512, dspec64, sin512);
2651             testVectorCastShortToDoubleFail(sspec512, dspec128, sin512);
2652             testVectorCastShortToDoubleFail(sspec512, dspec256, sin512);
2653             testVectorCastShortToDoubleFail(sspec512, dspec512, sin512);
2654         }
2655     }
2656 
2657     @Test(dataProvider = "intUnaryOpProvider")
2658     static void testCastFromInt(IntFunction<int[]> fa) {
2659         int[] iin64 = fa.apply(ispec64.length());
2660         int[] iin128 = fa.apply(ispec128.length());
2661         int[] iin256 = fa.apply(ispec256.length());
2662         int[] iin512 = fa.apply(ispec512.length());
2663 
2664         byte[] bout64 = new byte[bspec64.length()];
2665         byte[] bout128 = new byte[bspec128.length()];
2666 
2667         short[] sout64 = new short[sspec64.length()];
2668         short[] sout128 = new short[sspec128.length()];
2669         short[] sout256 = new short[sspec256.length()];
2670 
2671         int[] iout64 = new int[ispec64.length()];
2672         int[] iout128 = new int[ispec128.length()];
2673         int[] iout256 = new int[ispec256.length()];
2674         int[] iout512 = new int[ispec512.length()];
2675 
2676         long[] lout128 = new long[lspec128.length()];
2677         long[] lout256 = new long[lspec256.length()];
2678         long[] lout512 = new long[lspec512.length()];
2679 
2680         float[] fout64 = new float[fspec64.length()];
2681         float[] fout128 = new float[fspec128.length()];
2682         float[] fout256 = new float[fspec256.length()];
2683         float[] fout512 = new float[fspec512.length()];
2684 
2685         double[] dout128 = new double[dspec128.length()];
2686         double[] dout256 = new double[dspec256.length()];
2687         double[] dout512 = new double[dspec512.length()];
2688 
2689         for (int i = 0; i < NUM_ITER; i++) {
2690             testVectorCastIntToByte(ispec256, bspec64, iin256, bout64);
2691             testVectorCastIntToByte(ispec512, bspec128, iin512, bout128);
2692 
2693             testVectorCastIntToShort(ispec128, sspec64, iin128, sout64);
2694             testVectorCastIntToShort(ispec256, sspec128, iin256, sout128);
2695             testVectorCastIntToShort(ispec512, sspec256, iin512, sout256);
2696 
2697             testVectorCastIntToInt(ispec64, ispec64, iin64, iout64);
2698             testVectorCastIntToInt(ispec128, ispec128, iin128, iout128);
2699             testVectorCastIntToInt(ispec256, ispec256, iin256, iout256);
2700             testVectorCastIntToInt(ispec512, ispec512, iin512, iout512);
2701 
2702             testVectorCastIntToLong(ispec64, lspec128, iin64, lout128);
2703             testVectorCastIntToLong(ispec128, lspec256, iin128, lout256);
2704             testVectorCastIntToLong(ispec256, lspec512, iin256, lout512);
2705 
2706             testVectorCastIntToFloat(ispec64, fspec64, iin64, fout64);
2707             testVectorCastIntToFloat(ispec128, fspec128, iin128, fout128);
2708             testVectorCastIntToFloat(ispec256, fspec256, iin256, fout256);
2709             testVectorCastIntToFloat(ispec512, fspec512, iin512, fout512);
2710 
2711             testVectorCastIntToDouble(ispec64, dspec128, iin64, dout128);
2712             testVectorCastIntToDouble(ispec128, dspec256, iin128, dout256);
2713             testVectorCastIntToDouble(ispec256, dspec512, iin256, dout512);
2714         }
2715     }
2716 
2717     //@Test
2718     static void testCastFromIntFail() {
2719         int[] iin64 = new int[ispec64.length()];
2720         int[] iin128 = new int[ispec128.length()];
2721         int[] iin256 = new int[ispec256.length()];
2722         int[] iin512 = new int[ispec512.length()];
2723 
2724         for (int i = 0; i < INVOC_COUNT; i++) {
2725             testVectorCastIntToByteFail(ispec64, bspec64, iin64);
2726             testVectorCastIntToByteFail(ispec64, bspec128, iin64);
2727             testVectorCastIntToByteFail(ispec64, bspec256, iin64);
2728             testVectorCastIntToByteFail(ispec64, bspec512, iin64);
2729 
2730             testVectorCastIntToByteFail(ispec128, bspec64, iin128);
2731             testVectorCastIntToByteFail(ispec128, bspec128, iin128);
2732             testVectorCastIntToByteFail(ispec128, bspec256, iin128);
2733             testVectorCastIntToByteFail(ispec128, bspec512, iin128);
2734 
2735             testVectorCastIntToByteFail(ispec256, bspec128, iin256);
2736             testVectorCastIntToByteFail(ispec256, bspec256, iin256);
2737             testVectorCastIntToByteFail(ispec256, bspec512, iin256);
2738 
2739             testVectorCastIntToByteFail(ispec512, bspec64, iin512);
2740             testVectorCastIntToByteFail(ispec512, bspec256, iin512);
2741             testVectorCastIntToByteFail(ispec512, bspec512, iin512);
2742 
2743             testVectorCastIntToShortFail(ispec64, sspec64, iin64);
2744             testVectorCastIntToShortFail(ispec64, sspec128, iin64);
2745             testVectorCastIntToShortFail(ispec64, sspec256, iin64);
2746             testVectorCastIntToShortFail(ispec64, sspec512, iin64);
2747 
2748             testVectorCastIntToShortFail(ispec128, sspec128, iin128);
2749             testVectorCastIntToShortFail(ispec128, sspec256, iin128);
2750             testVectorCastIntToShortFail(ispec128, sspec512, iin128);
2751 
2752             testVectorCastIntToShortFail(ispec256, sspec64, iin256);
2753             testVectorCastIntToShortFail(ispec256, sspec256, iin256);
2754             testVectorCastIntToShortFail(ispec256, sspec512, iin256);
2755 
2756             testVectorCastIntToShortFail(ispec512, sspec64, iin512);
2757             testVectorCastIntToShortFail(ispec512, sspec128, iin512);
2758             testVectorCastIntToShortFail(ispec512, sspec512, iin512);
2759 
2760             testVectorCastIntToIntFail(ispec64, ispec128, iin64);
2761             testVectorCastIntToIntFail(ispec64, ispec256, iin64);
2762             testVectorCastIntToIntFail(ispec64, ispec512, iin64);
2763 
2764             testVectorCastIntToIntFail(ispec128, ispec64, iin128);
2765             testVectorCastIntToIntFail(ispec128, ispec256, iin128);
2766             testVectorCastIntToIntFail(ispec128, ispec512, iin128);
2767 
2768             testVectorCastIntToIntFail(ispec256, ispec64, iin256);
2769             testVectorCastIntToIntFail(ispec256, ispec128, iin256);
2770             testVectorCastIntToIntFail(ispec256, ispec512, iin256);
2771 
2772             testVectorCastIntToIntFail(ispec512, ispec64, iin512);
2773             testVectorCastIntToIntFail(ispec512, ispec128, iin512);
2774             testVectorCastIntToIntFail(ispec512, ispec256, iin512);
2775 
2776             testVectorCastIntToLongFail(ispec64, lspec64, iin64);
2777             testVectorCastIntToLongFail(ispec64, lspec256, iin64);
2778             testVectorCastIntToLongFail(ispec64, lspec512, iin64);
2779 
2780             testVectorCastIntToLongFail(ispec128, lspec64, iin128);
2781             testVectorCastIntToLongFail(ispec128, lspec128, iin128);
2782             testVectorCastIntToLongFail(ispec128, lspec512, iin128);
2783 
2784             testVectorCastIntToLongFail(ispec256, lspec64, iin256);
2785             testVectorCastIntToLongFail(ispec256, lspec128, iin256);
2786             testVectorCastIntToLongFail(ispec256, lspec256, iin256);
2787 
2788             testVectorCastIntToLongFail(ispec512, lspec64, iin512);
2789             testVectorCastIntToLongFail(ispec512, lspec128, iin512);
2790             testVectorCastIntToLongFail(ispec512, lspec256, iin512);
2791             testVectorCastIntToLongFail(ispec512, lspec512, iin512);
2792 
2793             testVectorCastIntToFloatFail(ispec64, fspec128, iin64);
2794             testVectorCastIntToFloatFail(ispec64, fspec256, iin64);
2795             testVectorCastIntToFloatFail(ispec64, fspec512, iin64);
2796 
2797             testVectorCastIntToFloatFail(ispec128, fspec64, iin128);
2798             testVectorCastIntToFloatFail(ispec128, fspec256, iin128);
2799             testVectorCastIntToFloatFail(ispec128, fspec512, iin128);
2800 
2801             testVectorCastIntToFloatFail(ispec256, fspec64, iin256);
2802             testVectorCastIntToFloatFail(ispec256, fspec128, iin256);
2803             testVectorCastIntToFloatFail(ispec256, fspec512, iin256);
2804 
2805             testVectorCastIntToFloatFail(ispec512, fspec64, iin512);
2806             testVectorCastIntToFloatFail(ispec512, fspec128, iin512);
2807             testVectorCastIntToFloatFail(ispec512, fspec256, iin512);
2808 
2809             testVectorCastIntToDoubleFail(ispec64, dspec64, iin64);
2810             testVectorCastIntToDoubleFail(ispec64, dspec256, iin64);
2811             testVectorCastIntToDoubleFail(ispec64, dspec512, iin64);
2812 
2813             testVectorCastIntToDoubleFail(ispec128, dspec64, iin128);
2814             testVectorCastIntToDoubleFail(ispec128, dspec128, iin128);
2815             testVectorCastIntToDoubleFail(ispec128, dspec512, iin128);
2816 
2817             testVectorCastIntToDoubleFail(ispec256, dspec64, iin256);
2818             testVectorCastIntToDoubleFail(ispec256, dspec128, iin256);
2819             testVectorCastIntToDoubleFail(ispec256, dspec256, iin256);
2820 
2821             testVectorCastIntToDoubleFail(ispec512, dspec64, iin512);
2822             testVectorCastIntToDoubleFail(ispec512, dspec128, iin512);
2823             testVectorCastIntToDoubleFail(ispec512, dspec256, iin512);
2824             testVectorCastIntToDoubleFail(ispec512, dspec512, iin512);
2825         }
2826     }
2827 
2828     @Test(dataProvider = "longUnaryOpProvider")
2829     static void testCastFromLong(IntFunction<long[]> fa) {
2830         long[] lin64 = fa.apply(lspec64.length());
2831         long[] lin128 = fa.apply(lspec128.length());
2832         long[] lin256 = fa.apply(lspec256.length());
2833         long[] lin512 = fa.apply(lspec512.length());
2834 
2835         byte[] bout64 = new byte[bspec64.length()];
2836 
2837         short[] sout64 = new short[sspec64.length()];
2838         short[] sout128 = new short[sspec128.length()];
2839 
2840         int[] iout64 = new int[ispec64.length()];
2841         int[] iout128 = new int[ispec128.length()];
2842         int[] iout256 = new int[ispec256.length()];
2843 
2844         long[] lout64 = new long[lspec64.length()];
2845         long[] lout128 = new long[lspec128.length()];
2846         long[] lout256 = new long[lspec256.length()];
2847         long[] lout512 = new long[lspec512.length()];
2848 
2849         float[] fout64 = new float[fspec64.length()];
2850         float[] fout128 = new float[fspec128.length()];
2851         float[] fout256 = new float[fspec256.length()];
2852 
2853         double[] dout64 = new double[dspec64.length()];
2854         double[] dout128 = new double[dspec128.length()];
2855         double[] dout256 = new double[dspec256.length()];
2856         double[] dout512 = new double[dspec512.length()];
2857 
2858         for (int i = 0; i < NUM_ITER; i++) {
2859             testVectorCastLongToByte(lspec512, bspec64, lin512, bout64);
2860 
2861             testVectorCastLongToShort(lspec256, sspec64, lin256, sout64);
2862             testVectorCastLongToShort(lspec512, sspec128, lin512, sout128);
2863 
2864             testVectorCastLongToInt(lspec128, ispec64, lin128, iout64);
2865             testVectorCastLongToInt(lspec256, ispec128, lin256, iout128);
2866             testVectorCastLongToInt(lspec512, ispec256, lin512, iout256);
2867 
2868             testVectorCastLongToLong(lspec64, lspec64, lin64, lout64);
2869             testVectorCastLongToLong(lspec128, lspec128, lin128, lout128);
2870             testVectorCastLongToLong(lspec256, lspec256, lin256, lout256);
2871             testVectorCastLongToLong(lspec512, lspec512, lin512, lout512);
2872 
2873             testVectorCastLongToFloat(lspec128, fspec64, lin128, fout64);
2874             testVectorCastLongToFloat(lspec256, fspec128, lin256, fout128);
2875             testVectorCastLongToFloat(lspec512, fspec256, lin512, fout256);
2876 
2877             testVectorCastLongToDouble(lspec64, dspec64, lin64, dout64);
2878             testVectorCastLongToDouble(lspec128, dspec128, lin128, dout128);
2879             testVectorCastLongToDouble(lspec256, dspec256, lin256, dout256);
2880             testVectorCastLongToDouble(lspec512, dspec512, lin512, dout512);
2881         }
2882     }
2883 
2884     //@Test
2885     static void testCastFromLongFail() {
2886         long[] lin64 = new long[lspec64.length()];
2887         long[] lin128 = new long[lspec128.length()];
2888         long[] lin256 = new long[lspec256.length()];
2889         long[] lin512 = new long[lspec512.length()];
2890 
2891         for (int i = 0; i < INVOC_COUNT; i++) {
2892             testVectorCastLongToByteFail(lspec64, bspec64, lin64);
2893             testVectorCastLongToByteFail(lspec64, bspec128, lin64);
2894             testVectorCastLongToByteFail(lspec64, bspec256, lin64);
2895             testVectorCastLongToByteFail(lspec64, bspec512, lin64);
2896 
2897             testVectorCastLongToByteFail(lspec128, bspec64, lin128);
2898             testVectorCastLongToByteFail(lspec128, bspec128, lin128);
2899             testVectorCastLongToByteFail(lspec128, bspec256, lin128);
2900             testVectorCastLongToByteFail(lspec128, bspec512, lin128);
2901 
2902             testVectorCastLongToByteFail(lspec256, bspec64, lin256);
2903             testVectorCastLongToByteFail(lspec256, bspec128, lin256);
2904             testVectorCastLongToByteFail(lspec256, bspec256, lin256);
2905             testVectorCastLongToByteFail(lspec256, bspec512, lin256);
2906 
2907             testVectorCastLongToByteFail(lspec512, bspec128, lin512);
2908             testVectorCastLongToByteFail(lspec512, bspec256, lin512);
2909             testVectorCastLongToByteFail(lspec512, bspec512, lin512);
2910 
2911             testVectorCastLongToShortFail(lspec64, sspec64, lin64);
2912             testVectorCastLongToShortFail(lspec64, sspec128, lin64);
2913             testVectorCastLongToShortFail(lspec64, sspec256, lin64);
2914             testVectorCastLongToShortFail(lspec64, sspec512, lin64);
2915 
2916             testVectorCastLongToShortFail(lspec128, sspec64, lin128);
2917             testVectorCastLongToShortFail(lspec128, sspec128, lin128);
2918             testVectorCastLongToShortFail(lspec128, sspec256, lin128);
2919             testVectorCastLongToShortFail(lspec128, sspec512, lin128);
2920 
2921             testVectorCastLongToShortFail(lspec256, sspec128, lin256);
2922             testVectorCastLongToShortFail(lspec256, sspec256, lin256);
2923             testVectorCastLongToShortFail(lspec256, sspec512, lin256);
2924 
2925             testVectorCastLongToShortFail(lspec512, sspec64, lin512);
2926             testVectorCastLongToShortFail(lspec512, sspec256, lin512);
2927             testVectorCastLongToShortFail(lspec512, sspec512, lin512);
2928 
2929             testVectorCastLongToIntFail(lspec64, ispec64, lin64);
2930             testVectorCastLongToIntFail(lspec64, ispec128, lin64);
2931             testVectorCastLongToIntFail(lspec64, ispec256, lin64);
2932             testVectorCastLongToIntFail(lspec64, ispec512, lin64);
2933 
2934             testVectorCastLongToIntFail(lspec128, ispec128, lin128);
2935             testVectorCastLongToIntFail(lspec128, ispec256, lin128);
2936             testVectorCastLongToIntFail(lspec128, ispec512, lin128);
2937 
2938             testVectorCastLongToIntFail(lspec256, ispec64, lin256);
2939             testVectorCastLongToIntFail(lspec256, ispec256, lin256);
2940             testVectorCastLongToIntFail(lspec256, ispec512, lin256);
2941 
2942             testVectorCastLongToIntFail(lspec512, ispec64, lin512);
2943             testVectorCastLongToIntFail(lspec512, ispec128, lin512);
2944             testVectorCastLongToIntFail(lspec512, ispec512, lin512);
2945 
2946             testVectorCastLongToLongFail(lspec64, lspec128, lin64);
2947             testVectorCastLongToLongFail(lspec64, lspec256, lin64);
2948             testVectorCastLongToLongFail(lspec64, lspec512, lin64);
2949 
2950             testVectorCastLongToLongFail(lspec128, lspec64, lin128);
2951             testVectorCastLongToLongFail(lspec128, lspec256, lin128);
2952             testVectorCastLongToLongFail(lspec128, lspec512, lin128);
2953 
2954             testVectorCastLongToLongFail(lspec256, lspec64, lin256);
2955             testVectorCastLongToLongFail(lspec256, lspec128, lin256);
2956             testVectorCastLongToLongFail(lspec256, lspec512, lin256);
2957 
2958             testVectorCastLongToLongFail(lspec512, lspec64, lin512);
2959             testVectorCastLongToLongFail(lspec512, lspec128, lin512);
2960             testVectorCastLongToLongFail(lspec512, lspec256, lin512);
2961 
2962             testVectorCastLongToFloatFail(lspec64, fspec64, lin64);
2963             testVectorCastLongToFloatFail(lspec64, fspec128, lin64);
2964             testVectorCastLongToFloatFail(lspec64, fspec256, lin64);
2965             testVectorCastLongToFloatFail(lspec64, fspec512, lin64);
2966 
2967             testVectorCastLongToFloatFail(lspec128, fspec128, lin128);
2968             testVectorCastLongToFloatFail(lspec128, fspec256, lin128);
2969             testVectorCastLongToFloatFail(lspec128, fspec512, lin128);
2970 
2971             testVectorCastLongToFloatFail(lspec256, fspec64, lin256);
2972             testVectorCastLongToFloatFail(lspec256, fspec256, lin256);
2973             testVectorCastLongToFloatFail(lspec256, fspec512, lin256);
2974 
2975             testVectorCastLongToFloatFail(lspec512, fspec64, lin512);
2976             testVectorCastLongToFloatFail(lspec512, fspec128, lin512);
2977             testVectorCastLongToFloatFail(lspec512, fspec512, lin512);
2978 
2979             testVectorCastLongToDoubleFail(lspec64, dspec128, lin64);
2980             testVectorCastLongToDoubleFail(lspec64, dspec256, lin64);
2981             testVectorCastLongToDoubleFail(lspec64, dspec512, lin64);
2982 
2983             testVectorCastLongToDoubleFail(lspec128, dspec64, lin128);
2984             testVectorCastLongToDoubleFail(lspec128, dspec256, lin128);
2985             testVectorCastLongToDoubleFail(lspec128, dspec512, lin128);
2986 
2987             testVectorCastLongToDoubleFail(lspec256, dspec64, lin256);
2988             testVectorCastLongToDoubleFail(lspec256, dspec128, lin256);
2989             testVectorCastLongToDoubleFail(lspec256, dspec512, lin256);
2990 
2991             testVectorCastLongToDoubleFail(lspec512, dspec64, lin512);
2992             testVectorCastLongToDoubleFail(lspec512, dspec128, lin512);
2993             testVectorCastLongToDoubleFail(lspec512, dspec256, lin512);
2994         }
2995     }
2996 
2997     @Test(dataProvider = "floatUnaryOpProvider")
2998     static void testCastFromFloat(IntFunction<float[]> fa) {
2999         float[] fin64 = fa.apply(fspec64.length());
3000         float[] fin128 = fa.apply(fspec128.length());
3001         float[] fin256 = fa.apply(fspec256.length());
3002         float[] fin512 = fa.apply(fspec512.length());
3003 
3004         byte[] bout64 = new byte[bspec64.length()];
3005         byte[] bout128 = new byte[bspec128.length()];
3006 
3007         short[] sout64 = new short[sspec64.length()];
3008         short[] sout128 = new short[sspec128.length()];
3009         short[] sout256 = new short[sspec256.length()];
3010 
3011         int[] iout64 = new int[ispec64.length()];
3012         int[] iout128 = new int[ispec128.length()];
3013         int[] iout256 = new int[ispec256.length()];
3014         int[] iout512 = new int[ispec512.length()];
3015 
3016         long[] lout128 = new long[lspec128.length()];
3017         long[] lout256 = new long[lspec256.length()];
3018         long[] lout512 = new long[lspec512.length()];
3019 
3020         float[] fout64 = new float[fspec64.length()];
3021         float[] fout128 = new float[fspec128.length()];
3022         float[] fout256 = new float[fspec256.length()];
3023         float[] fout512 = new float[fspec512.length()];
3024 
3025         double[] dout128 = new double[dspec128.length()];
3026         double[] dout256 = new double[dspec256.length()];
3027         double[] dout512 = new double[dspec512.length()];
3028 
3029         for (int i = 0; i < NUM_ITER; i++) {
3030             testVectorCastFloatToByte(fspec256, bspec64, fin256, bout64);
3031             testVectorCastFloatToByte(fspec512, bspec128, fin512, bout128);
3032 
3033             testVectorCastFloatToShort(fspec128, sspec64, fin128, sout64);
3034             testVectorCastFloatToShort(fspec256, sspec128, fin256, sout128);
3035             testVectorCastFloatToShort(fspec512, sspec256, fin512, sout256);
3036 
3037             testVectorCastFloatToInt(fspec64, ispec64, fin64, iout64);
3038             testVectorCastFloatToInt(fspec128, ispec128, fin128, iout128);
3039             testVectorCastFloatToInt(fspec256, ispec256, fin256, iout256);
3040             testVectorCastFloatToInt(fspec512, ispec512, fin512, iout512);
3041 
3042             testVectorCastFloatToLong(fspec64, lspec128, fin64, lout128);
3043             testVectorCastFloatToLong(fspec128, lspec256, fin128, lout256);
3044             testVectorCastFloatToLong(fspec256, lspec512, fin256, lout512);
3045 
3046             testVectorCastFloatToFloat(fspec64, fspec64, fin64, fout64);
3047             testVectorCastFloatToFloat(fspec128, fspec128, fin128, fout128);
3048             testVectorCastFloatToFloat(fspec256, fspec256, fin256, fout256);
3049             testVectorCastFloatToFloat(fspec512, fspec512, fin512, fout512);
3050 
3051             testVectorCastFloatToDouble(fspec64, dspec128, fin64, dout128);
3052             testVectorCastFloatToDouble(fspec128, dspec256, fin128, dout256);
3053             testVectorCastFloatToDouble(fspec256, dspec512, fin256, dout512);
3054         }
3055     }
3056 
3057     //@Test
3058     static void testCastFromFloatFail() {
3059         float[] fin64 = new float[fspec64.length()];
3060         float[] fin128 = new float[fspec128.length()];
3061         float[] fin256 = new float[fspec256.length()];
3062         float[] fin512 = new float[fspec512.length()];
3063 
3064         for (int i = 0; i < INVOC_COUNT; i++) {
3065             testVectorCastFloatToByteFail(fspec64, bspec64, fin64);
3066             testVectorCastFloatToByteFail(fspec64, bspec128, fin64);
3067             testVectorCastFloatToByteFail(fspec64, bspec256, fin64);
3068             testVectorCastFloatToByteFail(fspec64, bspec512, fin64);
3069 
3070             testVectorCastFloatToByteFail(fspec128, bspec64, fin128);
3071             testVectorCastFloatToByteFail(fspec128, bspec128, fin128);
3072             testVectorCastFloatToByteFail(fspec128, bspec256, fin128);
3073             testVectorCastFloatToByteFail(fspec128, bspec512, fin128);
3074 
3075             testVectorCastFloatToByteFail(fspec256, bspec128, fin256);
3076             testVectorCastFloatToByteFail(fspec256, bspec256, fin256);
3077             testVectorCastFloatToByteFail(fspec256, bspec512, fin256);
3078 
3079             testVectorCastFloatToByteFail(fspec512, bspec64, fin512);
3080             testVectorCastFloatToByteFail(fspec512, bspec256, fin512);
3081             testVectorCastFloatToByteFail(fspec512, bspec512, fin512);
3082 
3083             testVectorCastFloatToShortFail(fspec64, sspec64, fin64);
3084             testVectorCastFloatToShortFail(fspec64, sspec128, fin64);
3085             testVectorCastFloatToShortFail(fspec64, sspec256, fin64);
3086             testVectorCastFloatToShortFail(fspec64, sspec512, fin64);
3087 
3088             testVectorCastFloatToShortFail(fspec128, sspec128, fin128);
3089             testVectorCastFloatToShortFail(fspec128, sspec256, fin128);
3090             testVectorCastFloatToShortFail(fspec128, sspec512, fin128);
3091 
3092             testVectorCastFloatToShortFail(fspec256, sspec64, fin256);
3093             testVectorCastFloatToShortFail(fspec256, sspec256, fin256);
3094             testVectorCastFloatToShortFail(fspec256, sspec512, fin256);
3095 
3096             testVectorCastFloatToShortFail(fspec512, sspec64, fin512);
3097             testVectorCastFloatToShortFail(fspec512, sspec128, fin512);
3098             testVectorCastFloatToShortFail(fspec512, sspec512, fin512);
3099 
3100             testVectorCastFloatToIntFail(fspec64, ispec128, fin64);
3101             testVectorCastFloatToIntFail(fspec64, ispec256, fin64);
3102             testVectorCastFloatToIntFail(fspec64, ispec512, fin64);
3103 
3104             testVectorCastFloatToIntFail(fspec128, ispec64, fin128);
3105             testVectorCastFloatToIntFail(fspec128, ispec256, fin128);
3106             testVectorCastFloatToIntFail(fspec128, ispec512, fin128);
3107 
3108             testVectorCastFloatToIntFail(fspec256, ispec64, fin256);
3109             testVectorCastFloatToIntFail(fspec256, ispec128, fin256);
3110             testVectorCastFloatToIntFail(fspec256, ispec512, fin256);
3111 
3112             testVectorCastFloatToIntFail(fspec512, ispec64, fin512);
3113             testVectorCastFloatToIntFail(fspec512, ispec128, fin512);
3114             testVectorCastFloatToIntFail(fspec512, ispec256, fin512);
3115 
3116             testVectorCastFloatToLongFail(fspec64, lspec64, fin64);
3117             testVectorCastFloatToLongFail(fspec64, lspec256, fin64);
3118             testVectorCastFloatToLongFail(fspec64, lspec512, fin64);
3119 
3120             testVectorCastFloatToLongFail(fspec128, lspec64, fin128);
3121             testVectorCastFloatToLongFail(fspec128, lspec128, fin128);
3122             testVectorCastFloatToLongFail(fspec128, lspec512, fin128);
3123 
3124             testVectorCastFloatToLongFail(fspec256, lspec64, fin256);
3125             testVectorCastFloatToLongFail(fspec256, lspec128, fin256);
3126             testVectorCastFloatToLongFail(fspec256, lspec256, fin256);
3127 
3128             testVectorCastFloatToLongFail(fspec512, lspec64, fin512);
3129             testVectorCastFloatToLongFail(fspec512, lspec128, fin512);
3130             testVectorCastFloatToLongFail(fspec512, lspec256, fin512);
3131             testVectorCastFloatToLongFail(fspec512, lspec512, fin512);
3132 
3133             testVectorCastFloatToFloatFail(fspec64, fspec128, fin64);
3134             testVectorCastFloatToFloatFail(fspec64, fspec256, fin64);
3135             testVectorCastFloatToFloatFail(fspec64, fspec512, fin64);
3136 
3137             testVectorCastFloatToFloatFail(fspec128, fspec64, fin128);
3138             testVectorCastFloatToFloatFail(fspec128, fspec256, fin128);
3139             testVectorCastFloatToFloatFail(fspec128, fspec512, fin128);
3140 
3141             testVectorCastFloatToFloatFail(fspec256, fspec64, fin256);
3142             testVectorCastFloatToFloatFail(fspec256, fspec128, fin256);
3143             testVectorCastFloatToFloatFail(fspec256, fspec512, fin256);
3144 
3145             testVectorCastFloatToFloatFail(fspec512, fspec64, fin512);
3146             testVectorCastFloatToFloatFail(fspec512, fspec128, fin512);
3147             testVectorCastFloatToFloatFail(fspec512, fspec256, fin512);
3148 
3149             testVectorCastFloatToDoubleFail(fspec64, dspec64, fin64);
3150             testVectorCastFloatToDoubleFail(fspec64, dspec256, fin64);
3151             testVectorCastFloatToDoubleFail(fspec64, dspec512, fin64);
3152 
3153             testVectorCastFloatToDoubleFail(fspec128, dspec64, fin128);
3154             testVectorCastFloatToDoubleFail(fspec128, dspec128, fin128);
3155             testVectorCastFloatToDoubleFail(fspec128, dspec512, fin128);
3156 
3157             testVectorCastFloatToDoubleFail(fspec256, dspec64, fin256);
3158             testVectorCastFloatToDoubleFail(fspec256, dspec128, fin256);
3159             testVectorCastFloatToDoubleFail(fspec256, dspec256, fin256);
3160 
3161             testVectorCastFloatToDoubleFail(fspec512, dspec64, fin512);
3162             testVectorCastFloatToDoubleFail(fspec512, dspec128, fin512);
3163             testVectorCastFloatToDoubleFail(fspec512, dspec256, fin512);
3164             testVectorCastFloatToDoubleFail(fspec512, dspec512, fin512);
3165         }
3166     }
3167 
3168     @Test(dataProvider = "doubleUnaryOpProvider")
3169     static void testCastFromDouble(IntFunction<double[]> fa) {
3170         double[] din64 = fa.apply(dspec64.length());
3171         double[] din128 = fa.apply(dspec128.length());
3172         double[] din256 = fa.apply(dspec256.length());
3173         double[] din512 = fa.apply(dspec512.length());
3174 
3175         byte[] bout64 = new byte[bspec64.length()];
3176 
3177         short[] sout64 = new short[sspec64.length()];
3178         short[] sout128 = new short[sspec128.length()];
3179 
3180         int[] iout64 = new int[ispec64.length()];
3181         int[] iout128 = new int[ispec128.length()];
3182         int[] iout256 = new int[ispec256.length()];
3183 
3184         long[] lout64 = new long[lspec64.length()];
3185         long[] lout128 = new long[lspec128.length()];
3186         long[] lout256 = new long[lspec256.length()];
3187         long[] lout512 = new long[lspec512.length()];
3188 
3189         float[] fout64 = new float[fspec64.length()];
3190         float[] fout128 = new float[fspec128.length()];
3191         float[] fout256 = new float[fspec256.length()];
3192 
3193         double[] dout64 = new double[dspec64.length()];
3194         double[] dout128 = new double[dspec128.length()];
3195         double[] dout256 = new double[dspec256.length()];
3196         double[] dout512 = new double[dspec512.length()];
3197 
3198         for (int i = 0; i < NUM_ITER; i++) {
3199             testVectorCastDoubleToByte(dspec512, bspec64, din512, bout64);
3200 
3201             testVectorCastDoubleToShort(dspec256, sspec64, din256, sout64);
3202             testVectorCastDoubleToShort(dspec512, sspec128, din512, sout128);
3203 
3204             testVectorCastDoubleToInt(dspec128, ispec64, din128, iout64);
3205             testVectorCastDoubleToInt(dspec256, ispec128, din256, iout128);
3206             testVectorCastDoubleToInt(dspec512, ispec256, din512, iout256);
3207 
3208             testVectorCastDoubleToLong(dspec64, lspec64, din64, lout64);
3209             testVectorCastDoubleToLong(dspec128, lspec128, din128, lout128);
3210             testVectorCastDoubleToLong(dspec256, lspec256, din256, lout256);
3211             testVectorCastDoubleToLong(dspec512, lspec512, din512, lout512);
3212 
3213             testVectorCastDoubleToFloat(dspec128, fspec64, din128, fout64);
3214             testVectorCastDoubleToFloat(dspec256, fspec128, din256, fout128);
3215             testVectorCastDoubleToFloat(dspec512, fspec256, din512, fout256);
3216 
3217             testVectorCastDoubleToDouble(dspec64, dspec64, din64, dout64);
3218             testVectorCastDoubleToDouble(dspec128, dspec128, din128, dout128);
3219             testVectorCastDoubleToDouble(dspec256, dspec256, din256, dout256);
3220             testVectorCastDoubleToDouble(dspec512, dspec512, din512, dout512);
3221         }
3222     }
3223 
3224     //@Test
3225     static void testCastFromDoubleFail() {
3226         double[] din64 = new double[dspec64.length()];
3227         double[] din128 = new double[dspec128.length()];
3228         double[] din256 = new double[dspec256.length()];
3229         double[] din512 = new double[dspec512.length()];
3230 
3231         for (int i = 0; i < INVOC_COUNT; i++) {
3232             testVectorCastDoubleToByteFail(dspec64, bspec64, din64);
3233             testVectorCastDoubleToByteFail(dspec64, bspec128, din64);
3234             testVectorCastDoubleToByteFail(dspec64, bspec256, din64);
3235             testVectorCastDoubleToByteFail(dspec64, bspec512, din64);
3236 
3237             testVectorCastDoubleToByteFail(dspec128, bspec64, din128);
3238             testVectorCastDoubleToByteFail(dspec128, bspec128, din128);
3239             testVectorCastDoubleToByteFail(dspec128, bspec256, din128);
3240             testVectorCastDoubleToByteFail(dspec128, bspec512, din128);
3241 
3242             testVectorCastDoubleToByteFail(dspec256, bspec64, din256);
3243             testVectorCastDoubleToByteFail(dspec256, bspec128, din256);
3244             testVectorCastDoubleToByteFail(dspec256, bspec256, din256);
3245             testVectorCastDoubleToByteFail(dspec256, bspec512, din256);
3246 
3247             testVectorCastDoubleToByteFail(dspec512, bspec128, din512);
3248             testVectorCastDoubleToByteFail(dspec512, bspec256, din512);
3249             testVectorCastDoubleToByteFail(dspec512, bspec512, din512);
3250 
3251             testVectorCastDoubleToShortFail(dspec64, sspec64, din64);
3252             testVectorCastDoubleToShortFail(dspec64, sspec128, din64);
3253             testVectorCastDoubleToShortFail(dspec64, sspec256, din64);
3254             testVectorCastDoubleToShortFail(dspec64, sspec512, din64);
3255 
3256             testVectorCastDoubleToShortFail(dspec128, sspec64, din128);
3257             testVectorCastDoubleToShortFail(dspec128, sspec128, din128);
3258             testVectorCastDoubleToShortFail(dspec128, sspec256, din128);
3259             testVectorCastDoubleToShortFail(dspec128, sspec512, din128);
3260 
3261             testVectorCastDoubleToShortFail(dspec256, sspec128, din256);
3262             testVectorCastDoubleToShortFail(dspec256, sspec256, din256);
3263             testVectorCastDoubleToShortFail(dspec256, sspec512, din256);
3264 
3265             testVectorCastDoubleToShortFail(dspec512, sspec64, din512);
3266             testVectorCastDoubleToShortFail(dspec512, sspec256, din512);
3267             testVectorCastDoubleToShortFail(dspec512, sspec512, din512);
3268 
3269             testVectorCastDoubleToIntFail(dspec64, ispec64, din64);
3270             testVectorCastDoubleToIntFail(dspec64, ispec128, din64);
3271             testVectorCastDoubleToIntFail(dspec64, ispec256, din64);
3272             testVectorCastDoubleToIntFail(dspec64, ispec512, din64);
3273 
3274             testVectorCastDoubleToIntFail(dspec128, ispec128, din128);
3275             testVectorCastDoubleToIntFail(dspec128, ispec256, din128);
3276             testVectorCastDoubleToIntFail(dspec128, ispec512, din128);
3277 
3278             testVectorCastDoubleToIntFail(dspec256, ispec64, din256);
3279             testVectorCastDoubleToIntFail(dspec256, ispec256, din256);
3280             testVectorCastDoubleToIntFail(dspec256, ispec512, din256);
3281 
3282             testVectorCastDoubleToIntFail(dspec512, ispec64, din512);
3283             testVectorCastDoubleToIntFail(dspec512, ispec128, din512);
3284             testVectorCastDoubleToIntFail(dspec512, ispec512, din512);
3285 
3286             testVectorCastDoubleToLongFail(dspec64, lspec128, din64);
3287             testVectorCastDoubleToLongFail(dspec64, lspec256, din64);
3288             testVectorCastDoubleToLongFail(dspec64, lspec512, din64);
3289 
3290             testVectorCastDoubleToLongFail(dspec128, lspec64, din128);
3291             testVectorCastDoubleToLongFail(dspec128, lspec256, din128);
3292             testVectorCastDoubleToLongFail(dspec128, lspec512, din128);
3293 
3294             testVectorCastDoubleToLongFail(dspec256, lspec64, din256);
3295             testVectorCastDoubleToLongFail(dspec256, lspec128, din256);
3296             testVectorCastDoubleToLongFail(dspec256, lspec512, din256);
3297 
3298             testVectorCastDoubleToLongFail(dspec512, lspec64, din512);
3299             testVectorCastDoubleToLongFail(dspec512, lspec128, din512);
3300             testVectorCastDoubleToLongFail(dspec512, lspec256, din512);
3301 
3302             testVectorCastDoubleToFloatFail(dspec64, fspec64, din64);
3303             testVectorCastDoubleToFloatFail(dspec64, fspec128, din64);
3304             testVectorCastDoubleToFloatFail(dspec64, fspec256, din64);
3305             testVectorCastDoubleToFloatFail(dspec64, fspec512, din64);
3306 
3307             testVectorCastDoubleToFloatFail(dspec128, fspec128, din128);
3308             testVectorCastDoubleToFloatFail(dspec128, fspec256, din128);
3309             testVectorCastDoubleToFloatFail(dspec128, fspec512, din128);
3310 
3311             testVectorCastDoubleToFloatFail(dspec256, fspec64, din256);
3312             testVectorCastDoubleToFloatFail(dspec256, fspec256, din256);
3313             testVectorCastDoubleToFloatFail(dspec256, fspec512, din256);
3314 
3315             testVectorCastDoubleToFloatFail(dspec512, fspec64, din512);
3316             testVectorCastDoubleToFloatFail(dspec512, fspec128, din512);
3317             testVectorCastDoubleToFloatFail(dspec512, fspec512, din512);
3318 
3319             testVectorCastDoubleToDoubleFail(dspec64, dspec128, din64);
3320             testVectorCastDoubleToDoubleFail(dspec64, dspec256, din64);
3321             testVectorCastDoubleToDoubleFail(dspec64, dspec512, din64);
3322 
3323             testVectorCastDoubleToDoubleFail(dspec128, dspec64, din128);
3324             testVectorCastDoubleToDoubleFail(dspec128, dspec256, din128);
3325             testVectorCastDoubleToDoubleFail(dspec128, dspec512, din128);
3326 
3327             testVectorCastDoubleToDoubleFail(dspec256, dspec64, din256);
3328             testVectorCastDoubleToDoubleFail(dspec256, dspec128, din256);
3329             testVectorCastDoubleToDoubleFail(dspec256, dspec512, din256);
3330 
3331             testVectorCastDoubleToDoubleFail(dspec512, dspec64, din512);
3332             testVectorCastDoubleToDoubleFail(dspec512, dspec128, din512);
3333             testVectorCastDoubleToDoubleFail(dspec512, dspec256, din512);
3334         }
3335     }
3336 
3337     @ForceInline
3338     static
3339     void testVectorUCastByteToShort(VectorSpecies<Byte> a, VectorSpecies<Short> b, byte[] input, short[] output) {
3340         assert(input.length == a.length());
3341         assert(output.length == b.length());
3342 
3343         ByteVector av = ByteVector.fromArray(a, input, 0);
3344         ShortVector bv = (ShortVector) av.convertShape(VectorOperators.ZERO_EXTEND_B2S, b, 0);
3345         bv.intoArray(output, 0);
3346 
3347         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3348             Assert.assertEquals(output[i], Byte.toUnsignedLong(input[i]));
3349         }
3350         for(int i = input.length; i < output.length; i++) {
3351             Assert.assertEquals(output[i], (short)0);
3352         }
3353     }
3354 
3355     @ForceInline
3356     static
3357     void testVectorUCastByteToInt(VectorSpecies<Byte> a, VectorSpecies<Integer> b, byte[] input, int[] output) {
3358         assert(input.length == a.length());
3359         assert(output.length == b.length());
3360 
3361         ByteVector av = ByteVector.fromArray(a, input, 0);
3362         IntVector bv = (IntVector) av.convertShape(VectorOperators.ZERO_EXTEND_B2I, b, 0);
3363         bv.intoArray(output, 0);
3364 
3365         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3366             Assert.assertEquals(output[i], Byte.toUnsignedLong(input[i]));
3367         }
3368         for(int i = input.length; i < output.length; i++) {
3369             Assert.assertEquals(output[i], (int)0);
3370         }
3371     }
3372 
3373     @ForceInline
3374     static
3375     void testVectorUCastByteToLong(VectorSpecies<Byte> a, VectorSpecies<Long> b, byte[] input, long[] output) {
3376         assert(input.length == a.length());
3377         assert(output.length == b.length());
3378 
3379         ByteVector av = ByteVector.fromArray(a, input, 0);
3380         LongVector bv = (LongVector) av.convertShape(VectorOperators.ZERO_EXTEND_B2L, b, 0);
3381         bv.intoArray(output, 0);
3382 
3383         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3384             Assert.assertEquals(output[i], Byte.toUnsignedLong(input[i]));
3385         }
3386         for(int i = input.length; i < output.length; i++) {
3387             Assert.assertEquals(output[i], (long)0);
3388         }
3389     }
3390 
3391     @ForceInline
3392     static
3393     void testVectorUCastShortToInt(VectorSpecies<Short> a, VectorSpecies<Integer> b, short[] input, int[] output) {
3394         assert(input.length == a.length());
3395         assert(output.length == b.length());
3396 
3397         ShortVector av = ShortVector.fromArray(a, input, 0);
3398         IntVector bv = (IntVector) av.convertShape(VectorOperators.ZERO_EXTEND_S2I, b, 0);
3399         bv.intoArray(output, 0);
3400 
3401         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3402             Assert.assertEquals(output[i], Short.toUnsignedLong(input[i]));
3403         }
3404         for(int i = input.length; i < output.length; i++) {
3405             Assert.assertEquals(output[i], (int)0);
3406         }
3407     }
3408 
3409     @ForceInline
3410     static
3411     void testVectorUCastShortToLong(VectorSpecies<Short> a, VectorSpecies<Long> b, short[] input, long[] output) {
3412         assert(input.length == a.length());
3413         assert(output.length == b.length());
3414 
3415         ShortVector av = ShortVector.fromArray(a, input, 0);
3416         LongVector bv = (LongVector) av.convertShape(VectorOperators.ZERO_EXTEND_S2L, b, 0);
3417         bv.intoArray(output, 0);
3418 
3419         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3420             Assert.assertEquals(output[i], Short.toUnsignedLong(input[i]));
3421         }
3422         for(int i = input.length; i < output.length; i++) {
3423             Assert.assertEquals(output[i], (long)0);
3424         }
3425     }
3426 
3427     @ForceInline
3428     static
3429     void testVectorUCastIntToLong(VectorSpecies<Integer> a, VectorSpecies<Long> b, int[] input, long[] output) {
3430         assert(input.length == a.length());
3431         assert(output.length == b.length());
3432 
3433         IntVector av = IntVector.fromArray(a, input, 0);
3434         LongVector bv = (LongVector) av.convertShape(VectorOperators.ZERO_EXTEND_I2L, b, 0);
3435         bv.intoArray(output, 0);
3436 
3437         for (int i = 0; i < Math.min(input.length, output.length); i++) {
3438             Assert.assertEquals(output[i], Integer.toUnsignedLong(input[i]));
3439         }
3440         for(int i = input.length; i < output.length; i++) {
3441             Assert.assertEquals(output[i], (long)0);
3442         }
3443     }
3444 
3445     @Test(dataProvider = "byteUnaryOpProvider")
3446     static void testUCastFromByte(IntFunction<byte[]> fa) {
3447         byte[] bin64 = fa.apply(bspec64.length());
3448         byte[] bin128 = fa.apply(bspec128.length());
3449         byte[] bin256 = fa.apply(bspec256.length());
3450         byte[] bin512 = fa.apply(bspec512.length());
3451 
3452         short[] sout64 = new short[sspec64.length()];
3453         short[] sout128 = new short[sspec128.length()];
3454         short[] sout256 = new short[sspec256.length()];
3455         short[] sout512 = new short[sspec512.length()];
3456 
3457         int[] iout64 = new int[ispec64.length()];
3458         int[] iout128 = new int[ispec128.length()];
3459         int[] iout256 = new int[ispec256.length()];
3460         int[] iout512 = new int[ispec512.length()];
3461 
3462         long[] lout64 = new long[lspec64.length()];
3463         long[] lout128 = new long[lspec128.length()];
3464         long[] lout256 = new long[lspec256.length()];
3465         long[] lout512 = new long[lspec512.length()];
3466 
3467         for (int i = 0; i < NUM_ITER; i++) {
3468             // B2S exact fit
3469             testVectorUCastByteToShort(bspec64, sspec128, bin64, sout128);
3470             testVectorUCastByteToShort(bspec128, sspec256, bin128, sout256);
3471             testVectorUCastByteToShort(bspec256, sspec512, bin256, sout512);
3472 
3473             // B2S expansion
3474             testVectorUCastByteToShort(bspec64, sspec64, bin64, sout64);
3475             testVectorUCastByteToShort(bspec128, sspec128, bin128, sout128);
3476             testVectorUCastByteToShort(bspec256, sspec256, bin256, sout256);
3477             testVectorUCastByteToShort(bspec512, sspec512, bin512, sout512);
3478 
3479             testVectorUCastByteToShort(bspec128, sspec64, bin128, sout64);
3480             testVectorUCastByteToShort(bspec256, sspec128, bin256, sout128);
3481             testVectorUCastByteToShort(bspec512, sspec256, bin512, sout256);
3482 
3483             testVectorUCastByteToShort(bspec256, sspec64, bin256, sout64);
3484             testVectorUCastByteToShort(bspec512, sspec128, bin512, sout128);
3485 
3486             testVectorUCastByteToShort(bspec512, sspec64, bin512, sout64);
3487 
3488             // B2S contraction
3489             testVectorUCastByteToShort(bspec64, sspec256, bin64, sout256);
3490             testVectorUCastByteToShort(bspec128, sspec512, bin128, sout512);
3491 
3492             testVectorUCastByteToShort(bspec64, sspec512, bin64, sout512);
3493 
3494             // B2I exact fit
3495             testVectorUCastByteToInt(bspec64, ispec256, bin64, iout256);
3496             testVectorUCastByteToInt(bspec128, ispec512, bin128, iout512);
3497 
3498             // B2I expansion
3499             testVectorUCastByteToInt(bspec64, ispec128, bin64, iout128);
3500             testVectorUCastByteToInt(bspec128, ispec256, bin128, iout256);
3501             testVectorUCastByteToInt(bspec256, ispec512, bin256, iout512);
3502 
3503             testVectorUCastByteToInt(bspec64, ispec64, bin64, iout64);
3504             testVectorUCastByteToInt(bspec128, ispec128, bin128, iout128);
3505             testVectorUCastByteToInt(bspec256, ispec256, bin256, iout256);
3506             testVectorUCastByteToInt(bspec512, ispec512, bin512, iout512);
3507 
3508             testVectorUCastByteToInt(bspec128, ispec64, bin128, iout64);
3509             testVectorUCastByteToInt(bspec256, ispec128, bin256, iout128);
3510             testVectorUCastByteToInt(bspec512, ispec256, bin512, iout256);
3511 
3512             testVectorUCastByteToInt(bspec256, ispec64, bin256, iout64);
3513             testVectorUCastByteToInt(bspec512, ispec128, bin512, iout128);
3514 
3515             testVectorUCastByteToInt(bspec512, ispec64, bin512, iout64);
3516 
3517             // B2I contraction
3518             testVectorUCastByteToInt(bspec64, ispec512, bin64, iout512);
3519 
3520             // B2L exact fit
3521             testVectorUCastByteToLong(bspec64, lspec512, bin64, lout512);
3522 
3523             // B2L expansion
3524             testVectorUCastByteToLong(bspec64, lspec256, bin64, lout256);
3525             testVectorUCastByteToLong(bspec128, lspec512, bin128, lout512);
3526 
3527             testVectorUCastByteToLong(bspec64, lspec128, bin64, lout128);
3528             testVectorUCastByteToLong(bspec128, lspec256, bin128, lout256);
3529             testVectorUCastByteToLong(bspec256, lspec512, bin256, lout512);
3530 
3531             testVectorUCastByteToLong(bspec64, lspec64, bin64, lout64);
3532             testVectorUCastByteToLong(bspec128, lspec128, bin128, lout128);
3533             testVectorUCastByteToLong(bspec256, lspec256, bin256, lout256);
3534             testVectorUCastByteToLong(bspec512, lspec512, bin512, lout512);
3535 
3536             testVectorUCastByteToLong(bspec128, lspec64, bin128, lout64);
3537             testVectorUCastByteToLong(bspec256, lspec128, bin256, lout128);
3538             testVectorUCastByteToLong(bspec512, lspec256, bin512, lout256);
3539 
3540             testVectorUCastByteToLong(bspec256, lspec64, bin256, lout64);
3541             testVectorUCastByteToLong(bspec512, lspec128, bin512, lout128);
3542 
3543             testVectorUCastByteToLong(bspec512, lspec64, bin512, lout64);
3544         }
3545     }
3546 
3547     @Test(dataProvider = "shortUnaryOpProvider")
3548     static void testUCastFromShort(IntFunction<short[]> fa) {
3549         short[] sin64 = fa.apply(sspec64.length());
3550         short[] sin128 = fa.apply(sspec128.length());
3551         short[] sin256 = fa.apply(sspec256.length());
3552         short[] sin512 = fa.apply(sspec512.length());
3553 
3554         int[] iout64 = new int[ispec64.length()];
3555         int[] iout128 = new int[ispec128.length()];
3556         int[] iout256 = new int[ispec256.length()];
3557         int[] iout512 = new int[ispec512.length()];
3558 
3559         long[] lout64 = new long[lspec64.length()];
3560         long[] lout128 = new long[lspec128.length()];
3561         long[] lout256 = new long[lspec256.length()];
3562         long[] lout512 = new long[lspec512.length()];
3563 
3564         for (int i = 0; i < NUM_ITER; i++) {
3565             // S2I exact fit
3566             testVectorUCastShortToInt(sspec64, ispec128, sin64, iout128);
3567             testVectorUCastShortToInt(sspec128, ispec256, sin128, iout256);
3568             testVectorUCastShortToInt(sspec256, ispec512, sin256, iout512);
3569 
3570             // S2I expansion
3571             testVectorUCastShortToInt(sspec64, ispec64, sin64, iout64);
3572             testVectorUCastShortToInt(sspec128, ispec128, sin128, iout128);
3573             testVectorUCastShortToInt(sspec256, ispec256, sin256, iout256);
3574             testVectorUCastShortToInt(sspec512, ispec512, sin512, iout512);
3575 
3576             testVectorUCastShortToInt(sspec128, ispec64, sin128, iout64);
3577             testVectorUCastShortToInt(sspec256, ispec128, sin256, iout128);
3578             testVectorUCastShortToInt(sspec512, ispec256, sin512, iout256);
3579 
3580             testVectorUCastShortToInt(sspec256, ispec64, sin256, iout64);
3581             testVectorUCastShortToInt(sspec512, ispec128, sin512, iout128);
3582 
3583             testVectorUCastShortToInt(sspec512, ispec64, sin512, iout64);
3584 
3585             // S2I contraction
3586             testVectorUCastShortToInt(sspec64, ispec256, sin64, iout256);
3587             testVectorUCastShortToInt(sspec128, ispec512, sin128, iout512);
3588 
3589             testVectorUCastShortToInt(sspec64, ispec512, sin64, iout512);
3590 
3591             // S2L exact fit
3592             testVectorUCastShortToLong(sspec64, lspec256, sin64, lout256);
3593             testVectorUCastShortToLong(sspec128, lspec512, sin128, lout512);
3594 
3595             // S2L expansion
3596             testVectorUCastShortToLong(sspec64, lspec128, sin64, lout128);
3597             testVectorUCastShortToLong(sspec128, lspec256, sin128, lout256);
3598             testVectorUCastShortToLong(sspec256, lspec512, sin256, lout512);
3599 
3600             testVectorUCastShortToLong(sspec64, lspec64, sin64, lout64);
3601             testVectorUCastShortToLong(sspec128, lspec128, sin128, lout128);
3602             testVectorUCastShortToLong(sspec256, lspec256, sin256, lout256);
3603             testVectorUCastShortToLong(sspec512, lspec512, sin512, lout512);
3604 
3605             testVectorUCastShortToLong(sspec128, lspec64, sin128, lout64);
3606             testVectorUCastShortToLong(sspec256, lspec128, sin256, lout128);
3607             testVectorUCastShortToLong(sspec512, lspec256, sin512, lout256);
3608 
3609             testVectorUCastShortToLong(sspec256, lspec64, sin256, lout64);
3610             testVectorUCastShortToLong(sspec512, lspec128, sin512, lout128);
3611 
3612             testVectorUCastShortToLong(sspec512, lspec64, sin512, lout64);
3613 
3614             // S2L contraction
3615             testVectorUCastShortToLong(sspec64, lspec512, sin64, lout512);
3616         }
3617     }
3618 
3619     @Test(dataProvider = "intUnaryOpProvider")
3620     static void testUCastFromInt(IntFunction<int[]> fa) {
3621         int[] iin64 = fa.apply(ispec64.length());
3622         int[] iin128 = fa.apply(ispec128.length());
3623         int[] iin256 = fa.apply(ispec256.length());
3624         int[] iin512 = fa.apply(ispec512.length());
3625 
3626         long[] lout64 = new long[lspec64.length()];
3627         long[] lout128 = new long[lspec128.length()];
3628         long[] lout256 = new long[lspec256.length()];
3629         long[] lout512 = new long[lspec512.length()];
3630 
3631         // I2L exact fit
3632         testVectorUCastIntToLong(ispec64, lspec128, iin64, lout128);
3633         testVectorUCastIntToLong(ispec128, lspec256, iin128, lout256);
3634         testVectorUCastIntToLong(ispec256, lspec512, iin256, lout512);
3635 
3636         // I2L expansion
3637         testVectorUCastIntToLong(ispec64, lspec64, iin64, lout64);
3638         testVectorUCastIntToLong(ispec128, lspec128, iin128, lout128);
3639         testVectorUCastIntToLong(ispec256, lspec256, iin256, lout256);
3640         testVectorUCastIntToLong(ispec512, lspec512, iin512, lout512);
3641 
3642         testVectorUCastIntToLong(ispec128, lspec64, iin128, lout64);
3643         testVectorUCastIntToLong(ispec256, lspec128, iin256, lout128);
3644         testVectorUCastIntToLong(ispec512, lspec256, iin512, lout256);
3645 
3646         testVectorUCastIntToLong(ispec256, lspec64, iin256, lout64);
3647         testVectorUCastIntToLong(ispec512, lspec128, iin512, lout128);
3648 
3649         testVectorUCastIntToLong(ispec512, lspec64, iin512, lout64);
3650 
3651         // I2L contraction
3652         testVectorUCastIntToLong(ispec64, lspec256, iin64, lout256);
3653         testVectorUCastIntToLong(ispec128, lspec512, iin128, lout512);
3654 
3655         testVectorUCastIntToLong(ispec64, lspec512, iin64, lout512);
3656     }
3657 
3658     static
3659     void testVectorCastByteMaxToByte(VectorSpecies<Byte> a, VectorSpecies<Byte> b,
3660                                           byte[] input, byte[] output) {
3661         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3662             testVectorCastByteToByte(a, b, input, output);
3663         } else {
3664             testVectorCastByteToByteFail(a, b, input);
3665         }
3666     }
3667 
3668     static
3669     void testVectorCastByteMaxToShort(VectorSpecies<Byte> a, VectorSpecies<Short> b,
3670                                            byte[] input, short[] output) {
3671         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3672             testVectorCastByteToShort(a, b, input, output);
3673         } else {
3674             testVectorCastByteToShortFail(a, b, input);
3675         }
3676     }
3677 
3678     static
3679     void testVectorCastByteMaxToInt(VectorSpecies<Byte> a, VectorSpecies<Integer> b,
3680                                          byte[] input, int[] output) {
3681         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3682             testVectorCastByteToInt(a, b, input, output);
3683         } else {
3684             testVectorCastByteToIntFail(a, b, input);
3685         }
3686     }
3687 
3688     static
3689     void testVectorCastByteMaxToLong(VectorSpecies<Byte> a, VectorSpecies<Long> b,
3690                                           byte[] input, long[] output) {
3691         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3692             testVectorCastByteToLong(a, b, input, output);
3693         } else {
3694             testVectorCastByteToLongFail(a, b, input);
3695         }
3696     }
3697 
3698     static
3699     void testVectorCastByteMaxToFloat(VectorSpecies<Byte> a, VectorSpecies<Float> b,
3700                                            byte[] input, float[] output) {
3701         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3702             testVectorCastByteToFloat(a, b, input, output);
3703         } else {
3704             testVectorCastByteToFloatFail(a, b, input);
3705         }
3706     }
3707 
3708     static
3709     void testVectorCastByteMaxToDouble(VectorSpecies<Byte> a, VectorSpecies<Double> b,
3710                                             byte[] input, double[] output) {
3711         if (S_Max_BIT.vectorBitSize() == b.length() * Byte.SIZE) {
3712             testVectorCastByteToDouble(a, b, input, output);
3713         } else {
3714             testVectorCastByteToDoubleFail(a, b, input);
3715         }
3716     }
3717 
3718     static
3719     void testVectorCastShortMaxToByte(VectorSpecies<Short> a, VectorSpecies<Byte> b,
3720                                            short[] input, byte[] output) {
3721         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3722             testVectorCastShortToByte(a, b, input, output);
3723         } else {
3724             testVectorCastShortToByteFail(a, b, input);
3725         }
3726     }
3727 
3728     static
3729     void testVectorCastShortMaxToShort(VectorSpecies<Short> a, VectorSpecies<Short> b,
3730                                             short[] input, short[] output) {
3731         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3732             testVectorCastShortToShort(a, b, input, output);
3733         } else {
3734             testVectorCastShortToShortFail(a, b, input);
3735         }
3736     }
3737 
3738     static
3739     void testVectorCastShortMaxToInt(VectorSpecies<Short> a, VectorSpecies<Integer> b,
3740                                           short[] input, int[] output) {
3741         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3742             testVectorCastShortToInt(a, b, input, output);
3743         } else {
3744             testVectorCastShortToIntFail(a, b, input);
3745         }
3746     }
3747 
3748     static
3749     void testVectorCastShortMaxToLong(VectorSpecies<Short> a, VectorSpecies<Long> b,
3750                                            short[] input, long[] output) {
3751         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3752             testVectorCastShortToLong(a, b, input, output);
3753         } else {
3754             testVectorCastShortToLongFail(a, b, input);
3755         }
3756     }
3757 
3758     static
3759     void testVectorCastShortMaxToFloat(VectorSpecies<Short> a, VectorSpecies<Float> b,
3760                                             short[] input, float[] output) {
3761         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3762             testVectorCastShortToFloat(a, b, input, output);
3763         } else {
3764             testVectorCastShortToFloatFail(a, b, input);
3765         }
3766     }
3767 
3768     static
3769     void testVectorCastShortMaxToDouble(VectorSpecies<Short> a, VectorSpecies<Double> b,
3770                                              short[] input, double[] output) {
3771         if (S_Max_BIT.vectorBitSize() == b.length() * Short.SIZE) {
3772             testVectorCastShortToDouble(a, b, input, output);
3773         } else {
3774             testVectorCastShortToDoubleFail(a, b, input);
3775         }
3776     }
3777 
3778     static
3779     void testVectorCastIntMaxToByte(VectorSpecies<Integer> a, VectorSpecies<Byte> b,
3780                                          int[] input, byte[] output) {
3781         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3782             testVectorCastIntToByte(a, b, input, output);
3783         } else {
3784             testVectorCastIntToByteFail(a, b, input);
3785         }
3786     }
3787 
3788     static
3789     void testVectorCastIntMaxToShort(VectorSpecies<Integer> a, VectorSpecies<Short> b,
3790                                           int[] input, short[] output) {
3791         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3792             testVectorCastIntToShort(a, b, input, output);
3793         } else {
3794             testVectorCastIntToShortFail(a, b, input);
3795         }
3796     }
3797 
3798     static
3799     void testVectorCastIntMaxToInt(VectorSpecies<Integer> a, VectorSpecies<Integer> b,
3800                                         int[] input, int[] output) {
3801         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3802             testVectorCastIntToInt(a, b, input, output);
3803         } else {
3804             testVectorCastIntToIntFail(a, b, input);
3805         }
3806     }
3807 
3808     static
3809     void testVectorCastIntMaxToLong(VectorSpecies<Integer> a, VectorSpecies<Long> b,
3810                                          int[] input, long[] output) {
3811         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3812             testVectorCastIntToLong(a, b, input, output);
3813         } else {
3814             testVectorCastIntToLongFail(a, b, input);
3815         }
3816     }
3817 
3818     static
3819     void testVectorCastIntMaxToFloat(VectorSpecies<Integer> a, VectorSpecies<Float> b,
3820                                           int[] input, float[] output) {
3821         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3822             testVectorCastIntToFloat(a, b, input, output);
3823         } else {
3824             testVectorCastIntToFloatFail(a, b, input);
3825         }
3826     }
3827 
3828     static
3829     void testVectorCastIntMaxToDouble(VectorSpecies<Integer> a, VectorSpecies<Double> b,
3830                                            int[] input, double[] output) {
3831         if (S_Max_BIT.vectorBitSize() == b.length() * Integer.SIZE) {
3832             testVectorCastIntToDouble(a, b, input, output);
3833         } else {
3834             testVectorCastIntToDoubleFail(a, b, input);
3835         }
3836     }
3837 
3838     static
3839     void testVectorCastLongMaxToByte(VectorSpecies<Long> a, VectorSpecies<Byte> b,
3840                                           long[] input, byte[] output) {
3841         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3842             testVectorCastLongToByte(a, b, input, output);
3843         } else {
3844             testVectorCastLongToByteFail(a, b, input);
3845         }
3846     }
3847 
3848     static
3849     void testVectorCastLongMaxToShort(VectorSpecies<Long> a, VectorSpecies<Short> b,
3850                                            long[] input, short[] output) {
3851         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3852             testVectorCastLongToShort(a, b, input, output);
3853         } else {
3854             testVectorCastLongToShortFail(a, b, input);
3855         }
3856     }
3857 
3858     static
3859     void testVectorCastLongMaxToInt(VectorSpecies<Long> a, VectorSpecies<Integer> b,
3860                                          long[] input, int[] output) {
3861         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3862             testVectorCastLongToInt(a, b, input, output);
3863         } else {
3864             testVectorCastLongToIntFail(a, b, input);
3865         }
3866     }
3867 
3868     static
3869     void testVectorCastLongMaxToLong(VectorSpecies<Long> a, VectorSpecies<Long> b,
3870                                           long[] input, long[] output) {
3871         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3872             testVectorCastLongToLong(a, b, input, output);
3873         } else {
3874             testVectorCastLongToLongFail(a, b, input);
3875         }
3876     }
3877 
3878     static
3879     void testVectorCastLongMaxToFloat(VectorSpecies<Long> a, VectorSpecies<Float> b,
3880                                            long[] input, float[] output) {
3881         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3882             testVectorCastLongToFloat(a, b, input, output);
3883         } else {
3884             testVectorCastLongToFloatFail(a, b, input);
3885         }
3886     }
3887 
3888     static
3889     void testVectorCastLongMaxToDouble(VectorSpecies<Long> a, VectorSpecies<Double> b,
3890                                             long[] input, double[] output) {
3891         if (S_Max_BIT.vectorBitSize() == b.length() * Long.SIZE) {
3892             testVectorCastLongToDouble(a, b, input, output);
3893         } else {
3894             testVectorCastLongToDoubleFail(a, b, input);
3895         }
3896     }
3897 
3898     static
3899     void testVectorCastFloatMaxToByte(VectorSpecies<Float> a, VectorSpecies<Byte> b,
3900                                            float[] input, byte[] output) {
3901         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3902             testVectorCastFloatToByte(a, b, input, output);
3903         } else {
3904             testVectorCastFloatToByteFail(a, b, input);
3905         }
3906     }
3907 
3908     static
3909     void testVectorCastFloatMaxToShort(VectorSpecies<Float> a, VectorSpecies<Short> b,
3910                                             float[] input, short[] output) {
3911         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3912             testVectorCastFloatToShort(a, b, input, output);
3913         } else {
3914             testVectorCastFloatToShortFail(a, b, input);
3915         }
3916     }
3917 
3918     static
3919     void testVectorCastFloatMaxToInt(VectorSpecies<Float> a, VectorSpecies<Integer> b,
3920                                           float[] input, int[] output) {
3921         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3922             testVectorCastFloatToInt(a, b, input, output);
3923         } else {
3924             testVectorCastFloatToIntFail(a, b, input);
3925         }
3926     }
3927 
3928     static
3929     void testVectorCastFloatMaxToLong(VectorSpecies<Float> a, VectorSpecies<Long> b,
3930                                            float[] input, long[] output) {
3931         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3932             testVectorCastFloatToLong(a, b, input, output);
3933         } else {
3934             testVectorCastFloatToLongFail(a, b, input);
3935         }
3936     }
3937 
3938     static
3939     void testVectorCastFloatMaxToFloat(VectorSpecies<Float> a, VectorSpecies<Float> b,
3940                                             float[] input, float[] output) {
3941         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3942             testVectorCastFloatToFloat(a, b, input, output);
3943         } else {
3944             testVectorCastFloatToFloatFail(a, b, input);
3945         }
3946     }
3947 
3948     static
3949     void testVectorCastFloatMaxToDouble(VectorSpecies<Float> a, VectorSpecies<Double> b,
3950                                              float[] input, double[] output) {
3951         if (S_Max_BIT.vectorBitSize() == b.length() * Float.SIZE) {
3952             testVectorCastFloatToDouble(a, b, input, output);
3953         } else {
3954             testVectorCastFloatToDoubleFail(a, b, input);
3955         }
3956     }
3957 
3958     static
3959     void testVectorCastDoubleMaxToByte(VectorSpecies<Double> a, VectorSpecies<Byte> b,
3960                                             double[] input, byte[] output) {
3961         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
3962             testVectorCastDoubleToByte(a, b, input, output);
3963         } else {
3964             testVectorCastDoubleToByteFail(a, b, input);
3965         }
3966     }
3967 
3968     static
3969     void testVectorCastDoubleMaxToShort(VectorSpecies<Double> a, VectorSpecies<Short> b,
3970                                              double[] input, short[] output) {
3971         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
3972             testVectorCastDoubleToShort(a, b, input, output);
3973         } else {
3974             testVectorCastDoubleToShortFail(a, b, input);
3975         }
3976     }
3977 
3978     static
3979     void testVectorCastDoubleMaxToInt(VectorSpecies<Double> a, VectorSpecies<Integer> b,
3980                                            double[] input, int[] output) {
3981         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
3982             testVectorCastDoubleToInt(a, b, input, output);
3983         } else {
3984             testVectorCastDoubleToIntFail(a, b, input);
3985         }
3986     }
3987 
3988     static
3989     void testVectorCastDoubleMaxToLong(VectorSpecies<Double> a, VectorSpecies<Long> b,
3990                                             double[] input, long[] output) {
3991         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
3992             testVectorCastDoubleToLong(a, b, input, output);
3993         } else {
3994             testVectorCastDoubleToLongFail(a, b, input);
3995         }
3996     }
3997 
3998     static
3999     void testVectorCastDoubleMaxToFloat(VectorSpecies<Double> a, VectorSpecies<Float> b,
4000                                              double[] input, float[] output) {
4001         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
4002             testVectorCastDoubleToFloat(a, b, input, output);
4003         } else {
4004             testVectorCastDoubleToFloatFail(a, b, input);
4005         }
4006     }
4007 
4008     static
4009     void testVectorCastDoubleMaxToDouble(VectorSpecies<Double> a, VectorSpecies<Double> b,
4010                                               double[] input, double[] output) {
4011         if (S_Max_BIT.vectorBitSize() == b.length() * Double.SIZE) {
4012             testVectorCastDoubleToDouble(a, b, input, output);
4013         } else {
4014             testVectorCastDoubleToDoubleFail(a, b, input);
4015         }
4016     }
4017 
4018     //@Test(dataProvider = "byteUnaryOpProvider")
4019     static void testCastFromByteMax(IntFunction<byte[]> fa) {
4020         byte[] binMax = fa.apply(bspecMax.length());
4021 
4022         byte[] bout64 = new byte[bspec64.length()];
4023         byte[] bout128 = new byte[bspec128.length()];
4024         byte[] bout256 = new byte[bspec256.length()];
4025         byte[] bout512 = new byte[bspec512.length()];
4026         byte[] boutMax = new byte[bspecMax.length()];
4027 
4028         short[] sout64 = new short[sspec64.length()];
4029         short[] sout128 = new short[sspec128.length()];
4030         short[] sout256 = new short[sspec256.length()];
4031         short[] sout512 = new short[sspec512.length()];
4032         short[] soutMax = new short[sspecMax.length()];
4033 
4034         int[] iout64 = new int[ispec64.length()];
4035         int[] iout128 = new int[ispec128.length()];
4036         int[] iout256 = new int[ispec256.length()];
4037         int[] iout512 = new int[ispec512.length()];
4038         int[] ioutMax = new int[ispecMax.length()];
4039 
4040         long[] lout64 = new long[lspec64.length()];
4041         long[] lout128 = new long[lspec128.length()];
4042         long[] lout256 = new long[lspec256.length()];
4043         long[] lout512 = new long[lspec512.length()];
4044         long[] loutMax = new long[lspecMax.length()];
4045 
4046         float[] fout64 = new float[fspec64.length()];
4047         float[] fout128 = new float[fspec128.length()];
4048         float[] fout256 = new float[fspec256.length()];
4049         float[] fout512 = new float[fspec512.length()];
4050         float[] foutMax = new float[fspecMax.length()];
4051 
4052         double[] dout64 = new double[dspec64.length()];
4053         double[] dout128 = new double[dspec128.length()];
4054         double[] dout256 = new double[dspec256.length()];
4055         double[] dout512 = new double[dspec512.length()];
4056         double[] doutMax = new double[dspecMax.length()];
4057 
4058         for (int i = 0; i < NUM_ITER; i++) {
4059             testVectorCastByteMaxToByte(bspecMax, bspec64, binMax, bout64);
4060             testVectorCastByteMaxToByte(bspecMax, bspec128, binMax, bout128);
4061             testVectorCastByteMaxToByte(bspecMax, bspec256, binMax, bout256);
4062             testVectorCastByteMaxToByte(bspecMax, bspec512, binMax, bout512);
4063             testVectorCastByteMaxToByte(bspecMax, bspecMax, binMax, boutMax);
4064 
4065             testVectorCastByteMaxToShort(bspecMax, sspec64, binMax, sout64);
4066             testVectorCastByteMaxToShort(bspecMax, sspec128, binMax, sout128);
4067             testVectorCastByteMaxToShort(bspecMax, sspec256, binMax, sout256);
4068             testVectorCastByteMaxToShort(bspecMax, sspec512, binMax, sout512);
4069             testVectorCastByteMaxToShort(bspecMax, sspecMax, binMax, soutMax);
4070 
4071             testVectorCastByteMaxToInt(bspecMax, ispec64, binMax, iout64);
4072             testVectorCastByteMaxToInt(bspecMax, ispec128, binMax, iout128);
4073             testVectorCastByteMaxToInt(bspecMax, ispec256, binMax, iout256);
4074             testVectorCastByteMaxToInt(bspecMax, ispec512, binMax, iout512);
4075             testVectorCastByteMaxToInt(bspecMax, ispecMax, binMax, ioutMax);
4076 
4077             testVectorCastByteMaxToLong(bspecMax, lspec64, binMax, lout64);
4078             testVectorCastByteMaxToLong(bspecMax, lspec128, binMax, lout128);
4079             testVectorCastByteMaxToLong(bspecMax, lspec256, binMax, lout256);
4080             testVectorCastByteMaxToLong(bspecMax, lspec512, binMax, lout512);
4081             testVectorCastByteMaxToLong(bspecMax, lspecMax, binMax, loutMax);
4082 
4083             testVectorCastByteMaxToFloat(bspecMax, fspec64, binMax, fout64);
4084             testVectorCastByteMaxToFloat(bspecMax, fspec128, binMax, fout128);
4085             testVectorCastByteMaxToFloat(bspecMax, fspec256, binMax, fout256);
4086             testVectorCastByteMaxToFloat(bspecMax, fspec512, binMax, fout512);
4087             testVectorCastByteMaxToFloat(bspecMax, fspecMax, binMax, foutMax);
4088 
4089             testVectorCastByteMaxToDouble(bspecMax, dspec64, binMax, dout64);
4090             testVectorCastByteMaxToDouble(bspecMax, dspec128, binMax, dout128);
4091             testVectorCastByteMaxToDouble(bspecMax, dspec256, binMax, dout256);
4092             testVectorCastByteMaxToDouble(bspecMax, dspec512, binMax, dout512);
4093             testVectorCastByteMaxToDouble(bspecMax, dspecMax, binMax, doutMax);
4094         }
4095     }
4096 
4097     //@Test(dataProvider = "shortUnaryOpProvider")
4098     static void testCastFromShortMax(IntFunction<short[]> fa) {
4099         short[] sinMax = fa.apply(sspecMax.length());
4100 
4101         byte[] bout64 = new byte[bspec64.length()];
4102         byte[] bout128 = new byte[bspec128.length()];
4103         byte[] bout256 = new byte[bspec256.length()];
4104         byte[] bout512 = new byte[bspec512.length()];
4105         byte[] boutMax = new byte[bspecMax.length()];
4106 
4107         short[] sout64 = new short[sspec64.length()];
4108         short[] sout128 = new short[sspec128.length()];
4109         short[] sout256 = new short[sspec256.length()];
4110         short[] sout512 = new short[sspec512.length()];
4111         short[] soutMax = new short[sspecMax.length()];
4112 
4113         int[] iout64 = new int[ispec64.length()];
4114         int[] iout128 = new int[ispec128.length()];
4115         int[] iout256 = new int[ispec256.length()];
4116         int[] iout512 = new int[ispec512.length()];
4117         int[] ioutMax = new int[ispecMax.length()];
4118 
4119         long[] lout64 = new long[lspec64.length()];
4120         long[] lout128 = new long[lspec128.length()];
4121         long[] lout256 = new long[lspec256.length()];
4122         long[] lout512 = new long[lspec512.length()];
4123         long[] loutMax = new long[lspecMax.length()];
4124 
4125         float[] fout64 = new float[fspec64.length()];
4126         float[] fout128 = new float[fspec128.length()];
4127         float[] fout256 = new float[fspec256.length()];
4128         float[] fout512 = new float[fspec512.length()];
4129         float[] foutMax = new float[fspecMax.length()];
4130 
4131         double[] dout64 = new double[dspec64.length()];
4132         double[] dout128 = new double[dspec128.length()];
4133         double[] dout256 = new double[dspec256.length()];
4134         double[] dout512 = new double[dspec512.length()];
4135         double[] doutMax = new double[dspecMax.length()];
4136 
4137         for (int i = 0; i < NUM_ITER; i++) {
4138             testVectorCastShortMaxToByte(sspecMax, bspec64, sinMax, bout64);
4139             testVectorCastShortMaxToByte(sspecMax, bspec128, sinMax, bout128);
4140             testVectorCastShortMaxToByte(sspecMax, bspec256, sinMax, bout256);
4141             testVectorCastShortMaxToByte(sspecMax, bspec512, sinMax, bout512);
4142             testVectorCastShortMaxToByte(sspecMax, bspecMax, sinMax, boutMax);
4143 
4144             testVectorCastShortMaxToShort(sspecMax, sspec64, sinMax, sout64);
4145             testVectorCastShortMaxToShort(sspecMax, sspec128, sinMax, sout128);
4146             testVectorCastShortMaxToShort(sspecMax, sspec256, sinMax, sout256);
4147             testVectorCastShortMaxToShort(sspecMax, sspec512, sinMax, sout512);
4148             testVectorCastShortMaxToShort(sspecMax, sspecMax, sinMax, soutMax);
4149 
4150             testVectorCastShortMaxToInt(sspecMax, ispec64, sinMax, iout64);
4151             testVectorCastShortMaxToInt(sspecMax, ispec128, sinMax, iout128);
4152             testVectorCastShortMaxToInt(sspecMax, ispec256, sinMax, iout256);
4153             testVectorCastShortMaxToInt(sspecMax, ispec512, sinMax, iout512);
4154             testVectorCastShortMaxToInt(sspecMax, ispecMax, sinMax, ioutMax);
4155 
4156             testVectorCastShortMaxToLong(sspecMax, lspec64, sinMax, lout64);
4157             testVectorCastShortMaxToLong(sspecMax, lspec128, sinMax, lout128);
4158             testVectorCastShortMaxToLong(sspecMax, lspec256, sinMax, lout256);
4159             testVectorCastShortMaxToLong(sspecMax, lspec512, sinMax, lout512);
4160             testVectorCastShortMaxToLong(sspecMax, lspecMax, sinMax, loutMax);
4161 
4162             testVectorCastShortMaxToFloat(sspecMax, fspec64, sinMax, fout64);
4163             testVectorCastShortMaxToFloat(sspecMax, fspec128, sinMax, fout128);
4164             testVectorCastShortMaxToFloat(sspecMax, fspec256, sinMax, fout256);
4165             testVectorCastShortMaxToFloat(sspecMax, fspec512, sinMax, fout512);
4166             testVectorCastShortMaxToFloat(sspecMax, fspecMax, sinMax, foutMax);
4167 
4168             testVectorCastShortMaxToDouble(sspecMax, dspec64, sinMax, dout64);
4169             testVectorCastShortMaxToDouble(sspecMax, dspec128, sinMax, dout128);
4170             testVectorCastShortMaxToDouble(sspecMax, dspec256, sinMax, dout256);
4171             testVectorCastShortMaxToDouble(sspecMax, dspec512, sinMax, dout512);
4172             testVectorCastShortMaxToDouble(sspecMax, dspecMax, sinMax, doutMax);
4173         }
4174     }
4175 
4176     //@Test(dataProvider = "intUnaryOpProvider")
4177     static void testCastFromIntMax(IntFunction<int[]> fa) {
4178         int[] iinMax = fa.apply(ispecMax.length());
4179 
4180         byte[] bout64 = new byte[bspec64.length()];
4181         byte[] bout128 = new byte[bspec128.length()];
4182         byte[] bout256 = new byte[bspec256.length()];
4183         byte[] bout512 = new byte[bspec512.length()];
4184         byte[] boutMax = new byte[bspecMax.length()];
4185 
4186         short[] sout64 = new short[sspec64.length()];
4187         short[] sout128 = new short[sspec128.length()];
4188         short[] sout256 = new short[sspec256.length()];
4189         short[] sout512 = new short[sspec512.length()];
4190         short[] soutMax = new short[sspecMax.length()];
4191 
4192         int[] iout64 = new int[ispec64.length()];
4193         int[] iout128 = new int[ispec128.length()];
4194         int[] iout256 = new int[ispec256.length()];
4195         int[] iout512 = new int[ispec512.length()];
4196         int[] ioutMax = new int[ispecMax.length()];
4197 
4198         long[] lout64 = new long[lspec64.length()];
4199         long[] lout128 = new long[lspec128.length()];
4200         long[] lout256 = new long[lspec256.length()];
4201         long[] lout512 = new long[lspec512.length()];
4202         long[] loutMax = new long[lspecMax.length()];
4203 
4204         float[] fout64 = new float[fspec64.length()];
4205         float[] fout128 = new float[fspec128.length()];
4206         float[] fout256 = new float[fspec256.length()];
4207         float[] fout512 = new float[fspec512.length()];
4208         float[] foutMax = new float[fspecMax.length()];
4209 
4210         double[] dout64 = new double[dspec64.length()];
4211         double[] dout128 = new double[dspec128.length()];
4212         double[] dout256 = new double[dspec256.length()];
4213         double[] dout512 = new double[dspec512.length()];
4214         double[] doutMax = new double[dspecMax.length()];
4215 
4216         for (int i = 0; i < NUM_ITER; i++) {
4217             testVectorCastIntMaxToByte(ispecMax, bspec64, iinMax, bout64);
4218             testVectorCastIntMaxToByte(ispecMax, bspec128, iinMax, bout128);
4219             testVectorCastIntMaxToByte(ispecMax, bspec256, iinMax, bout256);
4220             testVectorCastIntMaxToByte(ispecMax, bspec512, iinMax, bout512);
4221             testVectorCastIntMaxToByte(ispecMax, bspecMax, iinMax, boutMax);
4222 
4223             testVectorCastIntMaxToShort(ispecMax, sspec64, iinMax, sout64);
4224             testVectorCastIntMaxToShort(ispecMax, sspec128, iinMax, sout128);
4225             testVectorCastIntMaxToShort(ispecMax, sspec256, iinMax, sout256);
4226             testVectorCastIntMaxToShort(ispecMax, sspec512, iinMax, sout512);
4227             testVectorCastIntMaxToShort(ispecMax, sspecMax, iinMax, soutMax);
4228 
4229             testVectorCastIntMaxToInt(ispecMax, ispec64, iinMax, iout64);
4230             testVectorCastIntMaxToInt(ispecMax, ispec128, iinMax, iout128);
4231             testVectorCastIntMaxToInt(ispecMax, ispec256, iinMax, iout256);
4232             testVectorCastIntMaxToInt(ispecMax, ispec512, iinMax, iout512);
4233             testVectorCastIntMaxToInt(ispecMax, ispecMax, iinMax, ioutMax);
4234 
4235             testVectorCastIntMaxToLong(ispecMax, lspec64, iinMax, lout64);
4236             testVectorCastIntMaxToLong(ispecMax, lspec128, iinMax, lout128);
4237             testVectorCastIntMaxToLong(ispecMax, lspec256, iinMax, lout256);
4238             testVectorCastIntMaxToLong(ispecMax, lspec512, iinMax, lout512);
4239             testVectorCastIntMaxToLong(ispecMax, lspecMax, iinMax, loutMax);
4240 
4241             testVectorCastIntMaxToFloat(ispecMax, fspec64, iinMax, fout64);
4242             testVectorCastIntMaxToFloat(ispecMax, fspec128, iinMax, fout128);
4243             testVectorCastIntMaxToFloat(ispecMax, fspec256, iinMax, fout256);
4244             testVectorCastIntMaxToFloat(ispecMax, fspec512, iinMax, fout512);
4245             testVectorCastIntMaxToFloat(ispecMax, fspecMax, iinMax, foutMax);
4246 
4247             testVectorCastIntMaxToDouble(ispecMax, dspec64, iinMax, dout64);
4248             testVectorCastIntMaxToDouble(ispecMax, dspec128, iinMax, dout128);
4249             testVectorCastIntMaxToDouble(ispecMax, dspec256, iinMax, dout256);
4250             testVectorCastIntMaxToDouble(ispecMax, dspec512, iinMax, dout512);
4251             testVectorCastIntMaxToDouble(ispecMax, dspecMax, iinMax, doutMax);
4252         }
4253     }
4254 
4255     //@Test(dataProvider = "longUnaryOpProvider")
4256     static void testCastFromLongMax(IntFunction<long[]> fa) {
4257         long[] linMax = fa.apply(lspecMax.length());
4258 
4259         byte[] bout64 = new byte[bspec64.length()];
4260         byte[] bout128 = new byte[bspec128.length()];
4261         byte[] bout256 = new byte[bspec256.length()];
4262         byte[] bout512 = new byte[bspec512.length()];
4263         byte[] boutMax = new byte[bspecMax.length()];
4264 
4265         short[] sout64 = new short[sspec64.length()];
4266         short[] sout128 = new short[sspec128.length()];
4267         short[] sout256 = new short[sspec256.length()];
4268         short[] sout512 = new short[sspec512.length()];
4269         short[] soutMax = new short[sspecMax.length()];
4270 
4271         int[] iout64 = new int[ispec64.length()];
4272         int[] iout128 = new int[ispec128.length()];
4273         int[] iout256 = new int[ispec256.length()];
4274         int[] iout512 = new int[ispec512.length()];
4275         int[] ioutMax = new int[ispecMax.length()];
4276 
4277         long[] lout64 = new long[lspec64.length()];
4278         long[] lout128 = new long[lspec128.length()];
4279         long[] lout256 = new long[lspec256.length()];
4280         long[] lout512 = new long[lspec512.length()];
4281         long[] loutMax = new long[lspecMax.length()];
4282 
4283         float[] fout64 = new float[fspec64.length()];
4284         float[] fout128 = new float[fspec128.length()];
4285         float[] fout256 = new float[fspec256.length()];
4286         float[] fout512 = new float[fspec512.length()];
4287         float[] foutMax = new float[fspecMax.length()];
4288 
4289         double[] dout64 = new double[dspec64.length()];
4290         double[] dout128 = new double[dspec128.length()];
4291         double[] dout256 = new double[dspec256.length()];
4292         double[] dout512 = new double[dspec512.length()];
4293         double[] doutMax = new double[dspecMax.length()];
4294 
4295         for (int i = 0; i < NUM_ITER; i++) {
4296             testVectorCastLongMaxToByte(lspecMax, bspec64, linMax, bout64);
4297             testVectorCastLongMaxToByte(lspecMax, bspec128, linMax, bout128);
4298             testVectorCastLongMaxToByte(lspecMax, bspec256, linMax, bout256);
4299             testVectorCastLongMaxToByte(lspecMax, bspec512, linMax, bout512);
4300             testVectorCastLongMaxToByte(lspecMax, bspecMax, linMax, boutMax);
4301 
4302             testVectorCastLongMaxToShort(lspecMax, sspec64, linMax, sout64);
4303             testVectorCastLongMaxToShort(lspecMax, sspec128, linMax, sout128);
4304             testVectorCastLongMaxToShort(lspecMax, sspec256, linMax, sout256);
4305             testVectorCastLongMaxToShort(lspecMax, sspec512, linMax, sout512);
4306             testVectorCastLongMaxToShort(lspecMax, sspecMax, linMax, soutMax);
4307 
4308             testVectorCastLongMaxToInt(lspecMax, ispec64, linMax, iout64);
4309             testVectorCastLongMaxToInt(lspecMax, ispec128, linMax, iout128);
4310             testVectorCastLongMaxToInt(lspecMax, ispec256, linMax, iout256);
4311             testVectorCastLongMaxToInt(lspecMax, ispec512, linMax, iout512);
4312             testVectorCastLongMaxToInt(lspecMax, ispecMax, linMax, ioutMax);
4313 
4314             testVectorCastLongMaxToLong(lspecMax, lspec64, linMax, lout64);
4315             testVectorCastLongMaxToLong(lspecMax, lspec128, linMax, lout128);
4316             testVectorCastLongMaxToLong(lspecMax, lspec256, linMax, lout256);
4317             testVectorCastLongMaxToLong(lspecMax, lspec512, linMax, lout512);
4318             testVectorCastLongMaxToLong(lspecMax, lspecMax, linMax, loutMax);
4319 
4320             testVectorCastLongMaxToFloat(lspecMax, fspec64, linMax, fout64);
4321             testVectorCastLongMaxToFloat(lspecMax, fspec128, linMax, fout128);
4322             testVectorCastLongMaxToFloat(lspecMax, fspec256, linMax, fout256);
4323             testVectorCastLongMaxToFloat(lspecMax, fspec512, linMax, fout512);
4324             testVectorCastLongMaxToFloat(lspecMax, fspecMax, linMax, foutMax);
4325 
4326             testVectorCastLongMaxToDouble(lspecMax, dspec64, linMax, dout64);
4327             testVectorCastLongMaxToDouble(lspecMax, dspec128, linMax, dout128);
4328             testVectorCastLongMaxToDouble(lspecMax, dspec256, linMax, dout256);
4329             testVectorCastLongMaxToDouble(lspecMax, dspec512, linMax, dout512);
4330             testVectorCastLongMaxToDouble(lspecMax, dspecMax, linMax, doutMax);
4331         }
4332     }
4333 
4334     //@Test(dataProvider = "floatUnaryOpProvider")
4335     static void testCastFromFloatMax(IntFunction<float[]> fa) {
4336         float[] finMax = fa.apply(fspecMax.length());
4337 
4338         byte[] bout64 = new byte[bspec64.length()];
4339         byte[] bout128 = new byte[bspec128.length()];
4340         byte[] bout256 = new byte[bspec256.length()];
4341         byte[] bout512 = new byte[bspec512.length()];
4342         byte[] boutMax = new byte[bspecMax.length()];
4343 
4344         short[] sout64 = new short[sspec64.length()];
4345         short[] sout128 = new short[sspec128.length()];
4346         short[] sout256 = new short[sspec256.length()];
4347         short[] sout512 = new short[sspec512.length()];
4348         short[] soutMax = new short[sspecMax.length()];
4349 
4350         int[] iout64 = new int[ispec64.length()];
4351         int[] iout128 = new int[ispec128.length()];
4352         int[] iout256 = new int[ispec256.length()];
4353         int[] iout512 = new int[ispec512.length()];
4354         int[] ioutMax = new int[ispecMax.length()];
4355 
4356         long[] lout64 = new long[lspec64.length()];
4357         long[] lout128 = new long[lspec128.length()];
4358         long[] lout256 = new long[lspec256.length()];
4359         long[] lout512 = new long[lspec512.length()];
4360         long[] loutMax = new long[lspecMax.length()];
4361 
4362         float[] fout64 = new float[fspec64.length()];
4363         float[] fout128 = new float[fspec128.length()];
4364         float[] fout256 = new float[fspec256.length()];
4365         float[] fout512 = new float[fspec512.length()];
4366         float[] foutMax = new float[fspecMax.length()];
4367 
4368         double[] dout64 = new double[dspec64.length()];
4369         double[] dout128 = new double[dspec128.length()];
4370         double[] dout256 = new double[dspec256.length()];
4371         double[] dout512 = new double[dspec512.length()];
4372         double[] doutMax = new double[dspecMax.length()];
4373 
4374         for (int i = 0; i < NUM_ITER; i++) {
4375             testVectorCastFloatMaxToByte(fspecMax, bspec64, finMax, bout64);
4376             testVectorCastFloatMaxToByte(fspecMax, bspec128, finMax, bout128);
4377             testVectorCastFloatMaxToByte(fspecMax, bspec256, finMax, bout256);
4378             testVectorCastFloatMaxToByte(fspecMax, bspec512, finMax, bout512);
4379             testVectorCastFloatMaxToByte(fspecMax, bspecMax, finMax, boutMax);
4380 
4381             testVectorCastFloatMaxToShort(fspecMax, sspec64, finMax, sout64);
4382             testVectorCastFloatMaxToShort(fspecMax, sspec128, finMax, sout128);
4383             testVectorCastFloatMaxToShort(fspecMax, sspec256, finMax, sout256);
4384             testVectorCastFloatMaxToShort(fspecMax, sspec512, finMax, sout512);
4385             testVectorCastFloatMaxToShort(fspecMax, sspecMax, finMax, soutMax);
4386 
4387             testVectorCastFloatMaxToInt(fspecMax, ispec64, finMax, iout64);
4388             testVectorCastFloatMaxToInt(fspecMax, ispec128, finMax, iout128);
4389             testVectorCastFloatMaxToInt(fspecMax, ispec256, finMax, iout256);
4390             testVectorCastFloatMaxToInt(fspecMax, ispec512, finMax, iout512);
4391             testVectorCastFloatMaxToInt(fspecMax, ispecMax, finMax, ioutMax);
4392 
4393             testVectorCastFloatMaxToLong(fspecMax, lspec64, finMax, lout64);
4394             testVectorCastFloatMaxToLong(fspecMax, lspec128, finMax, lout128);
4395             testVectorCastFloatMaxToLong(fspecMax, lspec256, finMax, lout256);
4396             testVectorCastFloatMaxToLong(fspecMax, lspec512, finMax, lout512);
4397             testVectorCastFloatMaxToLong(fspecMax, lspecMax, finMax, loutMax);
4398 
4399             testVectorCastFloatMaxToFloat(fspecMax, fspec64, finMax, fout64);
4400             testVectorCastFloatMaxToFloat(fspecMax, fspec128, finMax, fout128);
4401             testVectorCastFloatMaxToFloat(fspecMax, fspec256, finMax, fout256);
4402             testVectorCastFloatMaxToFloat(fspecMax, fspec512, finMax, fout512);
4403             testVectorCastFloatMaxToFloat(fspecMax, fspecMax, finMax, foutMax);
4404 
4405             testVectorCastFloatMaxToDouble(fspecMax, dspec64, finMax, dout64);
4406             testVectorCastFloatMaxToDouble(fspecMax, dspec128, finMax, dout128);
4407             testVectorCastFloatMaxToDouble(fspecMax, dspec256, finMax, dout256);
4408             testVectorCastFloatMaxToDouble(fspecMax, dspec512, finMax, dout512);
4409             testVectorCastFloatMaxToDouble(fspecMax, dspecMax, finMax, doutMax);
4410         }
4411     }
4412 
4413     //@Test(dataProvider = "doubleUnaryOpProvider")
4414     static void testCastFromDoubleMax(IntFunction<double[]> fa) {
4415         double[] dinMax = fa.apply(dspecMax.length());
4416 
4417         byte[] bout64 = new byte[bspec64.length()];
4418         byte[] bout128 = new byte[bspec128.length()];
4419         byte[] bout256 = new byte[bspec256.length()];
4420         byte[] bout512 = new byte[bspec512.length()];
4421         byte[] boutMax = new byte[bspecMax.length()];
4422 
4423         short[] sout64 = new short[sspec64.length()];
4424         short[] sout128 = new short[sspec128.length()];
4425         short[] sout256 = new short[sspec256.length()];
4426         short[] sout512 = new short[sspec512.length()];
4427         short[] soutMax = new short[sspecMax.length()];
4428 
4429         int[] iout64 = new int[ispec64.length()];
4430         int[] iout128 = new int[ispec128.length()];
4431         int[] iout256 = new int[ispec256.length()];
4432         int[] iout512 = new int[ispec512.length()];
4433         int[] ioutMax = new int[ispecMax.length()];
4434 
4435         long[] lout64 = new long[lspec64.length()];
4436         long[] lout128 = new long[lspec128.length()];
4437         long[] lout256 = new long[lspec256.length()];
4438         long[] lout512 = new long[lspec512.length()];
4439         long[] loutMax = new long[lspecMax.length()];
4440 
4441         float[] fout64 = new float[fspec64.length()];
4442         float[] fout128 = new float[fspec128.length()];
4443         float[] fout256 = new float[fspec256.length()];
4444         float[] fout512 = new float[fspec512.length()];
4445         float[] foutMax = new float[fspecMax.length()];
4446 
4447         double[] dout64 = new double[dspec64.length()];
4448         double[] dout128 = new double[dspec128.length()];
4449         double[] dout256 = new double[dspec256.length()];
4450         double[] dout512 = new double[dspec512.length()];
4451         double[] doutMax = new double[dspecMax.length()];
4452 
4453         for (int i = 0; i < NUM_ITER; i++) {
4454             testVectorCastDoubleMaxToByte(dspecMax, bspec64, dinMax, bout64);
4455             testVectorCastDoubleMaxToByte(dspecMax, bspec128, dinMax, bout128);
4456             testVectorCastDoubleMaxToByte(dspecMax, bspec256, dinMax, bout256);
4457             testVectorCastDoubleMaxToByte(dspecMax, bspec512, dinMax, bout512);
4458             testVectorCastDoubleMaxToByte(dspecMax, bspecMax, dinMax, boutMax);
4459 
4460             testVectorCastDoubleMaxToShort(dspecMax, sspec64, dinMax, sout64);
4461             testVectorCastDoubleMaxToShort(dspecMax, sspec128, dinMax, sout128);
4462             testVectorCastDoubleMaxToShort(dspecMax, sspec256, dinMax, sout256);
4463             testVectorCastDoubleMaxToShort(dspecMax, sspec512, dinMax, sout512);
4464             testVectorCastDoubleMaxToShort(dspecMax, sspecMax, dinMax, soutMax);
4465 
4466             testVectorCastDoubleMaxToInt(dspecMax, ispec64, dinMax, iout64);
4467             testVectorCastDoubleMaxToInt(dspecMax, ispec128, dinMax, iout128);
4468             testVectorCastDoubleMaxToInt(dspecMax, ispec256, dinMax, iout256);
4469             testVectorCastDoubleMaxToInt(dspecMax, ispec512, dinMax, iout512);
4470             testVectorCastDoubleMaxToInt(dspecMax, ispecMax, dinMax, ioutMax);
4471 
4472             testVectorCastDoubleMaxToLong(dspecMax, lspec64, dinMax, lout64);
4473             testVectorCastDoubleMaxToLong(dspecMax, lspec128, dinMax, lout128);
4474             testVectorCastDoubleMaxToLong(dspecMax, lspec256, dinMax, lout256);
4475             testVectorCastDoubleMaxToLong(dspecMax, lspec512, dinMax, lout512);
4476             testVectorCastDoubleMaxToLong(dspecMax, lspecMax, dinMax, loutMax);
4477 
4478             testVectorCastDoubleMaxToFloat(dspecMax, fspec64, dinMax, fout64);
4479             testVectorCastDoubleMaxToFloat(dspecMax, fspec128, dinMax, fout128);
4480             testVectorCastDoubleMaxToFloat(dspecMax, fspec256, dinMax, fout256);
4481             testVectorCastDoubleMaxToFloat(dspecMax, fspec512, dinMax, fout512);
4482             testVectorCastDoubleMaxToFloat(dspecMax, fspecMax, dinMax, foutMax);
4483 
4484             testVectorCastDoubleMaxToDouble(dspecMax, dspec64, dinMax, dout64);
4485             testVectorCastDoubleMaxToDouble(dspecMax, dspec128, dinMax, dout128);
4486             testVectorCastDoubleMaxToDouble(dspecMax, dspec256, dinMax, dout256);
4487             testVectorCastDoubleMaxToDouble(dspecMax, dspec512, dinMax, dout512);
4488             testVectorCastDoubleMaxToDouble(dspecMax, dspecMax, dinMax, doutMax);
4489         }
4490     }
4491 }