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