1 /*
   2  * Copyright (c) 2018, 2024, 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 
  24 /*
  25  * @test
  26  * @key randomness
  27  *
  28  * @library /test/lib
  29  * @modules jdk.incubator.vector
  30  * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ShortMaxVectorTests
  31  */
  32 
  33 // -- This file was mechanically generated: Do not edit! -- //
  34 
  35 import jdk.incubator.vector.VectorShape;
  36 import jdk.incubator.vector.VectorSpecies;
  37 import jdk.incubator.vector.VectorShuffle;
  38 import jdk.incubator.vector.VectorMask;
  39 import jdk.incubator.vector.VectorOperators;
  40 import jdk.incubator.vector.Vector;
  41 import jdk.incubator.vector.VectorMath;
  42 
  43 import jdk.incubator.vector.ShortVector;
  44 
  45 import org.testng.Assert;
  46 import org.testng.annotations.DataProvider;
  47 import org.testng.annotations.Test;
  48 
  49 import java.lang.Integer;
  50 import java.util.List;
  51 import java.util.Arrays;
  52 import java.util.function.BiFunction;
  53 import java.util.function.IntFunction;
  54 import java.util.Objects;
  55 import java.util.stream.Collectors;
  56 import java.util.stream.Stream;
  57 
  58 @Test
  59 public class ShortMaxVectorTests extends AbstractVectorTest {
  60 
  61     static final VectorSpecies<Short> SPECIES =
  62                 ShortVector.SPECIES_MAX;
  63 
  64     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  65 
  66     static VectorShape getMaxBit() {
  67         return VectorShape.S_Max_BIT;
  68     }
  69 
  70     private static final int Max = 256;  // juts so we can do N/Max
  71 
  72     private static final short CONST_SHIFT = Short.SIZE / 2;
  73 
  74     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  75 
  76     static void assertArraysStrictlyEquals(short[] r, short[] a) {
  77         for (int i = 0; i < a.length; i++) {
  78             if (r[i] != a[i]) {
  79                 Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]);
  80             }
  81         }
  82     }
  83 
  84     interface FUnOp {
  85         short apply(short a);
  86     }
  87 
  88     static void assertArraysEquals(short[] r, short[] a, FUnOp f) {
  89         int i = 0;
  90         try {
  91             for (; i < a.length; i++) {
  92                 Assert.assertEquals(r[i], f.apply(a[i]));
  93             }
  94         } catch (AssertionError e) {
  95             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  96         }
  97     }
  98 
  99     interface FUnArrayOp {
 100         short[] apply(short a);
 101     }
 102 
 103     static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) {
 104         int i = 0;
 105         try {
 106             for (; i < a.length; i += SPECIES.length()) {
 107                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 108                   f.apply(a[i]));
 109             }
 110         } catch (AssertionError e) {
 111             short[] ref = f.apply(a[i]);
 112             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 113             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 114               + ", res: " + Arrays.toString(res)
 115               + "), at index #" + i);
 116         }
 117     }
 118 
 119     static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) {
 120         int i = 0;
 121         try {
 122             for (; i < a.length; i++) {
 123                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 124             }
 125         } catch (AssertionError e) {
 126             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
 127         }
 128     }
 129 
 130     interface FReductionOp {
 131         short apply(short[] a, int idx);
 132     }
 133 
 134     interface FReductionAllOp {
 135         short apply(short[] a);
 136     }
 137 
 138     static void assertReductionArraysEquals(short[] r, short rc, short[] a,
 139                                             FReductionOp f, FReductionAllOp fa) {
 140         int i = 0;
 141         try {
 142             Assert.assertEquals(rc, fa.apply(a));
 143             for (; i < a.length; i += SPECIES.length()) {
 144                 Assert.assertEquals(r[i], f.apply(a, i));
 145             }
 146         } catch (AssertionError e) {
 147             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 148             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 149         }
 150     }
 151 
 152     interface FReductionMaskedOp {
 153         short apply(short[] a, int idx, boolean[] mask);
 154     }
 155 
 156     interface FReductionAllMaskedOp {
 157         short apply(short[] a, boolean[] mask);
 158     }
 159 
 160     static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask,
 161                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 162         int i = 0;
 163         try {
 164             Assert.assertEquals(rc, fa.apply(a, mask));
 165             for (; i < a.length; i += SPECIES.length()) {
 166                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 167             }
 168         } catch (AssertionError e) {
 169             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 170             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 171         }
 172     }
 173 
 174     interface FReductionOpLong {
 175         long apply(short[] a, int idx);
 176     }
 177 
 178     interface FReductionAllOpLong {
 179         long apply(short[] a);
 180     }
 181 
 182     static void assertReductionLongArraysEquals(long[] r, long rc, short[] a,
 183                                             FReductionOpLong f, FReductionAllOpLong fa) {
 184         int i = 0;
 185         try {
 186             Assert.assertEquals(rc, fa.apply(a));
 187             for (; i < a.length; i += SPECIES.length()) {
 188                 Assert.assertEquals(r[i], f.apply(a, i));
 189             }
 190         } catch (AssertionError e) {
 191             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 192             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 193         }
 194     }
 195 
 196     interface FReductionMaskedOpLong {
 197         long apply(short[] a, int idx, boolean[] mask);
 198     }
 199 
 200     interface FReductionAllMaskedOpLong {
 201         long apply(short[] a, boolean[] mask);
 202     }
 203 
 204     static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask,
 205                                             FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {
 206         int i = 0;
 207         try {
 208             Assert.assertEquals(rc, fa.apply(a, mask));
 209             for (; i < a.length; i += SPECIES.length()) {
 210                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 211             }
 212         } catch (AssertionError e) {
 213             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 214             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 215         }
 216     }
 217 
 218     interface FBoolReductionOp {
 219         boolean apply(boolean[] a, int idx);
 220     }
 221 
 222     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 223         int i = 0;
 224         try {
 225             for (; i < a.length; i += SPECIES.length()) {
 226                 Assert.assertEquals(r[i], f.apply(a, i));
 227             }
 228         } catch (AssertionError e) {
 229             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 230         }
 231     }
 232 
 233     interface FMaskReductionOp {
 234         int apply(boolean[] a, int idx);
 235     }
 236 
 237     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 238         int i = 0;
 239         try {
 240             for (; i < a.length; i += SPECIES.length()) {
 241                 Assert.assertEquals(r[i], f.apply(a, i));
 242             }
 243         } catch (AssertionError e) {
 244             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 245         }
 246     }
 247 
 248     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) {
 249         int i = 0, j = 0;
 250         try {
 251             for (; i < a.length; i += vector_len) {
 252                 for (j = 0; j < vector_len; j++) {
 253                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 254                 }
 255             }
 256         } catch (AssertionError e) {
 257             int idx = i + j;
 258             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 259         }
 260     }
 261 
 262     static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
 263         int i = 0, j = 0, k = 0;
 264         try {
 265             for (; i < a.length; i += vector_len) {
 266                 k = 0;
 267                 for (j = 0; j < vector_len; j++) {
 268                     if (m[(i + j) % SPECIES.length()]) {
 269                         Assert.assertEquals(r[i + k], a[i + j]);
 270                         k++;
 271                     }
 272                 }
 273                 for (; k < vector_len; k++) {
 274                     Assert.assertEquals(r[i + k], (short)0);
 275                 }
 276             }
 277         } catch (AssertionError e) {
 278             int idx = i + k;
 279             if (m[(i + j) % SPECIES.length()]) {
 280                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 281             } else {
 282                 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
 283             }
 284         }
 285     }
 286 
 287     static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
 288         int i = 0, j = 0, k = 0;
 289         try {
 290             for (; i < a.length; i += vector_len) {
 291                 k = 0;
 292                 for (j = 0; j < vector_len; j++) {
 293                     if (m[(i + j) % SPECIES.length()]) {
 294                         Assert.assertEquals(r[i + j], a[i + k]);
 295                         k++;
 296                     } else {
 297                         Assert.assertEquals(r[i + j], (short)0);
 298                     }
 299                 }
 300             }
 301         } catch (AssertionError e) {
 302             int idx = i + j;
 303             if (m[idx % SPECIES.length()]) {
 304                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 305             } else {
 306                 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
 307             }
 308         }
 309     }
 310 
 311     static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) {
 312         int i = 0, j = 0;
 313         boolean is_exceptional_idx = false;
 314         int idx = 0, wrapped_index = 0, oidx = 0;
 315         try {
 316             for (; i < a.length; i += vector_len) {
 317                 for (j = 0; j < vector_len; j++) {
 318                     idx = i + j;
 319                     wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len);
 320                     is_exceptional_idx = wrapped_index >= vector_len;
 321                     oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index;
 322                     Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]));
 323                 }
 324             }
 325         } catch (AssertionError e) {
 326             Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]);
 327         }
 328     }
 329 
 330     static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
 331         int i = 0, j = 0;
 332         try {
 333             for (; i < a.length; i += vector_len) {
 334                 for (j = 0; j < vector_len; j++) {
 335                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 336                 }
 337             }
 338         } catch (AssertionError e) {
 339             int idx = i + j;
 340             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 341         }
 342     }
 343 
 344     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) {
 345         int i = 0, j = 0;
 346         try {
 347             for (; i < a.length; i += vector_len) {
 348                 for (j = 0; j < vector_len; j++) {
 349                     if (mask[j % SPECIES.length()])
 350                          Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 351                     else
 352                          Assert.assertEquals(r[i+j], (short)0);
 353                 }
 354             }
 355         } catch (AssertionError e) {
 356             int idx = i + j;
 357             if (mask[j % SPECIES.length()])
 358                 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 359             else
 360                 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 361         }
 362     }
 363 
 364     static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) {
 365         int i = 0, j = 0;
 366         try {
 367             for (; i < a.length; i += vector_len) {
 368                 for (j = 0; j < vector_len; j++) {
 369                     if (mask[j % SPECIES.length()])
 370                          Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 371                     else
 372                          Assert.assertEquals(r[i+j], (short)0);
 373                 }
 374             }
 375         } catch (AssertionError e) {
 376             int idx = i + j;
 377             if (mask[j % SPECIES.length()])
 378                 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 379             else
 380                 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 381         }
 382     }
 383 
 384     static void assertBroadcastArraysEquals(short[] r, short[] a) {
 385         int i = 0;
 386         for (; i < a.length; i += SPECIES.length()) {
 387             int idx = i;
 388             for (int j = idx; j < (idx + SPECIES.length()); j++)
 389                 a[j]=a[idx];
 390         }
 391 
 392         try {
 393             for (i = 0; i < a.length; i++) {
 394                 Assert.assertEquals(r[i], a[i]);
 395             }
 396         } catch (AssertionError e) {
 397             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 398         }
 399     }
 400 
 401     interface FBinOp {
 402         short apply(short a, short b);
 403     }
 404 
 405     interface FBinMaskOp {
 406         short apply(short a, short b, boolean m);
 407 
 408         static FBinMaskOp lift(FBinOp f) {
 409             return (a, b, m) -> m ? f.apply(a, b) : a;
 410         }
 411     }
 412 
 413     static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) {
 414         int i = 0;
 415         try {
 416             for (; i < a.length; i++) {
 417                 //Left associative
 418                 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]));
 419 
 420                 //Right associative
 421                 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])));
 422 
 423                 //Results equal sanity check
 424                 Assert.assertEquals(rl[i], rr[i]);
 425             }
 426         } catch (AssertionError e) {
 427             Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 428             Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 429             Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
 430         }
 431     }
 432 
 433    static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) {
 434        assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f));
 435    }
 436 
 437     static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) {
 438         int i = 0;
 439         boolean mask_bit = false;
 440         try {
 441             for (; i < a.length; i++) {
 442                 mask_bit = mask[i % SPECIES.length()];
 443                 //Left associative
 444                 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit));
 445 
 446                 //Right associative
 447                 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit));
 448 
 449                 //Results equal sanity check
 450                 Assert.assertEquals(rl[i], rr[i]);
 451             }
 452         } catch (AssertionError e) {
 453             Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
 454             Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
 455             Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
 456         }
 457     }
 458 
 459     static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 460         int i = 0;
 461         try {
 462             for (; i < a.length; i++) {
 463                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 464             }
 465         } catch (AssertionError e) {
 466             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 467         }
 468     }
 469 
 470     static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) {
 471         int i = 0;
 472         try {
 473             for (; i < a.length; i++) {
 474                 Assert.assertEquals(r[i], f.apply(a[i], b));
 475             }
 476         } catch (AssertionError e) {
 477             Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i);
 478         }
 479     }
 480 
 481     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 482         int i = 0;
 483         try {
 484             for (; i < a.length; i++) {
 485                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 486             }
 487         } catch (AssertionError e) {
 488             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 489                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 490         }
 491     }
 492 
 493     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 494         int i = 0;
 495         try {
 496             for (; i < a.length; i++) {
 497                 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 498             }
 499         } catch (AssertionError e) {
 500             Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
 501                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 502         }
 503     }
 504 
 505     static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 506         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 507     }
 508 
 509     static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 510         int i = 0;
 511         try {
 512             for (; i < a.length; i++) {
 513                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 514             }
 515         } catch (AssertionError err) {
 516             Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
 517         }
 518     }
 519 
 520     static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) {
 521         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 522     }
 523 
 524     static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) {
 525         int i = 0;
 526         try {
 527             for (; i < a.length; i++) {
 528                 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]));
 529             }
 530         } catch (AssertionError err) {
 531             Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]);
 532         }
 533     }
 534 
 535     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 536         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 537     }
 538 
 539     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 540         int i = 0;
 541         try {
 542             for (; i < a.length; i++) {
 543                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 544             }
 545         } catch (AssertionError err) {
 546             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 547                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 548                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 549                                 mask[i % SPECIES.length()]);
 550         }
 551     }
 552 
 553     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 554         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 555     }
 556 
 557     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 558         int i = 0;
 559         try {
 560             for (; i < a.length; i++) {
 561                 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
 562             }
 563         } catch (AssertionError err) {
 564             Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
 565                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 566                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 567                                 mask[i % SPECIES.length()]);
 568         }
 569     }
 570 
 571     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 572         int i = 0;
 573         int j = 0;
 574         try {
 575             for (; j < a.length; j += SPECIES.length()) {
 576                 for (i = 0; i < SPECIES.length(); i++) {
 577                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 578                 }
 579             }
 580         } catch (AssertionError e) {
 581             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 582         }
 583     }
 584 
 585     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 586         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 587     }
 588 
 589     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 590         int i = 0;
 591         int j = 0;
 592         try {
 593             for (; j < a.length; j += SPECIES.length()) {
 594                 for (i = 0; i < SPECIES.length(); i++) {
 595                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 596                 }
 597             }
 598         } catch (AssertionError err) {
 599             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
 600         }
 601     }
 602 
 603     interface FBinConstOp {
 604         short apply(short a);
 605     }
 606 
 607     interface FBinConstMaskOp {
 608         short apply(short a, boolean m);
 609 
 610         static FBinConstMaskOp lift(FBinConstOp f) {
 611             return (a, m) -> m ? f.apply(a) : a;
 612         }
 613     }
 614 
 615     static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
 616         int i = 0;
 617         int j = 0;
 618         try {
 619             for (; j < a.length; j += SPECIES.length()) {
 620                 for (i = 0; i < SPECIES.length(); i++) {
 621                     Assert.assertEquals(r[i+j], f.apply(a[i+j]));
 622                 }
 623             }
 624         } catch (AssertionError e) {
 625             Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
 626         }
 627     }
 628 
 629     static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
 630         assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
 631     }
 632 
 633     static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
 634         int i = 0;
 635         int j = 0;
 636         try {
 637             for (; j < a.length; j += SPECIES.length()) {
 638                 for (i = 0; i < SPECIES.length(); i++) {
 639                     Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
 640                 }
 641             }
 642         } catch (AssertionError err) {
 643             Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
 644         }
 645     }
 646 
 647     interface FTernOp {
 648         short apply(short a, short b, short c);
 649     }
 650 
 651     interface FTernMaskOp {
 652         short apply(short a, short b, short c, boolean m);
 653 
 654         static FTernMaskOp lift(FTernOp f) {
 655             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 656         }
 657     }
 658 
 659     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 660         int i = 0;
 661         try {
 662             for (; i < a.length; i++) {
 663                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 664             }
 665         } catch (AssertionError e) {
 666             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 667         }
 668     }
 669 
 670     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) {
 671         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 672     }
 673 
 674     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) {
 675         int i = 0;
 676         try {
 677             for (; i < a.length; i++) {
 678                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 679             }
 680         } catch (AssertionError err) {
 681             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 682               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 683         }
 684     }
 685 
 686     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 687         int i = 0;
 688         try {
 689             for (; i < a.length; i++) {
 690                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
 691             }
 692         } catch (AssertionError e) {
 693             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
 694                                 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
 695                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 696         }
 697     }
 698 
 699     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 700         int i = 0;
 701         try {
 702             for (; i < a.length; i++) {
 703                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
 704             }
 705         } catch (AssertionError e) {
 706             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
 707                                 i + ", input1 = " + a[i] + ", input2 = " +
 708                                 b[(i / SPECIES.length()) * SPECIES.length()] + ",  input3 = " + c[i]);
 709         }
 710     }
 711 
 712     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 713                                             FTernOp f) {
 714         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 715     }
 716 
 717     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 718                                             FTernMaskOp f) {
 719         int i = 0;
 720         try {
 721             for (; i < a.length; i++) {
 722                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 723                                     mask[i % SPECIES.length()]));
 724             }
 725         } catch (AssertionError err) {
 726             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 727                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 728                                 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 729                                 mask[i % SPECIES.length()]);
 730         }
 731     }
 732 
 733     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 734                                             FTernOp f) {
 735         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 736     }
 737 
 738     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 739                                             FTernMaskOp f) {
 740         int i = 0;
 741         try {
 742             for (; i < a.length; i++) {
 743                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 744                                     mask[i % SPECIES.length()]));
 745             }
 746         } catch (AssertionError err) {
 747             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 748                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 749                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 750                                 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 751         }
 752     }
 753 
 754     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 755         int i = 0;
 756         try {
 757             for (; i < a.length; i++) {
 758                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 759                                     c[(i / SPECIES.length()) * SPECIES.length()]));
 760             }
 761         } catch (AssertionError e) {
 762             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 763                                 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
 764                                 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
 765                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 766         }
 767     }
 768 
 769     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 770                                                   FTernOp f) {
 771         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 772     }
 773 
 774     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 775                                                   FTernMaskOp f) {
 776         int i = 0;
 777         try {
 778             for (; i < a.length; i++) {
 779                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 780                                     c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 781             }
 782         } catch (AssertionError err) {
 783             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 784                                 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
 785                                 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 786                                 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 787                                 mask[i % SPECIES.length()]);
 788         }
 789     }
 790 
 791 
 792 
 793     interface FGatherScatterOp {
 794         short[] apply(short[] a, int ix, int[] b, int iy);
 795     }
 796 
 797     static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) {
 798         int i = 0;
 799         try {
 800             for (; i < a.length; i += SPECIES.length()) {
 801                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 802                   f.apply(a, i, b, i));
 803             }
 804         } catch (AssertionError e) {
 805             short[] ref = f.apply(a, i, b, i);
 806             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 807             Assert.assertEquals(res, ref,
 808               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 809               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 810               + ", b: "
 811               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 812               + " at index #" + i);
 813         }
 814     }
 815 
 816     interface FGatherMaskedOp {
 817         short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy);
 818     }
 819 
 820     interface FScatterMaskedOp {
 821         short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy);
 822     }
 823 
 824     static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
 825         int i = 0;
 826         try {
 827             for (; i < a.length; i += SPECIES.length()) {
 828                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 829                   f.apply(a, i, mask, b, i));
 830             }
 831         } catch (AssertionError e) {
 832             short[] ref = f.apply(a, i, mask, b, i);
 833             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 834             Assert.assertEquals(res, ref,
 835               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 836               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 837               + ", b: "
 838               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 839               + ", mask: "
 840               + Arrays.toString(mask)
 841               + " at index #" + i);
 842         }
 843     }
 844 
 845     static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
 846         int i = 0;
 847         try {
 848             for (; i < a.length; i += SPECIES.length()) {
 849                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 850                   f.apply(r, a, i, mask, b, i));
 851             }
 852         } catch (AssertionError e) {
 853             short[] ref = f.apply(r, a, i, mask, b, i);
 854             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 855             Assert.assertEquals(res, ref,
 856               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 857               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 858               + ", b: "
 859               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 860               + ", r: "
 861               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 862               + ", mask: "
 863               + Arrays.toString(mask)
 864               + " at index #" + i);
 865         }
 866     }
 867 
 868     interface FLaneOp {
 869         short[] apply(short[] a, int origin, int idx);
 870     }
 871 
 872     static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) {
 873         int i = 0;
 874         try {
 875             for (; i < a.length; i += SPECIES.length()) {
 876                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 877                   f.apply(a, origin, i));
 878             }
 879         } catch (AssertionError e) {
 880             short[] ref = f.apply(a, origin, i);
 881             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 882             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 883               + ", res: " + Arrays.toString(res)
 884               + "), at index #" + i);
 885         }
 886     }
 887 
 888     interface FLaneBop {
 889         short[] apply(short[] a, short[] b, int origin, int idx);
 890     }
 891 
 892     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) {
 893         int i = 0;
 894         try {
 895             for (; i < a.length; i += SPECIES.length()) {
 896                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 897                   f.apply(a, b, origin, i));
 898             }
 899         } catch (AssertionError e) {
 900             short[] ref = f.apply(a, b, origin, i);
 901             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 902             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 903               + ", res: " + Arrays.toString(res)
 904               + "), at index #" + i
 905               + ", at origin #" + origin);
 906         }
 907     }
 908 
 909     interface FLaneMaskedBop {
 910         short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx);
 911     }
 912 
 913     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
 914         int i = 0;
 915         try {
 916             for (; i < a.length; i += SPECIES.length()) {
 917                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 918                   f.apply(a, b, origin, mask, i));
 919             }
 920         } catch (AssertionError e) {
 921             short[] ref = f.apply(a, b, origin, mask, i);
 922             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 923             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 924               + ", res: " + Arrays.toString(res)
 925               + "), at index #" + i
 926               + ", at origin #" + origin);
 927         }
 928     }
 929 
 930     interface FLanePartBop {
 931         short[] apply(short[] a, short[] b, int origin, int part, int idx);
 932     }
 933 
 934     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) {
 935         int i = 0;
 936         try {
 937             for (; i < a.length; i += SPECIES.length()) {
 938                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 939                   f.apply(a, b, origin, part, i));
 940             }
 941         } catch (AssertionError e) {
 942             short[] ref = f.apply(a, b, origin, part, i);
 943             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 944             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 945               + ", res: " + Arrays.toString(res)
 946               + "), at index #" + i
 947               + ", at origin #" + origin
 948               + ", with part #" + part);
 949         }
 950     }
 951 
 952     interface FLanePartMaskedBop {
 953         short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx);
 954     }
 955 
 956     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 957         int i = 0;
 958         try {
 959             for (; i < a.length; i += SPECIES.length()) {
 960                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 961                   f.apply(a, b, origin, part, mask, i));
 962             }
 963         } catch (AssertionError e) {
 964             short[] ref = f.apply(a, b, origin, part, mask, i);
 965             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 966             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 967               + ", res: " + Arrays.toString(res)
 968               + "), at index #" + i
 969               + ", at origin #" + origin
 970               + ", with part #" + part);
 971         }
 972     }
 973 
 974 
 975     static void assertArraysEquals(int[] r, short[] a, int offs) {
 976         int i = 0;
 977         try {
 978             for (; i < r.length; i++) {
 979                 Assert.assertEquals(r[i], (int)(a[i+offs]));
 980             }
 981         } catch (AssertionError e) {
 982             Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 983         }
 984     }
 985 
 986 
 987 
 988     static void assertArraysEquals(long[] r, short[] a, int offs) {
 989         int i = 0;
 990         try {
 991             for (; i < r.length; i++) {
 992                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 993             }
 994         } catch (AssertionError e) {
 995             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 996         }
 997     }
 998 
 999     static void assertArraysEquals(double[] r, short[] a, int offs) {
1000         int i = 0;
1001         try {
1002             for (; i < r.length; i++) {
1003                 Assert.assertEquals(r[i], (double)(a[i+offs]));
1004             }
1005         } catch (AssertionError e) {
1006             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1007         }
1008     }
1009 
1010     static short bits(short e) {
1011         return  e;
1012     }
1013 
1014     static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
1015             withToString("short[-i * 5]", (int s) -> {
1016                 return fill(s * BUFFER_REPS,
1017                             i -> (short)(-i * 5));
1018             }),
1019             withToString("short[i * 5]", (int s) -> {
1020                 return fill(s * BUFFER_REPS,
1021                             i -> (short)(i * 5));
1022             }),
1023             withToString("short[i + 1]", (int s) -> {
1024                 return fill(s * BUFFER_REPS,
1025                             i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1)));
1026             }),
1027             withToString("short[cornerCaseValue(i)]", (int s) -> {
1028                 return fill(s * BUFFER_REPS,
1029                             i -> cornerCaseValue(i));
1030             })
1031     );
1032 
1033     static final List<IntFunction<short[]>> SHORT_SATURATING_GENERATORS = List.of(
1034             withToString("short[Short.MIN_VALUE]", (int s) -> {
1035                 return fill(s * BUFFER_REPS,
1036                             i -> (short)(Short.MIN_VALUE));
1037             }),
1038             withToString("short[Short.MAX_VALUE]", (int s) -> {
1039                 return fill(s * BUFFER_REPS,
1040                             i -> (short)(Short.MAX_VALUE));
1041             }),
1042             withToString("short[Short.MAX_VALUE - 100]", (int s) -> {
1043                 return fill(s * BUFFER_REPS,
1044                             i -> (short)(Short.MAX_VALUE - 100));
1045             }),
1046             withToString("short[Short.MIN_VALUE + 100]", (int s) -> {
1047                 return fill(s * BUFFER_REPS,
1048                             i -> (short)(Short.MIN_VALUE + 100));
1049             }),
1050             withToString("short[-i * 5]", (int s) -> {
1051                 return fill(s * BUFFER_REPS,
1052                             i -> (short)(-i * 5));
1053             }),
1054             withToString("short[i * 5]", (int s) -> {
1055                 return fill(s * BUFFER_REPS,
1056                             i -> (short)(i * 5));
1057             })
1058     );
1059 
1060     static final List<IntFunction<short[]>> SHORT_SATURATING_GENERATORS_ASSOC = List.of(
1061             withToString("short[Short.MAX_VALUE]", (int s) -> {
1062                 return fill(s * BUFFER_REPS,
1063                             i -> (short)(Short.MAX_VALUE));
1064             }),
1065             withToString("short[Short.MAX_VALUE - 100]", (int s) -> {
1066                 return fill(s * BUFFER_REPS,
1067                             i -> (short)(Short.MAX_VALUE - 100));
1068             }),
1069             withToString("short[-1]", (int s) -> {
1070                 return fill(s * BUFFER_REPS,
1071                             i -> (short)(-1));
1072             })
1073     );
1074 
1075     // Create combinations of pairs
1076     // @@@ Might be sensitive to order e.g. div by 0
1077     static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_PAIRS =
1078         Stream.of(SHORT_GENERATORS.get(0)).
1079                 flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1080                 collect(Collectors.toList());
1081 
1082     static final List<List<IntFunction<short[]>>> SHORT_SATURATING_GENERATOR_PAIRS =
1083         Stream.of(SHORT_GENERATORS.get(0)).
1084                 flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1085                 collect(Collectors.toList());
1086 
1087     static final List<List<IntFunction<short[]>>> SHORT_SATURATING_GENERATOR_TRIPLETS =
1088             Stream.of(SHORT_GENERATORS.get(1))
1089                     .flatMap(fa -> SHORT_SATURATING_GENERATORS_ASSOC.stream().map(fb -> List.of(fa, fb)))
1090                     .flatMap(pair -> SHORT_SATURATING_GENERATORS_ASSOC.stream().map(f -> List.of(pair.get(0), pair.get(1), f)))
1091                     .collect(Collectors.toList());
1092 
1093     @DataProvider
1094     public Object[][] boolUnaryOpProvider() {
1095         return BOOL_ARRAY_GENERATORS.stream().
1096                 map(f -> new Object[]{f}).
1097                 toArray(Object[][]::new);
1098     }
1099 
1100     static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_TRIPLES =
1101         SHORT_GENERATOR_PAIRS.stream().
1102                 flatMap(pair -> SHORT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1103                 collect(Collectors.toList());
1104 
1105     static final List<IntFunction<short[]>> SELECT_FROM_INDEX_GENERATORS = List.of(
1106             withToString("short[0..VECLEN*2)", (int s) -> {
1107                 return fill(s * BUFFER_REPS,
1108                             i -> (short)(RAND.nextInt()));
1109             })
1110     );
1111 
1112     static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_SELECT_FROM_TRIPLES =
1113         SHORT_GENERATOR_PAIRS.stream().
1114                 flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1115                 collect(Collectors.toList());
1116 
1117     @DataProvider
1118     public Object[][] shortBinaryOpProvider() {
1119         return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
1120                 toArray(Object[][]::new);
1121     }
1122 
1123     @DataProvider
1124     public Object[][] shortSaturatingBinaryOpProvider() {
1125         return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray).
1126                 toArray(Object[][]::new);
1127     }
1128 
1129     @DataProvider
1130     public Object[][] shortSaturatingBinaryOpAssocProvider() {
1131         return SHORT_SATURATING_GENERATOR_TRIPLETS.stream().map(List::toArray).
1132                 toArray(Object[][]::new);
1133     }
1134 
1135     @DataProvider
1136     public Object[][] shortSaturatingBinaryOpAssocMaskProvider() {
1137         return BOOLEAN_MASK_GENERATORS.stream().
1138                 flatMap(fm -> SHORT_SATURATING_GENERATOR_TRIPLETS.stream().map(lfa -> {
1139                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1140                 })).
1141                 toArray(Object[][]::new);
1142     }
1143 
1144 
1145     @DataProvider
1146     public Object[][] shortIndexedOpProvider() {
1147         return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
1148                 toArray(Object[][]::new);
1149     }
1150 
1151     @DataProvider
1152     public Object[][] shortSaturatingBinaryOpMaskProvider() {
1153         return BOOLEAN_MASK_GENERATORS.stream().
1154                 flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> {
1155                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1156                 })).
1157                 toArray(Object[][]::new);
1158     }
1159 
1160    @DataProvider
1161    public Object[][] shortSaturatingUnaryOpProvider() {
1162        return SHORT_SATURATING_GENERATORS.stream().
1163                     map(f -> new Object[]{f}).
1164                     toArray(Object[][]::new);
1165    }
1166 
1167    @DataProvider
1168    public Object[][] shortSaturatingUnaryOpMaskProvider() {
1169         return BOOLEAN_MASK_GENERATORS.stream().
1170                 flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
1171                     return new Object[] {fa, fm};
1172                 })).
1173                 toArray(Object[][]::new);
1174    }
1175 
1176     @DataProvider
1177     public Object[][] shortBinaryOpMaskProvider() {
1178         return BOOLEAN_MASK_GENERATORS.stream().
1179                 flatMap(fm -> SHORT_GENERATOR_PAIRS.stream().map(lfa -> {
1180                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1181                 })).
1182                 toArray(Object[][]::new);
1183     }
1184 
1185     @DataProvider
1186     public Object[][] shortTernaryOpProvider() {
1187         return SHORT_GENERATOR_TRIPLES.stream().map(List::toArray).
1188                 toArray(Object[][]::new);
1189     }
1190 
1191     @DataProvider
1192     public Object[][] shortSelectFromTwoVectorOpProvider() {
1193         return SHORT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray).
1194                 toArray(Object[][]::new);
1195     }
1196 
1197     @DataProvider
1198     public Object[][] shortTernaryOpMaskProvider() {
1199         return BOOLEAN_MASK_GENERATORS.stream().
1200                 flatMap(fm -> SHORT_GENERATOR_TRIPLES.stream().map(lfa -> {
1201                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1202                 })).
1203                 toArray(Object[][]::new);
1204     }
1205 
1206     @DataProvider
1207     public Object[][] shortUnaryOpProvider() {
1208         return SHORT_GENERATORS.stream().
1209                 map(f -> new Object[]{f}).
1210                 toArray(Object[][]::new);
1211     }
1212 
1213     @DataProvider
1214     public Object[][] shortUnaryOpMaskProvider() {
1215         return BOOLEAN_MASK_GENERATORS.stream().
1216                 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> {
1217                     return new Object[] {fa, fm};
1218                 })).
1219                 toArray(Object[][]::new);
1220     }
1221 
1222     @DataProvider
1223     public Object[][] maskProvider() {
1224         return BOOLEAN_MASK_GENERATORS.stream().
1225                 map(f -> new Object[]{f}).
1226                 toArray(Object[][]::new);
1227     }
1228 
1229     @DataProvider
1230     public Object[][] maskCompareOpProvider() {
1231         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1232                 toArray(Object[][]::new);
1233     }
1234 
1235     @DataProvider
1236     public Object[][] shuffleProvider() {
1237         return INT_SHUFFLE_GENERATORS.stream().
1238                 map(f -> new Object[]{f}).
1239                 toArray(Object[][]::new);
1240     }
1241 
1242     @DataProvider
1243     public Object[][] shuffleCompareOpProvider() {
1244         return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1245                 toArray(Object[][]::new);
1246     }
1247 
1248     @DataProvider
1249     public Object[][] shortUnaryOpShuffleProvider() {
1250         return INT_SHUFFLE_GENERATORS.stream().
1251                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1252                     return new Object[] {fa, fs};
1253                 })).
1254                 toArray(Object[][]::new);
1255     }
1256 
1257     @DataProvider
1258     public Object[][] shortUnaryOpShuffleMaskProvider() {
1259         return BOOLEAN_MASK_GENERATORS.stream().
1260                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1261                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1262                         return new Object[] {fa, fs, fm};
1263                 }))).
1264                 toArray(Object[][]::new);
1265     }
1266 
1267     static final List<BiFunction<Integer,Integer,short[]>> SHORT_SHUFFLE_GENERATORS = List.of(
1268             withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1269                 short[] a = new short[l];
1270                 int upper = m;
1271                 for (int i = 0; i < 1; i++) {
1272                     a[i] = (short)RAND.nextInt(upper);
1273                 }
1274                 return a;
1275             })
1276     );
1277 
1278     @DataProvider
1279     public Object[][] shortUnaryOpSelectFromProvider() {
1280         return SHORT_SHUFFLE_GENERATORS.stream().
1281                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1282                     return new Object[] {fa, fs};
1283                 })).
1284                 toArray(Object[][]::new);
1285     }
1286 
1287     @DataProvider
1288     public Object[][] shortUnaryOpSelectFromMaskProvider() {
1289         return BOOLEAN_MASK_GENERATORS.stream().
1290                 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream().
1291                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1292                         return new Object[] {fa, fs, fm};
1293                 }))).
1294                 toArray(Object[][]::new);
1295     }
1296 
1297     static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
1298             withToString("short[i]", (int s) -> {
1299                 return fill(s * BUFFER_REPS,
1300                             i -> (short)i);
1301             }),
1302             withToString("short[i - length / 2]", (int s) -> {
1303                 return fill(s * BUFFER_REPS,
1304                             i -> (short)(i - (s * BUFFER_REPS / 2)));
1305             }),
1306             withToString("short[i + 1]", (int s) -> {
1307                 return fill(s * BUFFER_REPS,
1308                             i -> (short)(i + 1));
1309             }),
1310             withToString("short[i - 2]", (int s) -> {
1311                 return fill(s * BUFFER_REPS,
1312                             i -> (short)(i - 2));
1313             }),
1314             withToString("short[zigZag(i)]", (int s) -> {
1315                 return fill(s * BUFFER_REPS,
1316                             i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2)));
1317             }),
1318             withToString("short[cornerCaseValue(i)]", (int s) -> {
1319                 return fill(s * BUFFER_REPS,
1320                             i -> cornerCaseValue(i));
1321             })
1322     );
1323 
1324     static final List<List<IntFunction<short[]>>> SHORT_TEST_GENERATOR_ARGS =
1325         SHORT_COMPARE_GENERATORS.stream().
1326                 map(fa -> List.of(fa)).
1327                 collect(Collectors.toList());
1328 
1329     @DataProvider
1330     public Object[][] shortTestOpProvider() {
1331         return SHORT_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1332                 toArray(Object[][]::new);
1333     }
1334 
1335     @DataProvider
1336     public Object[][] shortTestOpMaskProvider() {
1337         return BOOLEAN_MASK_GENERATORS.stream().
1338                 flatMap(fm -> SHORT_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1339                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1340                 })).
1341                 toArray(Object[][]::new);
1342     }
1343 
1344     static final List<List<IntFunction<short[]>>> SHORT_COMPARE_GENERATOR_PAIRS =
1345         SHORT_COMPARE_GENERATORS.stream().
1346                 flatMap(fa -> SHORT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1347                 collect(Collectors.toList());
1348 
1349     @DataProvider
1350     public Object[][] shortCompareOpProvider() {
1351         return SHORT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1352                 toArray(Object[][]::new);
1353     }
1354 
1355     @DataProvider
1356     public Object[][] shortCompareOpMaskProvider() {
1357         return BOOLEAN_MASK_GENERATORS.stream().
1358                 flatMap(fm -> SHORT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1359                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1360                 })).
1361                 toArray(Object[][]::new);
1362     }
1363 
1364     interface ToShortF {
1365         short apply(int i);
1366     }
1367 
1368     static short[] fill(int s , ToShortF f) {
1369         return fill(new short[s], f);
1370     }
1371 
1372     static short[] fill(short[] a, ToShortF f) {
1373         for (int i = 0; i < a.length; i++) {
1374             a[i] = f.apply(i);
1375         }
1376         return a;
1377     }
1378 
1379     static short cornerCaseValue(int i) {
1380         switch(i % 5) {
1381             case 0:
1382                 return Short.MAX_VALUE;
1383             case 1:
1384                 return Short.MIN_VALUE;
1385             case 2:
1386                 return Short.MIN_VALUE;
1387             case 3:
1388                 return Short.MAX_VALUE;
1389             default:
1390                 return (short)0;
1391         }
1392     }
1393 
1394     static final IntFunction<short[]> fr = (vl) -> {
1395         int length = BUFFER_REPS * vl;
1396         return new short[length];
1397     };
1398 
1399     static final IntFunction<boolean[]> fmr = (vl) -> {
1400         int length = BUFFER_REPS * vl;
1401         return new boolean[length];
1402     };
1403 
1404     static final IntFunction<long[]> lfr = (vl) -> {
1405         int length = BUFFER_REPS * vl;
1406         return new long[length];
1407     };
1408 
1409     static void replaceZero(short[] a, short v) {
1410         for (int i = 0; i < a.length; i++) {
1411             if (a[i] == 0) {
1412                 a[i] = v;
1413             }
1414         }
1415     }
1416 
1417     static void replaceZero(short[] a, boolean[] mask, short v) {
1418         for (int i = 0; i < a.length; i++) {
1419             if (mask[i % mask.length] && a[i] == 0) {
1420                 a[i] = v;
1421             }
1422         }
1423     }
1424 
1425     static short ROL_scalar(short a, short b) {
1426         return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15))));
1427     }
1428 
1429     static short ROR_scalar(short a, short b) {
1430         return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
1431     }
1432 
1433     static short TRAILING_ZEROS_COUNT_scalar(short a) {
1434         return (short) (a != 0 ? Integer.numberOfTrailingZeros(a) : 16);
1435     }
1436 
1437     static short LEADING_ZEROS_COUNT_scalar(short a) {
1438         return (short) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 16 : 0);
1439     }
1440 
1441     static short REVERSE_scalar(short a) {
1442         short b = ROL_scalar(a, (short) 8);
1443         b = (short) (((b & 0x5555) << 1) | ((b & 0xAAAA) >>> 1));
1444         b = (short) (((b & 0x3333) << 2) | ((b & 0xCCCC) >>> 2));
1445         b = (short) (((b & 0x0F0F) << 4) | ((b & 0xF0F0) >>> 4));
1446         return b;
1447     }
1448 
1449     static boolean eq(short a, short b) {
1450         return a == b;
1451     }
1452 
1453     static boolean neq(short a, short b) {
1454         return a != b;
1455     }
1456 
1457     static boolean lt(short a, short b) {
1458         return a < b;
1459     }
1460 
1461     static boolean le(short a, short b) {
1462         return a <= b;
1463     }
1464 
1465     static boolean gt(short a, short b) {
1466         return a > b;
1467     }
1468 
1469     static boolean ge(short a, short b) {
1470         return a >= b;
1471     }
1472 
1473     static boolean ult(short a, short b) {
1474         return Short.compareUnsigned(a, b) < 0;
1475     }
1476 
1477     static boolean ule(short a, short b) {
1478         return Short.compareUnsigned(a, b) <= 0;
1479     }
1480 
1481     static boolean ugt(short a, short b) {
1482         return Short.compareUnsigned(a, b) > 0;
1483     }
1484 
1485     static boolean uge(short a, short b) {
1486         return Short.compareUnsigned(a, b) >= 0;
1487     }
1488 
1489     static short firstNonZero(short a, short b) {
1490         return Short.compare(a, (short) 0) != 0 ? a : b;
1491     }
1492 
1493     @Test
1494     static void smokeTest1() {
1495         ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3);
1496         ShortVector three2 = (ShortVector) SPECIES.broadcast(-3);
1497         assert(three.eq(three2).allTrue());
1498         ShortVector three3 = three2.broadcast(1).broadcast(-3);
1499         assert(three.eq(three3).allTrue());
1500         int scale = 2;
1501         Class<?> ETYPE = short.class;
1502         if (ETYPE == double.class || ETYPE == long.class)
1503             scale = 1000000;
1504         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1505             scale = 1;
1506         ShortVector higher = three.addIndex(scale);
1507         VectorMask<Short> m = three.compare(VectorOperators.LE, higher);
1508         assert(m.allTrue());
1509         m = higher.min((short)-1).test(VectorOperators.IS_NEGATIVE);
1510         assert(m.allTrue());
1511         short max = higher.reduceLanes(VectorOperators.MAX);
1512         assert(max == -3 + scale * (SPECIES.length()-1));
1513     }
1514 
1515     private static short[]
1516     bothToArray(ShortVector a, ShortVector b) {
1517         short[] r = new short[a.length() + b.length()];
1518         a.intoArray(r, 0);
1519         b.intoArray(r, a.length());
1520         return r;
1521     }
1522 
1523     @Test
1524     static void smokeTest2() {
1525         // Do some zipping and shuffling.
1526         ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1527         ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1528         Assert.assertEquals(io, io2);
1529         ShortVector a = io.add((short)1); //[1,2]
1530         ShortVector b = a.neg();  //[-1,-2]
1531         short[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1532         VectorShuffle<Short> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1533         VectorShuffle<Short> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1534         ShortVector zab0 = a.rearrange(zip0,b); //[1,-1]
1535         ShortVector zab1 = a.rearrange(zip1,b); //[2,-2]
1536         short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1537         // manually zip
1538         short[] manual = new short[zabValues.length];
1539         for (int i = 0; i < manual.length; i += 2) {
1540             manual[i+0] = abValues[i/2];
1541             manual[i+1] = abValues[a.length() + i/2];
1542         }
1543         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1544         VectorShuffle<Short> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1545         VectorShuffle<Short> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1546         ShortVector uab0 = zab0.rearrange(unz0,zab1);
1547         ShortVector uab1 = zab0.rearrange(unz1,zab1);
1548         short[] abValues1 = bothToArray(uab0, uab1);
1549         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1550     }
1551 
1552     static void iotaShuffle() {
1553         ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1554         ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1555         Assert.assertEquals(io, io2);
1556     }
1557 
1558     @Test
1559     // Test all shuffle related operations.
1560     static void shuffleTest() {
1561         // To test backend instructions, make sure that C2 is used.
1562         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1563             iotaShuffle();
1564         }
1565     }
1566 
1567     @Test
1568     void viewAsIntegeralLanesTest() {
1569         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1570         Assert.assertEquals(asIntegral.species(), SPECIES);
1571     }
1572 
1573     @Test(expectedExceptions = UnsupportedOperationException.class)
1574     void viewAsFloatingLanesTest() {
1575         SPECIES.zero().viewAsFloatingLanes();
1576     }
1577 
1578     @Test
1579     // Test div by 0.
1580     static void bitwiseDivByZeroSmokeTest() {
1581         try {
1582             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1583             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1584             a.div(b);
1585             Assert.fail();
1586         } catch (ArithmeticException e) {
1587         }
1588 
1589         try {
1590             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1591             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1592             VectorMask<Short> m = a.lt((short) 1);
1593             a.div(b, m);
1594             Assert.fail();
1595         } catch (ArithmeticException e) {
1596         }
1597     }
1598 
1599     static short ADD(short a, short b) {
1600         return (short)(a + b);
1601     }
1602 
1603     @Test(dataProvider = "shortBinaryOpProvider")
1604     static void ADDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1605         short[] a = fa.apply(SPECIES.length());
1606         short[] b = fb.apply(SPECIES.length());
1607         short[] r = fr.apply(SPECIES.length());
1608 
1609         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1610             for (int i = 0; i < a.length; i += SPECIES.length()) {
1611                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1612                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1613                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1614             }
1615         }
1616 
1617         assertArraysEquals(r, a, b, ShortMaxVectorTests::ADD);
1618     }
1619 
1620     static short add(short a, short b) {
1621         return (short)(a + b);
1622     }
1623 
1624     @Test(dataProvider = "shortBinaryOpProvider")
1625     static void addShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1626         short[] a = fa.apply(SPECIES.length());
1627         short[] b = fb.apply(SPECIES.length());
1628         short[] r = fr.apply(SPECIES.length());
1629 
1630         for (int i = 0; i < a.length; i += SPECIES.length()) {
1631             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1632             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1633             av.add(bv).intoArray(r, i);
1634         }
1635 
1636         assertArraysEquals(r, a, b, ShortMaxVectorTests::add);
1637     }
1638 
1639     @Test(dataProvider = "shortBinaryOpMaskProvider")
1640     static void ADDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1641                                           IntFunction<boolean[]> fm) {
1642         short[] a = fa.apply(SPECIES.length());
1643         short[] b = fb.apply(SPECIES.length());
1644         short[] r = fr.apply(SPECIES.length());
1645         boolean[] mask = fm.apply(SPECIES.length());
1646         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1647 
1648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1649             for (int i = 0; i < a.length; i += SPECIES.length()) {
1650                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1651                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1652                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1653             }
1654         }
1655 
1656         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD);
1657     }
1658 
1659     @Test(dataProvider = "shortBinaryOpMaskProvider")
1660     static void addShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1661                                           IntFunction<boolean[]> fm) {
1662         short[] a = fa.apply(SPECIES.length());
1663         short[] b = fb.apply(SPECIES.length());
1664         short[] r = fr.apply(SPECIES.length());
1665         boolean[] mask = fm.apply(SPECIES.length());
1666         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1667 
1668         for (int i = 0; i < a.length; i += SPECIES.length()) {
1669             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1670             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1671             av.add(bv, vmask).intoArray(r, i);
1672         }
1673 
1674         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::add);
1675     }
1676 
1677     static short SUB(short a, short b) {
1678         return (short)(a - b);
1679     }
1680 
1681     @Test(dataProvider = "shortBinaryOpProvider")
1682     static void SUBShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1683         short[] a = fa.apply(SPECIES.length());
1684         short[] b = fb.apply(SPECIES.length());
1685         short[] r = fr.apply(SPECIES.length());
1686 
1687         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1688             for (int i = 0; i < a.length; i += SPECIES.length()) {
1689                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1690                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1691                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1692             }
1693         }
1694 
1695         assertArraysEquals(r, a, b, ShortMaxVectorTests::SUB);
1696     }
1697 
1698     static short sub(short a, short b) {
1699         return (short)(a - b);
1700     }
1701 
1702     @Test(dataProvider = "shortBinaryOpProvider")
1703     static void subShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1704         short[] a = fa.apply(SPECIES.length());
1705         short[] b = fb.apply(SPECIES.length());
1706         short[] r = fr.apply(SPECIES.length());
1707 
1708         for (int i = 0; i < a.length; i += SPECIES.length()) {
1709             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1710             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1711             av.sub(bv).intoArray(r, i);
1712         }
1713 
1714         assertArraysEquals(r, a, b, ShortMaxVectorTests::sub);
1715     }
1716 
1717     @Test(dataProvider = "shortBinaryOpMaskProvider")
1718     static void SUBShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1719                                           IntFunction<boolean[]> fm) {
1720         short[] a = fa.apply(SPECIES.length());
1721         short[] b = fb.apply(SPECIES.length());
1722         short[] r = fr.apply(SPECIES.length());
1723         boolean[] mask = fm.apply(SPECIES.length());
1724         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1725 
1726         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1727             for (int i = 0; i < a.length; i += SPECIES.length()) {
1728                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1729                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1730                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1731             }
1732         }
1733 
1734         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUB);
1735     }
1736 
1737     @Test(dataProvider = "shortBinaryOpMaskProvider")
1738     static void subShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1739                                           IntFunction<boolean[]> fm) {
1740         short[] a = fa.apply(SPECIES.length());
1741         short[] b = fb.apply(SPECIES.length());
1742         short[] r = fr.apply(SPECIES.length());
1743         boolean[] mask = fm.apply(SPECIES.length());
1744         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1745 
1746         for (int i = 0; i < a.length; i += SPECIES.length()) {
1747             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1748             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1749             av.sub(bv, vmask).intoArray(r, i);
1750         }
1751 
1752         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub);
1753     }
1754 
1755     static short MUL(short a, short b) {
1756         return (short)(a * b);
1757     }
1758 
1759     @Test(dataProvider = "shortBinaryOpProvider")
1760     static void MULShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1761         short[] a = fa.apply(SPECIES.length());
1762         short[] b = fb.apply(SPECIES.length());
1763         short[] r = fr.apply(SPECIES.length());
1764 
1765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1766             for (int i = 0; i < a.length; i += SPECIES.length()) {
1767                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1768                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1769                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1770             }
1771         }
1772 
1773         assertArraysEquals(r, a, b, ShortMaxVectorTests::MUL);
1774     }
1775 
1776     static short mul(short a, short b) {
1777         return (short)(a * b);
1778     }
1779 
1780     @Test(dataProvider = "shortBinaryOpProvider")
1781     static void mulShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1782         short[] a = fa.apply(SPECIES.length());
1783         short[] b = fb.apply(SPECIES.length());
1784         short[] r = fr.apply(SPECIES.length());
1785 
1786         for (int i = 0; i < a.length; i += SPECIES.length()) {
1787             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1788             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1789             av.mul(bv).intoArray(r, i);
1790         }
1791 
1792         assertArraysEquals(r, a, b, ShortMaxVectorTests::mul);
1793     }
1794 
1795     @Test(dataProvider = "shortBinaryOpMaskProvider")
1796     static void MULShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1797                                           IntFunction<boolean[]> fm) {
1798         short[] a = fa.apply(SPECIES.length());
1799         short[] b = fb.apply(SPECIES.length());
1800         short[] r = fr.apply(SPECIES.length());
1801         boolean[] mask = fm.apply(SPECIES.length());
1802         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1803 
1804         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1805             for (int i = 0; i < a.length; i += SPECIES.length()) {
1806                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1807                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1808                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1809             }
1810         }
1811 
1812         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::MUL);
1813     }
1814 
1815     @Test(dataProvider = "shortBinaryOpMaskProvider")
1816     static void mulShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1817                                           IntFunction<boolean[]> fm) {
1818         short[] a = fa.apply(SPECIES.length());
1819         short[] b = fb.apply(SPECIES.length());
1820         short[] r = fr.apply(SPECIES.length());
1821         boolean[] mask = fm.apply(SPECIES.length());
1822         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1823 
1824         for (int i = 0; i < a.length; i += SPECIES.length()) {
1825             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1826             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1827             av.mul(bv, vmask).intoArray(r, i);
1828         }
1829 
1830         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul);
1831     }
1832 
1833     static short DIV(short a, short b) {
1834         return (short)(a / b);
1835     }
1836 
1837     @Test(dataProvider = "shortBinaryOpProvider")
1838     static void DIVShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1839         short[] a = fa.apply(SPECIES.length());
1840         short[] b = fb.apply(SPECIES.length());
1841         short[] r = fr.apply(SPECIES.length());
1842 
1843         replaceZero(b, (short) 1);
1844 
1845         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1846             for (int i = 0; i < a.length; i += SPECIES.length()) {
1847                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1848                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1849                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1850             }
1851         }
1852 
1853         assertArraysEquals(r, a, b, ShortMaxVectorTests::DIV);
1854     }
1855 
1856     static short div(short a, short b) {
1857         return (short)(a / b);
1858     }
1859 
1860     @Test(dataProvider = "shortBinaryOpProvider")
1861     static void divShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1862         short[] a = fa.apply(SPECIES.length());
1863         short[] b = fb.apply(SPECIES.length());
1864         short[] r = fr.apply(SPECIES.length());
1865 
1866         replaceZero(b, (short) 1);
1867 
1868         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1869             for (int i = 0; i < a.length; i += SPECIES.length()) {
1870                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1871                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1872                 av.div(bv).intoArray(r, i);
1873             }
1874         }
1875 
1876         assertArraysEquals(r, a, b, ShortMaxVectorTests::div);
1877     }
1878 
1879     @Test(dataProvider = "shortBinaryOpMaskProvider")
1880     static void DIVShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1881                                           IntFunction<boolean[]> fm) {
1882         short[] a = fa.apply(SPECIES.length());
1883         short[] b = fb.apply(SPECIES.length());
1884         short[] r = fr.apply(SPECIES.length());
1885         boolean[] mask = fm.apply(SPECIES.length());
1886         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1887 
1888         replaceZero(b, mask, (short) 1);
1889 
1890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1891             for (int i = 0; i < a.length; i += SPECIES.length()) {
1892                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1893                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1894                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1895             }
1896         }
1897 
1898         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::DIV);
1899     }
1900 
1901     @Test(dataProvider = "shortBinaryOpMaskProvider")
1902     static void divShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1903                                           IntFunction<boolean[]> fm) {
1904         short[] a = fa.apply(SPECIES.length());
1905         short[] b = fb.apply(SPECIES.length());
1906         short[] r = fr.apply(SPECIES.length());
1907         boolean[] mask = fm.apply(SPECIES.length());
1908         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1909 
1910         replaceZero(b, mask, (short) 1);
1911 
1912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1913             for (int i = 0; i < a.length; i += SPECIES.length()) {
1914                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1915                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1916                 av.div(bv, vmask).intoArray(r, i);
1917             }
1918         }
1919 
1920         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::div);
1921     }
1922 
1923     static short FIRST_NONZERO(short a, short b) {
1924         return (short)((a)!=0?a:b);
1925     }
1926 
1927     @Test(dataProvider = "shortBinaryOpProvider")
1928     static void FIRST_NONZEROShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1929         short[] a = fa.apply(SPECIES.length());
1930         short[] b = fb.apply(SPECIES.length());
1931         short[] r = fr.apply(SPECIES.length());
1932 
1933         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1934             for (int i = 0; i < a.length; i += SPECIES.length()) {
1935                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1936                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1937                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1938             }
1939         }
1940 
1941         assertArraysEquals(r, a, b, ShortMaxVectorTests::FIRST_NONZERO);
1942     }
1943 
1944     @Test(dataProvider = "shortBinaryOpMaskProvider")
1945     static void FIRST_NONZEROShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1946                                           IntFunction<boolean[]> fm) {
1947         short[] a = fa.apply(SPECIES.length());
1948         short[] b = fb.apply(SPECIES.length());
1949         short[] r = fr.apply(SPECIES.length());
1950         boolean[] mask = fm.apply(SPECIES.length());
1951         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1952 
1953         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1954             for (int i = 0; i < a.length; i += SPECIES.length()) {
1955                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1956                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1957                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1958             }
1959         }
1960 
1961         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::FIRST_NONZERO);
1962     }
1963 
1964     static short AND(short a, short b) {
1965         return (short)(a & b);
1966     }
1967 
1968     @Test(dataProvider = "shortBinaryOpProvider")
1969     static void ANDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1970         short[] a = fa.apply(SPECIES.length());
1971         short[] b = fb.apply(SPECIES.length());
1972         short[] r = fr.apply(SPECIES.length());
1973 
1974         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1975             for (int i = 0; i < a.length; i += SPECIES.length()) {
1976                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1977                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1978                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1979             }
1980         }
1981 
1982         assertArraysEquals(r, a, b, ShortMaxVectorTests::AND);
1983     }
1984 
1985     static short and(short a, short b) {
1986         return (short)(a & b);
1987     }
1988 
1989     @Test(dataProvider = "shortBinaryOpProvider")
1990     static void andShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1991         short[] a = fa.apply(SPECIES.length());
1992         short[] b = fb.apply(SPECIES.length());
1993         short[] r = fr.apply(SPECIES.length());
1994 
1995         for (int i = 0; i < a.length; i += SPECIES.length()) {
1996             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1997             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1998             av.and(bv).intoArray(r, i);
1999         }
2000 
2001         assertArraysEquals(r, a, b, ShortMaxVectorTests::and);
2002     }
2003 
2004     @Test(dataProvider = "shortBinaryOpMaskProvider")
2005     static void ANDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2006                                           IntFunction<boolean[]> fm) {
2007         short[] a = fa.apply(SPECIES.length());
2008         short[] b = fb.apply(SPECIES.length());
2009         short[] r = fr.apply(SPECIES.length());
2010         boolean[] mask = fm.apply(SPECIES.length());
2011         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2012 
2013         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2014             for (int i = 0; i < a.length; i += SPECIES.length()) {
2015                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2016                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2017                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
2018             }
2019         }
2020 
2021         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND);
2022     }
2023 
2024     static short AND_NOT(short a, short b) {
2025         return (short)(a & ~b);
2026     }
2027 
2028     @Test(dataProvider = "shortBinaryOpProvider")
2029     static void AND_NOTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2030         short[] a = fa.apply(SPECIES.length());
2031         short[] b = fb.apply(SPECIES.length());
2032         short[] r = fr.apply(SPECIES.length());
2033 
2034         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2035             for (int i = 0; i < a.length; i += SPECIES.length()) {
2036                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2037                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2038                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
2039             }
2040         }
2041 
2042         assertArraysEquals(r, a, b, ShortMaxVectorTests::AND_NOT);
2043     }
2044 
2045     @Test(dataProvider = "shortBinaryOpMaskProvider")
2046     static void AND_NOTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2047                                           IntFunction<boolean[]> fm) {
2048         short[] a = fa.apply(SPECIES.length());
2049         short[] b = fb.apply(SPECIES.length());
2050         short[] r = fr.apply(SPECIES.length());
2051         boolean[] mask = fm.apply(SPECIES.length());
2052         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2053 
2054         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2055             for (int i = 0; i < a.length; i += SPECIES.length()) {
2056                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2057                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2058                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
2059             }
2060         }
2061 
2062         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND_NOT);
2063     }
2064 
2065     static short OR(short a, short b) {
2066         return (short)(a | b);
2067     }
2068 
2069     @Test(dataProvider = "shortBinaryOpProvider")
2070     static void ORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2071         short[] a = fa.apply(SPECIES.length());
2072         short[] b = fb.apply(SPECIES.length());
2073         short[] r = fr.apply(SPECIES.length());
2074 
2075         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2076             for (int i = 0; i < a.length; i += SPECIES.length()) {
2077                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2078                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2079                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
2080             }
2081         }
2082 
2083         assertArraysEquals(r, a, b, ShortMaxVectorTests::OR);
2084     }
2085 
2086     static short or(short a, short b) {
2087         return (short)(a | b);
2088     }
2089 
2090     @Test(dataProvider = "shortBinaryOpProvider")
2091     static void orShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2092         short[] a = fa.apply(SPECIES.length());
2093         short[] b = fb.apply(SPECIES.length());
2094         short[] r = fr.apply(SPECIES.length());
2095 
2096         for (int i = 0; i < a.length; i += SPECIES.length()) {
2097             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2098             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2099             av.or(bv).intoArray(r, i);
2100         }
2101 
2102         assertArraysEquals(r, a, b, ShortMaxVectorTests::or);
2103     }
2104 
2105     @Test(dataProvider = "shortBinaryOpMaskProvider")
2106     static void ORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2107                                           IntFunction<boolean[]> fm) {
2108         short[] a = fa.apply(SPECIES.length());
2109         short[] b = fb.apply(SPECIES.length());
2110         short[] r = fr.apply(SPECIES.length());
2111         boolean[] mask = fm.apply(SPECIES.length());
2112         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2113 
2114         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2115             for (int i = 0; i < a.length; i += SPECIES.length()) {
2116                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2117                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2118                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
2119             }
2120         }
2121 
2122         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR);
2123     }
2124 
2125     static short XOR(short a, short b) {
2126         return (short)(a ^ b);
2127     }
2128 
2129     @Test(dataProvider = "shortBinaryOpProvider")
2130     static void XORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2131         short[] a = fa.apply(SPECIES.length());
2132         short[] b = fb.apply(SPECIES.length());
2133         short[] r = fr.apply(SPECIES.length());
2134 
2135         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2136             for (int i = 0; i < a.length; i += SPECIES.length()) {
2137                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2138                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2139                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
2140             }
2141         }
2142 
2143         assertArraysEquals(r, a, b, ShortMaxVectorTests::XOR);
2144     }
2145 
2146     @Test(dataProvider = "shortBinaryOpMaskProvider")
2147     static void XORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2148                                           IntFunction<boolean[]> fm) {
2149         short[] a = fa.apply(SPECIES.length());
2150         short[] b = fb.apply(SPECIES.length());
2151         short[] r = fr.apply(SPECIES.length());
2152         boolean[] mask = fm.apply(SPECIES.length());
2153         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2154 
2155         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2156             for (int i = 0; i < a.length; i += SPECIES.length()) {
2157                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2158                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2159                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
2160             }
2161         }
2162 
2163         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::XOR);
2164     }
2165 
2166     @Test(dataProvider = "shortBinaryOpProvider")
2167     static void addShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2168         short[] a = fa.apply(SPECIES.length());
2169         short[] b = fb.apply(SPECIES.length());
2170         short[] r = fr.apply(SPECIES.length());
2171 
2172         for (int i = 0; i < a.length; i += SPECIES.length()) {
2173             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2174             av.add(b[i]).intoArray(r, i);
2175         }
2176 
2177         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::add);
2178     }
2179 
2180     @Test(dataProvider = "shortBinaryOpMaskProvider")
2181     static void addShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2182                                           IntFunction<boolean[]> fm) {
2183         short[] a = fa.apply(SPECIES.length());
2184         short[] b = fb.apply(SPECIES.length());
2185         short[] r = fr.apply(SPECIES.length());
2186         boolean[] mask = fm.apply(SPECIES.length());
2187         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2188 
2189         for (int i = 0; i < a.length; i += SPECIES.length()) {
2190             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2191             av.add(b[i], vmask).intoArray(r, i);
2192         }
2193 
2194         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::add);
2195     }
2196 
2197     @Test(dataProvider = "shortBinaryOpProvider")
2198     static void subShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2199         short[] a = fa.apply(SPECIES.length());
2200         short[] b = fb.apply(SPECIES.length());
2201         short[] r = fr.apply(SPECIES.length());
2202 
2203         for (int i = 0; i < a.length; i += SPECIES.length()) {
2204             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2205             av.sub(b[i]).intoArray(r, i);
2206         }
2207 
2208         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::sub);
2209     }
2210 
2211     @Test(dataProvider = "shortBinaryOpMaskProvider")
2212     static void subShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2213                                           IntFunction<boolean[]> fm) {
2214         short[] a = fa.apply(SPECIES.length());
2215         short[] b = fb.apply(SPECIES.length());
2216         short[] r = fr.apply(SPECIES.length());
2217         boolean[] mask = fm.apply(SPECIES.length());
2218         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2219 
2220         for (int i = 0; i < a.length; i += SPECIES.length()) {
2221             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2222             av.sub(b[i], vmask).intoArray(r, i);
2223         }
2224 
2225         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::sub);
2226     }
2227 
2228     @Test(dataProvider = "shortBinaryOpProvider")
2229     static void mulShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2230         short[] a = fa.apply(SPECIES.length());
2231         short[] b = fb.apply(SPECIES.length());
2232         short[] r = fr.apply(SPECIES.length());
2233 
2234         for (int i = 0; i < a.length; i += SPECIES.length()) {
2235             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2236             av.mul(b[i]).intoArray(r, i);
2237         }
2238 
2239         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::mul);
2240     }
2241 
2242     @Test(dataProvider = "shortBinaryOpMaskProvider")
2243     static void mulShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2244                                           IntFunction<boolean[]> fm) {
2245         short[] a = fa.apply(SPECIES.length());
2246         short[] b = fb.apply(SPECIES.length());
2247         short[] r = fr.apply(SPECIES.length());
2248         boolean[] mask = fm.apply(SPECIES.length());
2249         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2250 
2251         for (int i = 0; i < a.length; i += SPECIES.length()) {
2252             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2253             av.mul(b[i], vmask).intoArray(r, i);
2254         }
2255 
2256         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::mul);
2257     }
2258 
2259     @Test(dataProvider = "shortBinaryOpProvider")
2260     static void divShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2261         short[] a = fa.apply(SPECIES.length());
2262         short[] b = fb.apply(SPECIES.length());
2263         short[] r = fr.apply(SPECIES.length());
2264 
2265         replaceZero(b, (short) 1);
2266 
2267         for (int i = 0; i < a.length; i += SPECIES.length()) {
2268             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2269             av.div(b[i]).intoArray(r, i);
2270         }
2271 
2272         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::div);
2273     }
2274 
2275     @Test(dataProvider = "shortBinaryOpMaskProvider")
2276     static void divShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2277                                           IntFunction<boolean[]> fm) {
2278         short[] a = fa.apply(SPECIES.length());
2279         short[] b = fb.apply(SPECIES.length());
2280         short[] r = fr.apply(SPECIES.length());
2281         boolean[] mask = fm.apply(SPECIES.length());
2282         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2283 
2284         replaceZero(b, (short) 1);
2285 
2286         for (int i = 0; i < a.length; i += SPECIES.length()) {
2287             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2288             av.div(b[i], vmask).intoArray(r, i);
2289         }
2290 
2291         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::div);
2292     }
2293 
2294     @Test(dataProvider = "shortBinaryOpProvider")
2295     static void ORShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2296         short[] a = fa.apply(SPECIES.length());
2297         short[] b = fb.apply(SPECIES.length());
2298         short[] r = fr.apply(SPECIES.length());
2299 
2300         for (int i = 0; i < a.length; i += SPECIES.length()) {
2301             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2302             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2303         }
2304 
2305         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::OR);
2306     }
2307 
2308     @Test(dataProvider = "shortBinaryOpProvider")
2309     static void orShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2310         short[] a = fa.apply(SPECIES.length());
2311         short[] b = fb.apply(SPECIES.length());
2312         short[] r = fr.apply(SPECIES.length());
2313 
2314         for (int i = 0; i < a.length; i += SPECIES.length()) {
2315             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2316             av.or(b[i]).intoArray(r, i);
2317         }
2318 
2319         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::or);
2320     }
2321 
2322     @Test(dataProvider = "shortBinaryOpMaskProvider")
2323     static void ORShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2324                                           IntFunction<boolean[]> fm) {
2325         short[] a = fa.apply(SPECIES.length());
2326         short[] b = fb.apply(SPECIES.length());
2327         short[] r = fr.apply(SPECIES.length());
2328         boolean[] mask = fm.apply(SPECIES.length());
2329         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2330 
2331         for (int i = 0; i < a.length; i += SPECIES.length()) {
2332             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2333             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2334         }
2335 
2336         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR);
2337     }
2338 
2339     @Test(dataProvider = "shortBinaryOpProvider")
2340     static void ANDShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2341         short[] a = fa.apply(SPECIES.length());
2342         short[] b = fb.apply(SPECIES.length());
2343         short[] r = fr.apply(SPECIES.length());
2344 
2345         for (int i = 0; i < a.length; i += SPECIES.length()) {
2346             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2347             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2348         }
2349 
2350         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::AND);
2351     }
2352 
2353     @Test(dataProvider = "shortBinaryOpProvider")
2354     static void andShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2355         short[] a = fa.apply(SPECIES.length());
2356         short[] b = fb.apply(SPECIES.length());
2357         short[] r = fr.apply(SPECIES.length());
2358 
2359         for (int i = 0; i < a.length; i += SPECIES.length()) {
2360             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2361             av.and(b[i]).intoArray(r, i);
2362         }
2363 
2364         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::and);
2365     }
2366 
2367     @Test(dataProvider = "shortBinaryOpMaskProvider")
2368     static void ANDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2369                                           IntFunction<boolean[]> fm) {
2370         short[] a = fa.apply(SPECIES.length());
2371         short[] b = fb.apply(SPECIES.length());
2372         short[] r = fr.apply(SPECIES.length());
2373         boolean[] mask = fm.apply(SPECIES.length());
2374         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2375 
2376         for (int i = 0; i < a.length; i += SPECIES.length()) {
2377             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2378             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2379         }
2380 
2381         assertBroadcastArraysEquals(r, a, b, mask, ShortMaxVectorTests::AND);
2382     }
2383 
2384     @Test(dataProvider = "shortBinaryOpProvider")
2385     static void ORShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2386         short[] a = fa.apply(SPECIES.length());
2387         short[] b = fb.apply(SPECIES.length());
2388         short[] r = fr.apply(SPECIES.length());
2389 
2390         for (int i = 0; i < a.length; i += SPECIES.length()) {
2391             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2392             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2393         }
2394 
2395         assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::OR);
2396     }
2397 
2398     @Test(dataProvider = "shortBinaryOpMaskProvider")
2399     static void ORShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2400                                           IntFunction<boolean[]> fm) {
2401         short[] a = fa.apply(SPECIES.length());
2402         short[] b = fb.apply(SPECIES.length());
2403         short[] r = fr.apply(SPECIES.length());
2404         boolean[] mask = fm.apply(SPECIES.length());
2405         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2406 
2407         for (int i = 0; i < a.length; i += SPECIES.length()) {
2408             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2409             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2410         }
2411 
2412         assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::OR);
2413     }
2414 
2415     @Test(dataProvider = "shortBinaryOpProvider")
2416     static void ADDShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2417         short[] a = fa.apply(SPECIES.length());
2418         short[] b = fb.apply(SPECIES.length());
2419         short[] r = fr.apply(SPECIES.length());
2420 
2421         for (int i = 0; i < a.length; i += SPECIES.length()) {
2422             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2423             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2424         }
2425 
2426         assertBroadcastLongArraysEquals(r, a, b, ShortMaxVectorTests::ADD);
2427     }
2428 
2429     @Test(dataProvider = "shortBinaryOpMaskProvider")
2430     static void ADDShortMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2431                                           IntFunction<boolean[]> fm) {
2432         short[] a = fa.apply(SPECIES.length());
2433         short[] b = fb.apply(SPECIES.length());
2434         short[] r = fr.apply(SPECIES.length());
2435         boolean[] mask = fm.apply(SPECIES.length());
2436         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2437 
2438         for (int i = 0; i < a.length; i += SPECIES.length()) {
2439             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2440             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2441         }
2442 
2443         assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::ADD);
2444     }
2445 
2446     static short LSHL(short a, short b) {
2447         return (short)((a << (b & 0xF)));
2448     }
2449 
2450     @Test(dataProvider = "shortBinaryOpProvider")
2451     static void LSHLShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2452         short[] a = fa.apply(SPECIES.length());
2453         short[] b = fb.apply(SPECIES.length());
2454         short[] r = fr.apply(SPECIES.length());
2455 
2456         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2457             for (int i = 0; i < a.length; i += SPECIES.length()) {
2458                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2459                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2460                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2461             }
2462         }
2463 
2464         assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHL);
2465     }
2466 
2467     @Test(dataProvider = "shortBinaryOpMaskProvider")
2468     static void LSHLShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2469                                           IntFunction<boolean[]> fm) {
2470         short[] a = fa.apply(SPECIES.length());
2471         short[] b = fb.apply(SPECIES.length());
2472         short[] r = fr.apply(SPECIES.length());
2473         boolean[] mask = fm.apply(SPECIES.length());
2474         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2475 
2476         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2477             for (int i = 0; i < a.length; i += SPECIES.length()) {
2478                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2479                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2480                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2481             }
2482         }
2483 
2484         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL);
2485     }
2486 
2487     static short ASHR(short a, short b) {
2488         return (short)((a >> (b & 0xF)));
2489     }
2490 
2491     @Test(dataProvider = "shortBinaryOpProvider")
2492     static void ASHRShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2493         short[] a = fa.apply(SPECIES.length());
2494         short[] b = fb.apply(SPECIES.length());
2495         short[] r = fr.apply(SPECIES.length());
2496 
2497         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2498             for (int i = 0; i < a.length; i += SPECIES.length()) {
2499                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2500                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2501                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2502             }
2503         }
2504 
2505         assertArraysEquals(r, a, b, ShortMaxVectorTests::ASHR);
2506     }
2507 
2508     @Test(dataProvider = "shortBinaryOpMaskProvider")
2509     static void ASHRShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2510                                           IntFunction<boolean[]> fm) {
2511         short[] a = fa.apply(SPECIES.length());
2512         short[] b = fb.apply(SPECIES.length());
2513         short[] r = fr.apply(SPECIES.length());
2514         boolean[] mask = fm.apply(SPECIES.length());
2515         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2516 
2517         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2518             for (int i = 0; i < a.length; i += SPECIES.length()) {
2519                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2520                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2521                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2522             }
2523         }
2524 
2525         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR);
2526     }
2527 
2528     static short LSHR(short a, short b) {
2529         return (short)(((a & 0xFFFF) >>> (b & 0xF)));
2530     }
2531 
2532     @Test(dataProvider = "shortBinaryOpProvider")
2533     static void LSHRShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2534         short[] a = fa.apply(SPECIES.length());
2535         short[] b = fb.apply(SPECIES.length());
2536         short[] r = fr.apply(SPECIES.length());
2537 
2538         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2539             for (int i = 0; i < a.length; i += SPECIES.length()) {
2540                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2541                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2542                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2543             }
2544         }
2545 
2546         assertArraysEquals(r, a, b, ShortMaxVectorTests::LSHR);
2547     }
2548 
2549     @Test(dataProvider = "shortBinaryOpMaskProvider")
2550     static void LSHRShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2551                                           IntFunction<boolean[]> fm) {
2552         short[] a = fa.apply(SPECIES.length());
2553         short[] b = fb.apply(SPECIES.length());
2554         short[] r = fr.apply(SPECIES.length());
2555         boolean[] mask = fm.apply(SPECIES.length());
2556         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2557 
2558         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2559             for (int i = 0; i < a.length; i += SPECIES.length()) {
2560                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2561                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2562                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2563             }
2564         }
2565 
2566         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR);
2567     }
2568 
2569     static short LSHL_unary(short a, short b) {
2570         return (short)((a << (b & 15)));
2571     }
2572 
2573     @Test(dataProvider = "shortBinaryOpProvider")
2574     static void LSHLShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2575         short[] a = fa.apply(SPECIES.length());
2576         short[] b = fb.apply(SPECIES.length());
2577         short[] r = fr.apply(SPECIES.length());
2578 
2579         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2580             for (int i = 0; i < a.length; i += SPECIES.length()) {
2581                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2582                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2583             }
2584         }
2585 
2586         assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHL_unary);
2587     }
2588 
2589     @Test(dataProvider = "shortBinaryOpMaskProvider")
2590     static void LSHLShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2591                                           IntFunction<boolean[]> fm) {
2592         short[] a = fa.apply(SPECIES.length());
2593         short[] b = fb.apply(SPECIES.length());
2594         short[] r = fr.apply(SPECIES.length());
2595         boolean[] mask = fm.apply(SPECIES.length());
2596         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2597 
2598         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2599             for (int i = 0; i < a.length; i += SPECIES.length()) {
2600                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2601                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2602             }
2603         }
2604 
2605         assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHL_unary);
2606     }
2607 
2608     static short LSHR_unary(short a, short b) {
2609         return (short)(((a & 0xFFFF) >>> (b & 15)));
2610     }
2611 
2612     @Test(dataProvider = "shortBinaryOpProvider")
2613     static void LSHRShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2614         short[] a = fa.apply(SPECIES.length());
2615         short[] b = fb.apply(SPECIES.length());
2616         short[] r = fr.apply(SPECIES.length());
2617 
2618         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2619             for (int i = 0; i < a.length; i += SPECIES.length()) {
2620                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2621                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2622             }
2623         }
2624 
2625         assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::LSHR_unary);
2626     }
2627 
2628     @Test(dataProvider = "shortBinaryOpMaskProvider")
2629     static void LSHRShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2630                                           IntFunction<boolean[]> fm) {
2631         short[] a = fa.apply(SPECIES.length());
2632         short[] b = fb.apply(SPECIES.length());
2633         short[] r = fr.apply(SPECIES.length());
2634         boolean[] mask = fm.apply(SPECIES.length());
2635         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2636 
2637         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2638             for (int i = 0; i < a.length; i += SPECIES.length()) {
2639                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2640                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2641             }
2642         }
2643 
2644         assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::LSHR_unary);
2645     }
2646 
2647     static short ASHR_unary(short a, short b) {
2648         return (short)((a >> (b & 15)));
2649     }
2650 
2651     @Test(dataProvider = "shortBinaryOpProvider")
2652     static void ASHRShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2653         short[] a = fa.apply(SPECIES.length());
2654         short[] b = fb.apply(SPECIES.length());
2655         short[] r = fr.apply(SPECIES.length());
2656 
2657         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2658             for (int i = 0; i < a.length; i += SPECIES.length()) {
2659                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2660                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2661             }
2662         }
2663 
2664         assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ASHR_unary);
2665     }
2666 
2667     @Test(dataProvider = "shortBinaryOpMaskProvider")
2668     static void ASHRShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2669                                           IntFunction<boolean[]> fm) {
2670         short[] a = fa.apply(SPECIES.length());
2671         short[] b = fb.apply(SPECIES.length());
2672         short[] r = fr.apply(SPECIES.length());
2673         boolean[] mask = fm.apply(SPECIES.length());
2674         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2675 
2676         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2677             for (int i = 0; i < a.length; i += SPECIES.length()) {
2678                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2679                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2680             }
2681         }
2682 
2683         assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ASHR_unary);
2684     }
2685 
2686     static short ROR(short a, short b) {
2687         return (short)(ROR_scalar(a,b));
2688     }
2689 
2690     @Test(dataProvider = "shortBinaryOpProvider")
2691     static void RORShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2692         short[] a = fa.apply(SPECIES.length());
2693         short[] b = fb.apply(SPECIES.length());
2694         short[] r = fr.apply(SPECIES.length());
2695 
2696         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2697             for (int i = 0; i < a.length; i += SPECIES.length()) {
2698                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2699                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2700                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2701             }
2702         }
2703 
2704         assertArraysEquals(r, a, b, ShortMaxVectorTests::ROR);
2705     }
2706 
2707     @Test(dataProvider = "shortBinaryOpMaskProvider")
2708     static void RORShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2709                                           IntFunction<boolean[]> fm) {
2710         short[] a = fa.apply(SPECIES.length());
2711         short[] b = fb.apply(SPECIES.length());
2712         short[] r = fr.apply(SPECIES.length());
2713         boolean[] mask = fm.apply(SPECIES.length());
2714         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2715 
2716         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2717             for (int i = 0; i < a.length; i += SPECIES.length()) {
2718                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2719                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2720                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2721             }
2722         }
2723 
2724         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR);
2725     }
2726 
2727     static short ROL(short a, short b) {
2728         return (short)(ROL_scalar(a,b));
2729     }
2730 
2731     @Test(dataProvider = "shortBinaryOpProvider")
2732     static void ROLShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2733         short[] a = fa.apply(SPECIES.length());
2734         short[] b = fb.apply(SPECIES.length());
2735         short[] r = fr.apply(SPECIES.length());
2736 
2737         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2738             for (int i = 0; i < a.length; i += SPECIES.length()) {
2739                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2740                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2741                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2742             }
2743         }
2744 
2745         assertArraysEquals(r, a, b, ShortMaxVectorTests::ROL);
2746     }
2747 
2748     @Test(dataProvider = "shortBinaryOpMaskProvider")
2749     static void ROLShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2750                                           IntFunction<boolean[]> fm) {
2751         short[] a = fa.apply(SPECIES.length());
2752         short[] b = fb.apply(SPECIES.length());
2753         short[] r = fr.apply(SPECIES.length());
2754         boolean[] mask = fm.apply(SPECIES.length());
2755         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2756 
2757         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2758             for (int i = 0; i < a.length; i += SPECIES.length()) {
2759                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2760                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2761                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2762             }
2763         }
2764 
2765         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL);
2766     }
2767 
2768     static short ROR_unary(short a, short b) {
2769         return (short)(ROR_scalar(a, b));
2770     }
2771 
2772     @Test(dataProvider = "shortBinaryOpProvider")
2773     static void RORShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2774         short[] a = fa.apply(SPECIES.length());
2775         short[] b = fb.apply(SPECIES.length());
2776         short[] r = fr.apply(SPECIES.length());
2777 
2778         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2779             for (int i = 0; i < a.length; i += SPECIES.length()) {
2780                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2781                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2782             }
2783         }
2784 
2785         assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROR_unary);
2786     }
2787 
2788     @Test(dataProvider = "shortBinaryOpMaskProvider")
2789     static void RORShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2790                                           IntFunction<boolean[]> fm) {
2791         short[] a = fa.apply(SPECIES.length());
2792         short[] b = fb.apply(SPECIES.length());
2793         short[] r = fr.apply(SPECIES.length());
2794         boolean[] mask = fm.apply(SPECIES.length());
2795         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2796 
2797         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2798             for (int i = 0; i < a.length; i += SPECIES.length()) {
2799                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2800                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2801             }
2802         }
2803 
2804         assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROR_unary);
2805     }
2806 
2807     static short ROL_unary(short a, short b) {
2808         return (short)(ROL_scalar(a, b));
2809     }
2810 
2811     @Test(dataProvider = "shortBinaryOpProvider")
2812     static void ROLShortMaxVectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2813         short[] a = fa.apply(SPECIES.length());
2814         short[] b = fb.apply(SPECIES.length());
2815         short[] r = fr.apply(SPECIES.length());
2816 
2817         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2818             for (int i = 0; i < a.length; i += SPECIES.length()) {
2819                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2820                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2821             }
2822         }
2823 
2824         assertShiftArraysEquals(r, a, b, ShortMaxVectorTests::ROL_unary);
2825     }
2826 
2827     @Test(dataProvider = "shortBinaryOpMaskProvider")
2828     static void ROLShortMaxVectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2829                                           IntFunction<boolean[]> fm) {
2830         short[] a = fa.apply(SPECIES.length());
2831         short[] b = fb.apply(SPECIES.length());
2832         short[] r = fr.apply(SPECIES.length());
2833         boolean[] mask = fm.apply(SPECIES.length());
2834         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2835 
2836         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2837             for (int i = 0; i < a.length; i += SPECIES.length()) {
2838                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2839                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2840             }
2841         }
2842 
2843         assertShiftArraysEquals(r, a, b, mask, ShortMaxVectorTests::ROL_unary);
2844     }
2845     static short LSHR_binary_const(short a) {
2846         return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
2847     }
2848 
2849     @Test(dataProvider = "shortUnaryOpProvider")
2850     static void LSHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2851         short[] a = fa.apply(SPECIES.length());
2852         short[] r = fr.apply(SPECIES.length());
2853 
2854         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2855             for (int i = 0; i < a.length; i += SPECIES.length()) {
2856                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2857                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2858             }
2859         }
2860 
2861         assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHR_binary_const);
2862     }
2863 
2864     @Test(dataProvider = "shortUnaryOpMaskProvider")
2865     static void LSHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2866                                           IntFunction<boolean[]> fm) {
2867         short[] a = fa.apply(SPECIES.length());
2868         short[] r = fr.apply(SPECIES.length());
2869         boolean[] mask = fm.apply(SPECIES.length());
2870         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2871 
2872         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2873             for (int i = 0; i < a.length; i += SPECIES.length()) {
2874                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2875                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2876             }
2877         }
2878 
2879         assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHR_binary_const);
2880     }
2881 
2882     static short LSHL_binary_const(short a) {
2883         return (short)((a << CONST_SHIFT));
2884     }
2885 
2886     @Test(dataProvider = "shortUnaryOpProvider")
2887     static void LSHLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2888         short[] a = fa.apply(SPECIES.length());
2889         short[] r = fr.apply(SPECIES.length());
2890 
2891         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2892             for (int i = 0; i < a.length; i += SPECIES.length()) {
2893                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2894                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2895             }
2896         }
2897 
2898         assertShiftConstEquals(r, a, ShortMaxVectorTests::LSHL_binary_const);
2899     }
2900 
2901     @Test(dataProvider = "shortUnaryOpMaskProvider")
2902     static void LSHLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2903                                           IntFunction<boolean[]> fm) {
2904         short[] a = fa.apply(SPECIES.length());
2905         short[] r = fr.apply(SPECIES.length());
2906         boolean[] mask = fm.apply(SPECIES.length());
2907         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2908 
2909         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2910             for (int i = 0; i < a.length; i += SPECIES.length()) {
2911                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2912                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2913             }
2914         }
2915 
2916         assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::LSHL_binary_const);
2917     }
2918 
2919     static short ASHR_binary_const(short a) {
2920         return (short)((a >> CONST_SHIFT));
2921     }
2922 
2923     @Test(dataProvider = "shortUnaryOpProvider")
2924     static void ASHRShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2925         short[] a = fa.apply(SPECIES.length());
2926         short[] r = fr.apply(SPECIES.length());
2927 
2928         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2929             for (int i = 0; i < a.length; i += SPECIES.length()) {
2930                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2931                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2932             }
2933         }
2934 
2935         assertShiftConstEquals(r, a, ShortMaxVectorTests::ASHR_binary_const);
2936     }
2937 
2938     @Test(dataProvider = "shortUnaryOpMaskProvider")
2939     static void ASHRShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2940                                           IntFunction<boolean[]> fm) {
2941         short[] a = fa.apply(SPECIES.length());
2942         short[] r = fr.apply(SPECIES.length());
2943         boolean[] mask = fm.apply(SPECIES.length());
2944         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2945 
2946         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2947             for (int i = 0; i < a.length; i += SPECIES.length()) {
2948                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2949                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2950             }
2951         }
2952 
2953         assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ASHR_binary_const);
2954     }
2955 
2956     static short ROR_binary_const(short a) {
2957         return (short)(ROR_scalar(a, CONST_SHIFT));
2958     }
2959 
2960     @Test(dataProvider = "shortUnaryOpProvider")
2961     static void RORShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2962         short[] a = fa.apply(SPECIES.length());
2963         short[] r = fr.apply(SPECIES.length());
2964 
2965         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2966             for (int i = 0; i < a.length; i += SPECIES.length()) {
2967                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2968                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2969             }
2970         }
2971 
2972         assertShiftConstEquals(r, a, ShortMaxVectorTests::ROR_binary_const);
2973     }
2974 
2975     @Test(dataProvider = "shortUnaryOpMaskProvider")
2976     static void RORShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2977                                           IntFunction<boolean[]> fm) {
2978         short[] a = fa.apply(SPECIES.length());
2979         short[] r = fr.apply(SPECIES.length());
2980         boolean[] mask = fm.apply(SPECIES.length());
2981         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2982 
2983         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2984             for (int i = 0; i < a.length; i += SPECIES.length()) {
2985                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2986                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2987             }
2988         }
2989 
2990         assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROR_binary_const);
2991     }
2992 
2993     static short ROL_binary_const(short a) {
2994         return (short)(ROL_scalar(a, CONST_SHIFT));
2995     }
2996 
2997     @Test(dataProvider = "shortUnaryOpProvider")
2998     static void ROLShortMaxVectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2999         short[] a = fa.apply(SPECIES.length());
3000         short[] r = fr.apply(SPECIES.length());
3001 
3002         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3003             for (int i = 0; i < a.length; i += SPECIES.length()) {
3004                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3005                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
3006             }
3007         }
3008 
3009         assertShiftConstEquals(r, a, ShortMaxVectorTests::ROL_binary_const);
3010     }
3011 
3012     @Test(dataProvider = "shortUnaryOpMaskProvider")
3013     static void ROLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
3014                                           IntFunction<boolean[]> fm) {
3015         short[] a = fa.apply(SPECIES.length());
3016         short[] r = fr.apply(SPECIES.length());
3017         boolean[] mask = fm.apply(SPECIES.length());
3018         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3019 
3020         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3021             for (int i = 0; i < a.length; i += SPECIES.length()) {
3022                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3023                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
3024             }
3025         }
3026 
3027         assertShiftConstEquals(r, a, mask, ShortMaxVectorTests::ROL_binary_const);
3028     }
3029 
3030 
3031     static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10);
3032 
3033     @Test(dataProvider = "shortUnaryOpProvider")
3034     static void MINShortMaxVectorTestsWithMemOp(IntFunction<short[]> fa) {
3035         short[] a = fa.apply(SPECIES.length());
3036         short[] r = fr.apply(SPECIES.length());
3037 
3038         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3039             for (int i = 0; i < a.length; i += SPECIES.length()) {
3040                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3041                 av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i);
3042             }
3043         }
3044 
3045         assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MIN);
3046     }
3047 
3048     static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10);
3049 
3050     @Test(dataProvider = "shortUnaryOpProvider")
3051     static void minShortMaxVectorTestsWithMemOp(IntFunction<short[]> fa) {
3052         short[] a = fa.apply(SPECIES.length());
3053         short[] r = fr.apply(SPECIES.length());
3054 
3055         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3056             for (int i = 0; i < a.length; i += SPECIES.length()) {
3057                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3058                 av.min(bv_min).intoArray(r, i);
3059             }
3060         }
3061 
3062         assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::min);
3063     }
3064 
3065     static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10);
3066 
3067     @Test(dataProvider = "shortUnaryOpMaskProvider")
3068     static void MINShortMaxVectorTestsMaskedWithMemOp(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3069         short[] a = fa.apply(SPECIES.length());
3070         short[] r = fr.apply(SPECIES.length());
3071         boolean[] mask = fm.apply(SPECIES.length());
3072         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3073 
3074         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3075             for (int i = 0; i < a.length; i += SPECIES.length()) {
3076                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3077                 av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i);
3078             }
3079         }
3080 
3081         assertArraysEquals(r, a, (short)10, mask, ShortMaxVectorTests::MIN);
3082     }
3083 
3084     static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10);
3085 
3086     @Test(dataProvider = "shortUnaryOpProvider")
3087     static void MAXShortMaxVectorTestsWithMemOp(IntFunction<short[]> fa) {
3088         short[] a = fa.apply(SPECIES.length());
3089         short[] r = fr.apply(SPECIES.length());
3090 
3091         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3092             for (int i = 0; i < a.length; i += SPECIES.length()) {
3093                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3094                 av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i);
3095             }
3096         }
3097 
3098         assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MAX);
3099     }
3100 
3101     static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10);
3102 
3103     @Test(dataProvider = "shortUnaryOpProvider")
3104     static void maxShortMaxVectorTestsWithMemOp(IntFunction<short[]> fa) {
3105         short[] a = fa.apply(SPECIES.length());
3106         short[] r = fr.apply(SPECIES.length());
3107 
3108         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3109             for (int i = 0; i < a.length; i += SPECIES.length()) {
3110                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3111                 av.max(bv_max).intoArray(r, i);
3112             }
3113         }
3114 
3115         assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::max);
3116     }
3117 
3118     static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10);
3119 
3120     @Test(dataProvider = "shortUnaryOpMaskProvider")
3121     static void MAXShortMaxVectorTestsMaskedWithMemOp(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3122         short[] a = fa.apply(SPECIES.length());
3123         short[] r = fr.apply(SPECIES.length());
3124         boolean[] mask = fm.apply(SPECIES.length());
3125         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3126 
3127         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3128             for (int i = 0; i < a.length; i += SPECIES.length()) {
3129                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3130                 av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i);
3131             }
3132         }
3133 
3134         assertArraysEquals(r, a, (short)10, mask, ShortMaxVectorTests::MAX);
3135     }
3136 
3137     static short MIN(short a, short b) {
3138         return (short)(Math.min(a, b));
3139     }
3140 
3141     @Test(dataProvider = "shortBinaryOpProvider")
3142     static void MINShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3143         short[] a = fa.apply(SPECIES.length());
3144         short[] b = fb.apply(SPECIES.length());
3145         short[] r = fr.apply(SPECIES.length());
3146 
3147         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3148             for (int i = 0; i < a.length; i += SPECIES.length()) {
3149                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3150                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3151                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
3152             }
3153         }
3154 
3155         assertArraysEquals(r, a, b, ShortMaxVectorTests::MIN);
3156     }
3157 
3158     static short min(short a, short b) {
3159         return (short)(Math.min(a, b));
3160     }
3161 
3162     @Test(dataProvider = "shortBinaryOpProvider")
3163     static void minShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3164         short[] a = fa.apply(SPECIES.length());
3165         short[] b = fb.apply(SPECIES.length());
3166         short[] r = fr.apply(SPECIES.length());
3167 
3168         for (int i = 0; i < a.length; i += SPECIES.length()) {
3169             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3170             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3171             av.min(bv).intoArray(r, i);
3172         }
3173 
3174         assertArraysEquals(r, a, b, ShortMaxVectorTests::min);
3175     }
3176 
3177     static short MAX(short a, short b) {
3178         return (short)(Math.max(a, b));
3179     }
3180 
3181     @Test(dataProvider = "shortBinaryOpProvider")
3182     static void MAXShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3183         short[] a = fa.apply(SPECIES.length());
3184         short[] b = fb.apply(SPECIES.length());
3185         short[] r = fr.apply(SPECIES.length());
3186 
3187         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3188             for (int i = 0; i < a.length; i += SPECIES.length()) {
3189                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3190                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3191                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
3192             }
3193         }
3194 
3195         assertArraysEquals(r, a, b, ShortMaxVectorTests::MAX);
3196     }
3197 
3198     static short max(short a, short b) {
3199         return (short)(Math.max(a, b));
3200     }
3201 
3202     @Test(dataProvider = "shortBinaryOpProvider")
3203     static void maxShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3204         short[] a = fa.apply(SPECIES.length());
3205         short[] b = fb.apply(SPECIES.length());
3206         short[] r = fr.apply(SPECIES.length());
3207 
3208         for (int i = 0; i < a.length; i += SPECIES.length()) {
3209             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3210             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3211             av.max(bv).intoArray(r, i);
3212         }
3213 
3214         assertArraysEquals(r, a, b, ShortMaxVectorTests::max);
3215     }
3216 
3217     static short UMIN(short a, short b) {
3218         return (short)(VectorMath.minUnsigned(a, b));
3219     }
3220 
3221     @Test(dataProvider = "shortBinaryOpProvider")
3222     static void UMINShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3223         short[] a = fa.apply(SPECIES.length());
3224         short[] b = fb.apply(SPECIES.length());
3225         short[] r = fr.apply(SPECIES.length());
3226 
3227         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3228             for (int i = 0; i < a.length; i += SPECIES.length()) {
3229                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3230                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3231                 av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i);
3232             }
3233         }
3234 
3235         assertArraysEquals(r, a, b, ShortMaxVectorTests::UMIN);
3236     }
3237 
3238     @Test(dataProvider = "shortBinaryOpMaskProvider")
3239     static void UMINShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3240                                           IntFunction<boolean[]> fm) {
3241         short[] a = fa.apply(SPECIES.length());
3242         short[] b = fb.apply(SPECIES.length());
3243         short[] r = fr.apply(SPECIES.length());
3244         boolean[] mask = fm.apply(SPECIES.length());
3245         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3246 
3247         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3248             for (int i = 0; i < a.length; i += SPECIES.length()) {
3249                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3250                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3251                 av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i);
3252             }
3253         }
3254 
3255         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMIN);
3256     }
3257 
3258     static short UMAX(short a, short b) {
3259         return (short)(VectorMath.maxUnsigned(a, b));
3260     }
3261 
3262     @Test(dataProvider = "shortBinaryOpProvider")
3263     static void UMAXShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3264         short[] a = fa.apply(SPECIES.length());
3265         short[] b = fb.apply(SPECIES.length());
3266         short[] r = fr.apply(SPECIES.length());
3267 
3268         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3269             for (int i = 0; i < a.length; i += SPECIES.length()) {
3270                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3271                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3272                 av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i);
3273             }
3274         }
3275 
3276         assertArraysEquals(r, a, b, ShortMaxVectorTests::UMAX);
3277     }
3278 
3279     @Test(dataProvider = "shortBinaryOpMaskProvider")
3280     static void UMAXShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3281                                           IntFunction<boolean[]> fm) {
3282         short[] a = fa.apply(SPECIES.length());
3283         short[] b = fb.apply(SPECIES.length());
3284         short[] r = fr.apply(SPECIES.length());
3285         boolean[] mask = fm.apply(SPECIES.length());
3286         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3287 
3288         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3289             for (int i = 0; i < a.length; i += SPECIES.length()) {
3290                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3291                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3292                 av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i);
3293             }
3294         }
3295 
3296         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMAX);
3297     }
3298 
3299     static short SADD(short a, short b) {
3300         return (short)(VectorMath.addSaturating(a, b));
3301     }
3302 
3303     @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3304     static void SADDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3305         short[] a = fa.apply(SPECIES.length());
3306         short[] b = fb.apply(SPECIES.length());
3307         short[] r = fr.apply(SPECIES.length());
3308 
3309         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3310             for (int i = 0; i < a.length; i += SPECIES.length()) {
3311                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3312                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3313                 av.lanewise(VectorOperators.SADD, bv).intoArray(r, i);
3314             }
3315         }
3316 
3317         assertArraysEquals(r, a, b, ShortMaxVectorTests::SADD);
3318     }
3319 
3320     @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3321     static void SADDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3322                                           IntFunction<boolean[]> fm) {
3323         short[] a = fa.apply(SPECIES.length());
3324         short[] b = fb.apply(SPECIES.length());
3325         short[] r = fr.apply(SPECIES.length());
3326         boolean[] mask = fm.apply(SPECIES.length());
3327         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3328 
3329         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3330             for (int i = 0; i < a.length; i += SPECIES.length()) {
3331                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3332                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3333                 av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i);
3334             }
3335         }
3336 
3337         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SADD);
3338     }
3339 
3340     static short SSUB(short a, short b) {
3341         return (short)(VectorMath.subSaturating(a, b));
3342     }
3343 
3344     @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3345     static void SSUBShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3346         short[] a = fa.apply(SPECIES.length());
3347         short[] b = fb.apply(SPECIES.length());
3348         short[] r = fr.apply(SPECIES.length());
3349 
3350         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3351             for (int i = 0; i < a.length; i += SPECIES.length()) {
3352                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3353                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3354                 av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i);
3355             }
3356         }
3357 
3358         assertArraysEquals(r, a, b, ShortMaxVectorTests::SSUB);
3359     }
3360 
3361     @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3362     static void SSUBShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3363                                           IntFunction<boolean[]> fm) {
3364         short[] a = fa.apply(SPECIES.length());
3365         short[] b = fb.apply(SPECIES.length());
3366         short[] r = fr.apply(SPECIES.length());
3367         boolean[] mask = fm.apply(SPECIES.length());
3368         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3369 
3370         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3371             for (int i = 0; i < a.length; i += SPECIES.length()) {
3372                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3373                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3374                 av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i);
3375             }
3376         }
3377 
3378         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SSUB);
3379     }
3380 
3381     static short SUADD(short a, short b) {
3382         return (short)(VectorMath.addSaturatingUnsigned(a, b));
3383     }
3384 
3385     @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3386     static void SUADDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3387         short[] a = fa.apply(SPECIES.length());
3388         short[] b = fb.apply(SPECIES.length());
3389         short[] r = fr.apply(SPECIES.length());
3390 
3391         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3392             for (int i = 0; i < a.length; i += SPECIES.length()) {
3393                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3394                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3395                 av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i);
3396             }
3397         }
3398 
3399         assertArraysEquals(r, a, b, ShortMaxVectorTests::SUADD);
3400     }
3401 
3402     @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3403     static void SUADDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3404                                           IntFunction<boolean[]> fm) {
3405         short[] a = fa.apply(SPECIES.length());
3406         short[] b = fb.apply(SPECIES.length());
3407         short[] r = fr.apply(SPECIES.length());
3408         boolean[] mask = fm.apply(SPECIES.length());
3409         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3410 
3411         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3412             for (int i = 0; i < a.length; i += SPECIES.length()) {
3413                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3414                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3415                 av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i);
3416             }
3417         }
3418 
3419         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUADD);
3420     }
3421 
3422     static short SUSUB(short a, short b) {
3423         return (short)(VectorMath.subSaturatingUnsigned(a, b));
3424     }
3425 
3426     @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3427     static void SUSUBShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3428         short[] a = fa.apply(SPECIES.length());
3429         short[] b = fb.apply(SPECIES.length());
3430         short[] r = fr.apply(SPECIES.length());
3431 
3432         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3433             for (int i = 0; i < a.length; i += SPECIES.length()) {
3434                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3435                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3436                 av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i);
3437             }
3438         }
3439 
3440         assertArraysEquals(r, a, b, ShortMaxVectorTests::SUSUB);
3441     }
3442 
3443     @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3444     static void SUSUBShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3445                                           IntFunction<boolean[]> fm) {
3446         short[] a = fa.apply(SPECIES.length());
3447         short[] b = fb.apply(SPECIES.length());
3448         short[] r = fr.apply(SPECIES.length());
3449         boolean[] mask = fm.apply(SPECIES.length());
3450         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3451 
3452         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3453             for (int i = 0; i < a.length; i += SPECIES.length()) {
3454                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3455                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3456                 av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i);
3457             }
3458         }
3459 
3460         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUSUB);
3461     }
3462 
3463     @Test(dataProvider = "shortBinaryOpProvider")
3464     static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3465         short[] a = fa.apply(SPECIES.length());
3466         short[] b = fb.apply(SPECIES.length());
3467         short[] r = fr.apply(SPECIES.length());
3468 
3469         for (int i = 0; i < a.length; i += SPECIES.length()) {
3470             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3471             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
3472         }
3473 
3474         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MIN);
3475     }
3476 
3477     @Test(dataProvider = "shortBinaryOpProvider")
3478     static void minShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3479         short[] a = fa.apply(SPECIES.length());
3480         short[] b = fb.apply(SPECIES.length());
3481         short[] r = fr.apply(SPECIES.length());
3482 
3483         for (int i = 0; i < a.length; i += SPECIES.length()) {
3484             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3485             av.min(b[i]).intoArray(r, i);
3486         }
3487 
3488         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::min);
3489     }
3490 
3491     @Test(dataProvider = "shortBinaryOpProvider")
3492     static void MAXShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3493         short[] a = fa.apply(SPECIES.length());
3494         short[] b = fb.apply(SPECIES.length());
3495         short[] r = fr.apply(SPECIES.length());
3496 
3497         for (int i = 0; i < a.length; i += SPECIES.length()) {
3498             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3499             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
3500         }
3501 
3502         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::MAX);
3503     }
3504 
3505     @Test(dataProvider = "shortBinaryOpProvider")
3506     static void maxShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3507         short[] a = fa.apply(SPECIES.length());
3508         short[] b = fb.apply(SPECIES.length());
3509         short[] r = fr.apply(SPECIES.length());
3510 
3511         for (int i = 0; i < a.length; i += SPECIES.length()) {
3512             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3513             av.max(b[i]).intoArray(r, i);
3514         }
3515 
3516         assertBroadcastArraysEquals(r, a, b, ShortMaxVectorTests::max);
3517     }
3518     @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider")
3519     static void SUADDAssocShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
3520         short[] a = fa.apply(SPECIES.length());
3521         short[] b = fb.apply(SPECIES.length());
3522         short[] c = fc.apply(SPECIES.length());
3523         short[] rl = fr.apply(SPECIES.length());
3524         short[] rr = fr.apply(SPECIES.length());
3525 
3526         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3527             for (int i = 0; i < a.length; i += SPECIES.length()) {
3528                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3529                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3530                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3531                 av.lanewise(VectorOperators.SUADD, bv).lanewise(VectorOperators.SUADD, cv).intoArray(rl, i);
3532                 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv)).intoArray(rr, i);
3533             }
3534         }
3535 
3536         assertArraysEqualsAssociative(rl, rr, a, b, c, ShortMaxVectorTests::SUADD);
3537     }
3538 
3539     @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider")
3540     static void SUADDAssocShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3541                                                      IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
3542         short[] a = fa.apply(SPECIES.length());
3543         short[] b = fb.apply(SPECIES.length());
3544         short[] c = fc.apply(SPECIES.length());
3545         boolean[] mask = fm.apply(SPECIES.length());
3546         short[] rl = fr.apply(SPECIES.length());
3547         short[] rr = fr.apply(SPECIES.length());
3548 
3549         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3550 
3551         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3552             for (int i = 0; i < a.length; i += SPECIES.length()) {
3553                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3554                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3555                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3556                 av.lanewise(VectorOperators.SUADD, bv, vmask).lanewise(VectorOperators.SUADD, cv, vmask).intoArray(rl, i);
3557                 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv, vmask), vmask).intoArray(rr, i);
3558             }
3559         }
3560 
3561         assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ShortMaxVectorTests::SUADD);
3562     }
3563 
3564     static short ANDReduce(short[] a, int idx) {
3565         short res = -1;
3566         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3567             res &= a[i];
3568         }
3569 
3570         return res;
3571     }
3572 
3573     static short ANDReduceAll(short[] a) {
3574         short res = -1;
3575         for (int i = 0; i < a.length; i += SPECIES.length()) {
3576             res &= ANDReduce(a, i);
3577         }
3578 
3579         return res;
3580     }
3581 
3582     @Test(dataProvider = "shortUnaryOpProvider")
3583     static void ANDReduceShortMaxVectorTests(IntFunction<short[]> fa) {
3584         short[] a = fa.apply(SPECIES.length());
3585         short[] r = fr.apply(SPECIES.length());
3586         short ra = -1;
3587 
3588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3589             for (int i = 0; i < a.length; i += SPECIES.length()) {
3590                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3591                 r[i] = av.reduceLanes(VectorOperators.AND);
3592             }
3593         }
3594 
3595         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3596             ra = -1;
3597             for (int i = 0; i < a.length; i += SPECIES.length()) {
3598                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3599                 ra &= av.reduceLanes(VectorOperators.AND);
3600             }
3601         }
3602 
3603         assertReductionArraysEquals(r, ra, a,
3604                 ShortMaxVectorTests::ANDReduce, ShortMaxVectorTests::ANDReduceAll);
3605     }
3606 
3607     static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
3608         short res = -1;
3609         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3610             if (mask[i % SPECIES.length()])
3611                 res &= a[i];
3612         }
3613 
3614         return res;
3615     }
3616 
3617     static short ANDReduceAllMasked(short[] a, boolean[] mask) {
3618         short res = -1;
3619         for (int i = 0; i < a.length; i += SPECIES.length()) {
3620             res &= ANDReduceMasked(a, i, mask);
3621         }
3622 
3623         return res;
3624     }
3625 
3626     @Test(dataProvider = "shortUnaryOpMaskProvider")
3627     static void ANDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3628         short[] a = fa.apply(SPECIES.length());
3629         short[] r = fr.apply(SPECIES.length());
3630         boolean[] mask = fm.apply(SPECIES.length());
3631         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3632         short ra = -1;
3633 
3634         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3635             for (int i = 0; i < a.length; i += SPECIES.length()) {
3636                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3637                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3638             }
3639         }
3640 
3641         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3642             ra = -1;
3643             for (int i = 0; i < a.length; i += SPECIES.length()) {
3644                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3645                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3646             }
3647         }
3648 
3649         assertReductionArraysEqualsMasked(r, ra, a, mask,
3650                 ShortMaxVectorTests::ANDReduceMasked, ShortMaxVectorTests::ANDReduceAllMasked);
3651     }
3652 
3653     static short ORReduce(short[] a, int idx) {
3654         short res = 0;
3655         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3656             res |= a[i];
3657         }
3658 
3659         return res;
3660     }
3661 
3662     static short ORReduceAll(short[] a) {
3663         short res = 0;
3664         for (int i = 0; i < a.length; i += SPECIES.length()) {
3665             res |= ORReduce(a, i);
3666         }
3667 
3668         return res;
3669     }
3670 
3671     @Test(dataProvider = "shortUnaryOpProvider")
3672     static void ORReduceShortMaxVectorTests(IntFunction<short[]> fa) {
3673         short[] a = fa.apply(SPECIES.length());
3674         short[] r = fr.apply(SPECIES.length());
3675         short ra = 0;
3676 
3677         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3678             for (int i = 0; i < a.length; i += SPECIES.length()) {
3679                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3680                 r[i] = av.reduceLanes(VectorOperators.OR);
3681             }
3682         }
3683 
3684         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3685             ra = 0;
3686             for (int i = 0; i < a.length; i += SPECIES.length()) {
3687                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3688                 ra |= av.reduceLanes(VectorOperators.OR);
3689             }
3690         }
3691 
3692         assertReductionArraysEquals(r, ra, a,
3693                 ShortMaxVectorTests::ORReduce, ShortMaxVectorTests::ORReduceAll);
3694     }
3695 
3696     static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
3697         short res = 0;
3698         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3699             if (mask[i % SPECIES.length()])
3700                 res |= a[i];
3701         }
3702 
3703         return res;
3704     }
3705 
3706     static short ORReduceAllMasked(short[] a, boolean[] mask) {
3707         short res = 0;
3708         for (int i = 0; i < a.length; i += SPECIES.length()) {
3709             res |= ORReduceMasked(a, i, mask);
3710         }
3711 
3712         return res;
3713     }
3714 
3715     @Test(dataProvider = "shortUnaryOpMaskProvider")
3716     static void ORReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3717         short[] a = fa.apply(SPECIES.length());
3718         short[] r = fr.apply(SPECIES.length());
3719         boolean[] mask = fm.apply(SPECIES.length());
3720         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3721         short ra = 0;
3722 
3723         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3724             for (int i = 0; i < a.length; i += SPECIES.length()) {
3725                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3726                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3727             }
3728         }
3729 
3730         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3731             ra = 0;
3732             for (int i = 0; i < a.length; i += SPECIES.length()) {
3733                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3734                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3735             }
3736         }
3737 
3738         assertReductionArraysEqualsMasked(r, ra, a, mask,
3739                 ShortMaxVectorTests::ORReduceMasked, ShortMaxVectorTests::ORReduceAllMasked);
3740     }
3741 
3742     static short XORReduce(short[] a, int idx) {
3743         short res = 0;
3744         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3745             res ^= a[i];
3746         }
3747 
3748         return res;
3749     }
3750 
3751     static short XORReduceAll(short[] a) {
3752         short res = 0;
3753         for (int i = 0; i < a.length; i += SPECIES.length()) {
3754             res ^= XORReduce(a, i);
3755         }
3756 
3757         return res;
3758     }
3759 
3760     @Test(dataProvider = "shortUnaryOpProvider")
3761     static void XORReduceShortMaxVectorTests(IntFunction<short[]> fa) {
3762         short[] a = fa.apply(SPECIES.length());
3763         short[] r = fr.apply(SPECIES.length());
3764         short ra = 0;
3765 
3766         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3767             for (int i = 0; i < a.length; i += SPECIES.length()) {
3768                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3769                 r[i] = av.reduceLanes(VectorOperators.XOR);
3770             }
3771         }
3772 
3773         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3774             ra = 0;
3775             for (int i = 0; i < a.length; i += SPECIES.length()) {
3776                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3777                 ra ^= av.reduceLanes(VectorOperators.XOR);
3778             }
3779         }
3780 
3781         assertReductionArraysEquals(r, ra, a,
3782                 ShortMaxVectorTests::XORReduce, ShortMaxVectorTests::XORReduceAll);
3783     }
3784 
3785     static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
3786         short res = 0;
3787         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3788             if (mask[i % SPECIES.length()])
3789                 res ^= a[i];
3790         }
3791 
3792         return res;
3793     }
3794 
3795     static short XORReduceAllMasked(short[] a, boolean[] mask) {
3796         short res = 0;
3797         for (int i = 0; i < a.length; i += SPECIES.length()) {
3798             res ^= XORReduceMasked(a, i, mask);
3799         }
3800 
3801         return res;
3802     }
3803 
3804     @Test(dataProvider = "shortUnaryOpMaskProvider")
3805     static void XORReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3806         short[] a = fa.apply(SPECIES.length());
3807         short[] r = fr.apply(SPECIES.length());
3808         boolean[] mask = fm.apply(SPECIES.length());
3809         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3810         short ra = 0;
3811 
3812         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3813             for (int i = 0; i < a.length; i += SPECIES.length()) {
3814                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3815                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3816             }
3817         }
3818 
3819         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3820             ra = 0;
3821             for (int i = 0; i < a.length; i += SPECIES.length()) {
3822                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3823                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3824             }
3825         }
3826 
3827         assertReductionArraysEqualsMasked(r, ra, a, mask,
3828                 ShortMaxVectorTests::XORReduceMasked, ShortMaxVectorTests::XORReduceAllMasked);
3829     }
3830 
3831     static short ADDReduce(short[] a, int idx) {
3832         short res = 0;
3833         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3834             res += a[i];
3835         }
3836 
3837         return res;
3838     }
3839 
3840     static short ADDReduceAll(short[] a) {
3841         short res = 0;
3842         for (int i = 0; i < a.length; i += SPECIES.length()) {
3843             res += ADDReduce(a, i);
3844         }
3845 
3846         return res;
3847     }
3848 
3849     @Test(dataProvider = "shortUnaryOpProvider")
3850     static void ADDReduceShortMaxVectorTests(IntFunction<short[]> fa) {
3851         short[] a = fa.apply(SPECIES.length());
3852         short[] r = fr.apply(SPECIES.length());
3853         short ra = 0;
3854 
3855         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3856             for (int i = 0; i < a.length; i += SPECIES.length()) {
3857                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3858                 r[i] = av.reduceLanes(VectorOperators.ADD);
3859             }
3860         }
3861 
3862         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3863             ra = 0;
3864             for (int i = 0; i < a.length; i += SPECIES.length()) {
3865                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3866                 ra += av.reduceLanes(VectorOperators.ADD);
3867             }
3868         }
3869 
3870         assertReductionArraysEquals(r, ra, a,
3871                 ShortMaxVectorTests::ADDReduce, ShortMaxVectorTests::ADDReduceAll);
3872     }
3873 
3874     static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
3875         short res = 0;
3876         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3877             if (mask[i % SPECIES.length()])
3878                 res += a[i];
3879         }
3880 
3881         return res;
3882     }
3883 
3884     static short ADDReduceAllMasked(short[] a, boolean[] mask) {
3885         short res = 0;
3886         for (int i = 0; i < a.length; i += SPECIES.length()) {
3887             res += ADDReduceMasked(a, i, mask);
3888         }
3889 
3890         return res;
3891     }
3892 
3893     @Test(dataProvider = "shortUnaryOpMaskProvider")
3894     static void ADDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3895         short[] a = fa.apply(SPECIES.length());
3896         short[] r = fr.apply(SPECIES.length());
3897         boolean[] mask = fm.apply(SPECIES.length());
3898         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3899         short ra = 0;
3900 
3901         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3902             for (int i = 0; i < a.length; i += SPECIES.length()) {
3903                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3904                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3905             }
3906         }
3907 
3908         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3909             ra = 0;
3910             for (int i = 0; i < a.length; i += SPECIES.length()) {
3911                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3912                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3913             }
3914         }
3915 
3916         assertReductionArraysEqualsMasked(r, ra, a, mask,
3917                 ShortMaxVectorTests::ADDReduceMasked, ShortMaxVectorTests::ADDReduceAllMasked);
3918     }
3919 
3920     static short MULReduce(short[] a, int idx) {
3921         short res = 1;
3922         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3923             res *= a[i];
3924         }
3925 
3926         return res;
3927     }
3928 
3929     static short MULReduceAll(short[] a) {
3930         short res = 1;
3931         for (int i = 0; i < a.length; i += SPECIES.length()) {
3932             res *= MULReduce(a, i);
3933         }
3934 
3935         return res;
3936     }
3937 
3938     @Test(dataProvider = "shortUnaryOpProvider")
3939     static void MULReduceShortMaxVectorTests(IntFunction<short[]> fa) {
3940         short[] a = fa.apply(SPECIES.length());
3941         short[] r = fr.apply(SPECIES.length());
3942         short ra = 1;
3943 
3944         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3945             for (int i = 0; i < a.length; i += SPECIES.length()) {
3946                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3947                 r[i] = av.reduceLanes(VectorOperators.MUL);
3948             }
3949         }
3950 
3951         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3952             ra = 1;
3953             for (int i = 0; i < a.length; i += SPECIES.length()) {
3954                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3955                 ra *= av.reduceLanes(VectorOperators.MUL);
3956             }
3957         }
3958 
3959         assertReductionArraysEquals(r, ra, a,
3960                 ShortMaxVectorTests::MULReduce, ShortMaxVectorTests::MULReduceAll);
3961     }
3962 
3963     static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
3964         short res = 1;
3965         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3966             if (mask[i % SPECIES.length()])
3967                 res *= a[i];
3968         }
3969 
3970         return res;
3971     }
3972 
3973     static short MULReduceAllMasked(short[] a, boolean[] mask) {
3974         short res = 1;
3975         for (int i = 0; i < a.length; i += SPECIES.length()) {
3976             res *= MULReduceMasked(a, i, mask);
3977         }
3978 
3979         return res;
3980     }
3981 
3982     @Test(dataProvider = "shortUnaryOpMaskProvider")
3983     static void MULReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3984         short[] a = fa.apply(SPECIES.length());
3985         short[] r = fr.apply(SPECIES.length());
3986         boolean[] mask = fm.apply(SPECIES.length());
3987         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3988         short ra = 1;
3989 
3990         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3991             for (int i = 0; i < a.length; i += SPECIES.length()) {
3992                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3993                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3994             }
3995         }
3996 
3997         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3998             ra = 1;
3999             for (int i = 0; i < a.length; i += SPECIES.length()) {
4000                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4001                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
4002             }
4003         }
4004 
4005         assertReductionArraysEqualsMasked(r, ra, a, mask,
4006                 ShortMaxVectorTests::MULReduceMasked, ShortMaxVectorTests::MULReduceAllMasked);
4007     }
4008 
4009     static short MINReduce(short[] a, int idx) {
4010         short res = Short.MAX_VALUE;
4011         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4012             res = (short) Math.min(res, a[i]);
4013         }
4014 
4015         return res;
4016     }
4017 
4018     static short MINReduceAll(short[] a) {
4019         short res = Short.MAX_VALUE;
4020         for (int i = 0; i < a.length; i += SPECIES.length()) {
4021             res = (short) Math.min(res, MINReduce(a, i));
4022         }
4023 
4024         return res;
4025     }
4026 
4027     @Test(dataProvider = "shortUnaryOpProvider")
4028     static void MINReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4029         short[] a = fa.apply(SPECIES.length());
4030         short[] r = fr.apply(SPECIES.length());
4031         short ra = Short.MAX_VALUE;
4032 
4033         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4034             for (int i = 0; i < a.length; i += SPECIES.length()) {
4035                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4036                 r[i] = av.reduceLanes(VectorOperators.MIN);
4037             }
4038         }
4039 
4040         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4041             ra = Short.MAX_VALUE;
4042             for (int i = 0; i < a.length; i += SPECIES.length()) {
4043                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4044                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
4045             }
4046         }
4047 
4048         assertReductionArraysEquals(r, ra, a,
4049                 ShortMaxVectorTests::MINReduce, ShortMaxVectorTests::MINReduceAll);
4050     }
4051 
4052     static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
4053         short res = Short.MAX_VALUE;
4054         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4055             if (mask[i % SPECIES.length()])
4056                 res = (short) Math.min(res, a[i]);
4057         }
4058 
4059         return res;
4060     }
4061 
4062     static short MINReduceAllMasked(short[] a, boolean[] mask) {
4063         short res = Short.MAX_VALUE;
4064         for (int i = 0; i < a.length; i += SPECIES.length()) {
4065             res = (short) Math.min(res, MINReduceMasked(a, i, mask));
4066         }
4067 
4068         return res;
4069     }
4070 
4071     @Test(dataProvider = "shortUnaryOpMaskProvider")
4072     static void MINReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4073         short[] a = fa.apply(SPECIES.length());
4074         short[] r = fr.apply(SPECIES.length());
4075         boolean[] mask = fm.apply(SPECIES.length());
4076         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4077         short ra = Short.MAX_VALUE;
4078 
4079         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4080             for (int i = 0; i < a.length; i += SPECIES.length()) {
4081                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4082                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
4083             }
4084         }
4085 
4086         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4087             ra = Short.MAX_VALUE;
4088             for (int i = 0; i < a.length; i += SPECIES.length()) {
4089                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4090                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
4091             }
4092         }
4093 
4094         assertReductionArraysEqualsMasked(r, ra, a, mask,
4095                 ShortMaxVectorTests::MINReduceMasked, ShortMaxVectorTests::MINReduceAllMasked);
4096     }
4097 
4098     static short MAXReduce(short[] a, int idx) {
4099         short res = Short.MIN_VALUE;
4100         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4101             res = (short) Math.max(res, a[i]);
4102         }
4103 
4104         return res;
4105     }
4106 
4107     static short MAXReduceAll(short[] a) {
4108         short res = Short.MIN_VALUE;
4109         for (int i = 0; i < a.length; i += SPECIES.length()) {
4110             res = (short) Math.max(res, MAXReduce(a, i));
4111         }
4112 
4113         return res;
4114     }
4115 
4116     @Test(dataProvider = "shortUnaryOpProvider")
4117     static void MAXReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4118         short[] a = fa.apply(SPECIES.length());
4119         short[] r = fr.apply(SPECIES.length());
4120         short ra = Short.MIN_VALUE;
4121 
4122         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4123             for (int i = 0; i < a.length; i += SPECIES.length()) {
4124                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4125                 r[i] = av.reduceLanes(VectorOperators.MAX);
4126             }
4127         }
4128 
4129         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4130             ra = Short.MIN_VALUE;
4131             for (int i = 0; i < a.length; i += SPECIES.length()) {
4132                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4133                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
4134             }
4135         }
4136 
4137         assertReductionArraysEquals(r, ra, a,
4138                 ShortMaxVectorTests::MAXReduce, ShortMaxVectorTests::MAXReduceAll);
4139     }
4140 
4141     static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
4142         short res = Short.MIN_VALUE;
4143         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4144             if (mask[i % SPECIES.length()])
4145                 res = (short) Math.max(res, a[i]);
4146         }
4147 
4148         return res;
4149     }
4150 
4151     static short MAXReduceAllMasked(short[] a, boolean[] mask) {
4152         short res = Short.MIN_VALUE;
4153         for (int i = 0; i < a.length; i += SPECIES.length()) {
4154             res = (short) Math.max(res, MAXReduceMasked(a, i, mask));
4155         }
4156 
4157         return res;
4158     }
4159 
4160     @Test(dataProvider = "shortUnaryOpMaskProvider")
4161     static void MAXReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4162         short[] a = fa.apply(SPECIES.length());
4163         short[] r = fr.apply(SPECIES.length());
4164         boolean[] mask = fm.apply(SPECIES.length());
4165         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4166         short ra = Short.MIN_VALUE;
4167 
4168         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4169             for (int i = 0; i < a.length; i += SPECIES.length()) {
4170                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4171                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
4172             }
4173         }
4174 
4175         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4176             ra = Short.MIN_VALUE;
4177             for (int i = 0; i < a.length; i += SPECIES.length()) {
4178                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4179                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
4180             }
4181         }
4182 
4183         assertReductionArraysEqualsMasked(r, ra, a, mask,
4184                 ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked);
4185     }
4186 
4187     static short UMINReduce(short[] a, int idx) {
4188         short res = Short.MAX_VALUE;
4189         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4190             res = (short) VectorMath.minUnsigned(res, a[i]);
4191         }
4192 
4193         return res;
4194     }
4195 
4196     static short UMINReduceAll(short[] a) {
4197         short res = Short.MAX_VALUE;
4198         for (int i = 0; i < a.length; i += SPECIES.length()) {
4199             res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
4200         }
4201 
4202         return res;
4203     }
4204 
4205     @Test(dataProvider = "shortUnaryOpProvider")
4206     static void UMINReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4207         short[] a = fa.apply(SPECIES.length());
4208         short[] r = fr.apply(SPECIES.length());
4209         short ra = Short.MAX_VALUE;
4210 
4211         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4212             for (int i = 0; i < a.length; i += SPECIES.length()) {
4213                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4214                 r[i] = av.reduceLanes(VectorOperators.UMIN);
4215             }
4216         }
4217 
4218         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4219             ra = Short.MAX_VALUE;
4220             for (int i = 0; i < a.length; i += SPECIES.length()) {
4221                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4222                 ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
4223             }
4224         }
4225 
4226         assertReductionArraysEquals(r, ra, a,
4227                 ShortMaxVectorTests::UMINReduce, ShortMaxVectorTests::UMINReduceAll);
4228     }
4229 
4230     static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
4231         short res = Short.MAX_VALUE;
4232         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4233             if (mask[i % SPECIES.length()])
4234                 res = (short) VectorMath.minUnsigned(res, a[i]);
4235         }
4236 
4237         return res;
4238     }
4239 
4240     static short UMINReduceAllMasked(short[] a, boolean[] mask) {
4241         short res = Short.MAX_VALUE;
4242         for (int i = 0; i < a.length; i += SPECIES.length()) {
4243             res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
4244         }
4245 
4246         return res;
4247     }
4248 
4249     @Test(dataProvider = "shortUnaryOpMaskProvider")
4250     static void UMINReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4251         short[] a = fa.apply(SPECIES.length());
4252         short[] r = fr.apply(SPECIES.length());
4253         boolean[] mask = fm.apply(SPECIES.length());
4254         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4255         short ra = Short.MAX_VALUE;
4256 
4257         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4258             for (int i = 0; i < a.length; i += SPECIES.length()) {
4259                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4260                 r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
4261             }
4262         }
4263 
4264         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4265             ra = Short.MAX_VALUE;
4266             for (int i = 0; i < a.length; i += SPECIES.length()) {
4267                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4268                 ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
4269             }
4270         }
4271 
4272         assertReductionArraysEqualsMasked(r, ra, a, mask,
4273                 ShortMaxVectorTests::UMINReduceMasked, ShortMaxVectorTests::UMINReduceAllMasked);
4274     }
4275 
4276     static short UMAXReduce(short[] a, int idx) {
4277         short res = Short.MIN_VALUE;
4278         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4279             res = (short) VectorMath.maxUnsigned(res, a[i]);
4280         }
4281 
4282         return res;
4283     }
4284 
4285     static short UMAXReduceAll(short[] a) {
4286         short res = Short.MIN_VALUE;
4287         for (int i = 0; i < a.length; i += SPECIES.length()) {
4288             res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
4289         }
4290 
4291         return res;
4292     }
4293 
4294     @Test(dataProvider = "shortUnaryOpProvider")
4295     static void UMAXReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4296         short[] a = fa.apply(SPECIES.length());
4297         short[] r = fr.apply(SPECIES.length());
4298         short ra = Short.MIN_VALUE;
4299 
4300         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4301             for (int i = 0; i < a.length; i += SPECIES.length()) {
4302                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4303                 r[i] = av.reduceLanes(VectorOperators.UMAX);
4304             }
4305         }
4306 
4307         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4308             ra = Short.MIN_VALUE;
4309             for (int i = 0; i < a.length; i += SPECIES.length()) {
4310                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4311                 ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
4312             }
4313         }
4314 
4315         assertReductionArraysEquals(r, ra, a,
4316                 ShortMaxVectorTests::UMAXReduce, ShortMaxVectorTests::UMAXReduceAll);
4317     }
4318 
4319     static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
4320         short res = Short.MIN_VALUE;
4321         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4322             if (mask[i % SPECIES.length()])
4323                 res = (short) VectorMath.maxUnsigned(res, a[i]);
4324         }
4325 
4326         return res;
4327     }
4328 
4329     static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
4330         short res = Short.MIN_VALUE;
4331         for (int i = 0; i < a.length; i += SPECIES.length()) {
4332             res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
4333         }
4334 
4335         return res;
4336     }
4337 
4338     @Test(dataProvider = "shortUnaryOpMaskProvider")
4339     static void UMAXReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4340         short[] a = fa.apply(SPECIES.length());
4341         short[] r = fr.apply(SPECIES.length());
4342         boolean[] mask = fm.apply(SPECIES.length());
4343         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4344         short ra = Short.MIN_VALUE;
4345 
4346         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4347             for (int i = 0; i < a.length; i += SPECIES.length()) {
4348                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4349                 r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
4350             }
4351         }
4352 
4353         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4354             ra = Short.MIN_VALUE;
4355             for (int i = 0; i < a.length; i += SPECIES.length()) {
4356                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4357                 ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
4358             }
4359         }
4360 
4361         assertReductionArraysEqualsMasked(r, ra, a, mask,
4362                 ShortMaxVectorTests::UMAXReduceMasked, ShortMaxVectorTests::UMAXReduceAllMasked);
4363     }
4364 
4365     static short FIRST_NONZEROReduce(short[] a, int idx) {
4366         short res = (short) 0;
4367         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4368             res = firstNonZero(res, a[i]);
4369         }
4370 
4371         return res;
4372     }
4373 
4374     static short FIRST_NONZEROReduceAll(short[] a) {
4375         short res = (short) 0;
4376         for (int i = 0; i < a.length; i += SPECIES.length()) {
4377             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
4378         }
4379 
4380         return res;
4381     }
4382 
4383     @Test(dataProvider = "shortUnaryOpProvider")
4384     static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4385         short[] a = fa.apply(SPECIES.length());
4386         short[] r = fr.apply(SPECIES.length());
4387         short ra = (short) 0;
4388 
4389         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4390             for (int i = 0; i < a.length; i += SPECIES.length()) {
4391                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4392                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
4393             }
4394         }
4395 
4396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4397             ra = (short) 0;
4398             for (int i = 0; i < a.length; i += SPECIES.length()) {
4399                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4400                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
4401             }
4402         }
4403 
4404         assertReductionArraysEquals(r, ra, a,
4405                 ShortMaxVectorTests::FIRST_NONZEROReduce, ShortMaxVectorTests::FIRST_NONZEROReduceAll);
4406     }
4407 
4408     static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) {
4409         short res = (short) 0;
4410         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4411             if (mask[i % SPECIES.length()])
4412                 res = firstNonZero(res, a[i]);
4413         }
4414 
4415         return res;
4416     }
4417 
4418     static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) {
4419         short res = (short) 0;
4420         for (int i = 0; i < a.length; i += SPECIES.length()) {
4421             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
4422         }
4423 
4424         return res;
4425     }
4426 
4427     @Test(dataProvider = "shortUnaryOpMaskProvider")
4428     static void FIRST_NONZEROReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4429         short[] a = fa.apply(SPECIES.length());
4430         short[] r = fr.apply(SPECIES.length());
4431         boolean[] mask = fm.apply(SPECIES.length());
4432         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4433         short ra = (short) 0;
4434 
4435         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4436             for (int i = 0; i < a.length; i += SPECIES.length()) {
4437                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4438                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
4439             }
4440         }
4441 
4442         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4443             ra = (short) 0;
4444             for (int i = 0; i < a.length; i += SPECIES.length()) {
4445                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4446                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
4447             }
4448         }
4449 
4450         assertReductionArraysEqualsMasked(r, ra, a, mask,
4451                 ShortMaxVectorTests::FIRST_NONZEROReduceMasked, ShortMaxVectorTests::FIRST_NONZEROReduceAllMasked);
4452     }
4453 
4454     static boolean anyTrue(boolean[] a, int idx) {
4455         boolean res = false;
4456         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4457             res |= a[i];
4458         }
4459 
4460         return res;
4461     }
4462 
4463     @Test(dataProvider = "boolUnaryOpProvider")
4464     static void anyTrueShortMaxVectorTests(IntFunction<boolean[]> fm) {
4465         boolean[] mask = fm.apply(SPECIES.length());
4466         boolean[] r = fmr.apply(SPECIES.length());
4467 
4468         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4469             for (int i = 0; i < mask.length; i += SPECIES.length()) {
4470                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
4471                 r[i] = vmask.anyTrue();
4472             }
4473         }
4474 
4475         assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::anyTrue);
4476     }
4477 
4478     static boolean allTrue(boolean[] a, int idx) {
4479         boolean res = true;
4480         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4481             res &= a[i];
4482         }
4483 
4484         return res;
4485     }
4486 
4487     @Test(dataProvider = "boolUnaryOpProvider")
4488     static void allTrueShortMaxVectorTests(IntFunction<boolean[]> fm) {
4489         boolean[] mask = fm.apply(SPECIES.length());
4490         boolean[] r = fmr.apply(SPECIES.length());
4491 
4492         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4493             for (int i = 0; i < mask.length; i += SPECIES.length()) {
4494                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
4495                 r[i] = vmask.allTrue();
4496             }
4497         }
4498 
4499         assertReductionBoolArraysEquals(r, mask, ShortMaxVectorTests::allTrue);
4500     }
4501 
4502     static short SUADDReduce(short[] a, int idx) {
4503         short res = 0;
4504         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4505             res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
4506         }
4507 
4508         return res;
4509     }
4510 
4511     static short SUADDReduceAll(short[] a) {
4512         short res = 0;
4513         for (int i = 0; i < a.length; i += SPECIES.length()) {
4514             res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
4515         }
4516 
4517         return res;
4518     }
4519 
4520     @Test(dataProvider = "shortSaturatingUnaryOpProvider")
4521     static void SUADDReduceShortMaxVectorTests(IntFunction<short[]> fa) {
4522         short[] a = fa.apply(SPECIES.length());
4523         short[] r = fr.apply(SPECIES.length());
4524         short ra = 0;
4525 
4526         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4527             for (int i = 0; i < a.length; i += SPECIES.length()) {
4528                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4529                 r[i] = av.reduceLanes(VectorOperators.SUADD);
4530             }
4531         }
4532 
4533         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4534             ra = 0;
4535             for (int i = 0; i < a.length; i += SPECIES.length()) {
4536                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4537                 ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
4538             }
4539         }
4540 
4541         assertReductionArraysEquals(r, ra, a,
4542                 ShortMaxVectorTests::SUADDReduce, ShortMaxVectorTests::SUADDReduceAll);
4543     }
4544 
4545     static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
4546         short res = 0;
4547         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4548             if (mask[i % SPECIES.length()])
4549                 res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
4550         }
4551 
4552         return res;
4553     }
4554 
4555     static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
4556         short res = 0;
4557         for (int i = 0; i < a.length; i += SPECIES.length()) {
4558             res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
4559         }
4560 
4561         return res;
4562     }
4563     @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
4564     static void SUADDReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4565         short[] a = fa.apply(SPECIES.length());
4566         short[] r = fr.apply(SPECIES.length());
4567         boolean[] mask = fm.apply(SPECIES.length());
4568         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4569         short ra = 0;
4570 
4571         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4572             for (int i = 0; i < a.length; i += SPECIES.length()) {
4573                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4574                 r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
4575             }
4576         }
4577 
4578         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4579             ra = 0;
4580             for (int i = 0; i < a.length; i += SPECIES.length()) {
4581                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4582                 ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
4583             }
4584         }
4585 
4586         assertReductionArraysEqualsMasked(r, ra, a, mask,
4587                 ShortMaxVectorTests::SUADDReduceMasked, ShortMaxVectorTests::SUADDReduceAllMasked);
4588     }
4589 
4590     @Test(dataProvider = "shortBinaryOpProvider")
4591     static void withShortMaxVectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
4592         short[] a = fa.apply(SPECIES.length());
4593         short[] b = fb.apply(SPECIES.length());
4594         short[] r = fr.apply(SPECIES.length());
4595 
4596         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4597             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
4598                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4599                 av.withLane(j, b[i + j]).intoArray(r, i);
4600                 a[i + j] = b[i + j];
4601                 j = (j + 1) & (SPECIES.length() - 1);
4602             }
4603         }
4604 
4605 
4606         assertArraysStrictlyEquals(r, a);
4607     }
4608 
4609     static boolean testIS_DEFAULT(short a) {
4610         return bits(a)==0;
4611     }
4612 
4613     @Test(dataProvider = "shortTestOpProvider")
4614     static void IS_DEFAULTShortMaxVectorTests(IntFunction<short[]> fa) {
4615         short[] a = fa.apply(SPECIES.length());
4616 
4617         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4618             for (int i = 0; i < a.length; i += SPECIES.length()) {
4619                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4620                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT);
4621 
4622                 // Check results as part of computation.
4623                 for (int j = 0; j < SPECIES.length(); j++) {
4624                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
4625                 }
4626             }
4627         }
4628     }
4629 
4630     @Test(dataProvider = "shortTestOpMaskProvider")
4631     static void IS_DEFAULTMaskedShortMaxVectorTests(IntFunction<short[]> fa,
4632                                           IntFunction<boolean[]> fm) {
4633         short[] a = fa.apply(SPECIES.length());
4634         boolean[] mask = fm.apply(SPECIES.length());
4635         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4636 
4637         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4638             for (int i = 0; i < a.length; i += SPECIES.length()) {
4639                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4640                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
4641 
4642                 // Check results as part of computation.
4643                 for (int j = 0; j < SPECIES.length(); j++) {
4644                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
4645                 }
4646             }
4647         }
4648     }
4649 
4650     static boolean testIS_NEGATIVE(short a) {
4651         return bits(a)<0;
4652     }
4653 
4654     @Test(dataProvider = "shortTestOpProvider")
4655     static void IS_NEGATIVEShortMaxVectorTests(IntFunction<short[]> fa) {
4656         short[] a = fa.apply(SPECIES.length());
4657 
4658         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4659             for (int i = 0; i < a.length; i += SPECIES.length()) {
4660                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4661                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE);
4662 
4663                 // Check results as part of computation.
4664                 for (int j = 0; j < SPECIES.length(); j++) {
4665                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
4666                 }
4667             }
4668         }
4669     }
4670 
4671     @Test(dataProvider = "shortTestOpMaskProvider")
4672     static void IS_NEGATIVEMaskedShortMaxVectorTests(IntFunction<short[]> fa,
4673                                           IntFunction<boolean[]> fm) {
4674         short[] a = fa.apply(SPECIES.length());
4675         boolean[] mask = fm.apply(SPECIES.length());
4676         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4677 
4678         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4679             for (int i = 0; i < a.length; i += SPECIES.length()) {
4680                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4681                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
4682 
4683                 // Check results as part of computation.
4684                 for (int j = 0; j < SPECIES.length(); j++) {
4685                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
4686                 }
4687             }
4688         }
4689     }
4690 
4691     @Test(dataProvider = "shortCompareOpProvider")
4692     static void LTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4693         short[] a = fa.apply(SPECIES.length());
4694         short[] b = fb.apply(SPECIES.length());
4695 
4696         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4697             for (int i = 0; i < a.length; i += SPECIES.length()) {
4698                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4699                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4700                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv);
4701 
4702                 // Check results as part of computation.
4703                 for (int j = 0; j < SPECIES.length(); j++) {
4704                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4705                 }
4706             }
4707         }
4708     }
4709 
4710     @Test(dataProvider = "shortCompareOpProvider")
4711     static void ltShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4712         short[] a = fa.apply(SPECIES.length());
4713         short[] b = fb.apply(SPECIES.length());
4714 
4715         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4716             for (int i = 0; i < a.length; i += SPECIES.length()) {
4717                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4718                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4719                 VectorMask<Short> mv = av.lt(bv);
4720 
4721                 // Check results as part of computation.
4722                 for (int j = 0; j < SPECIES.length(); j++) {
4723                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4724                 }
4725             }
4726         }
4727     }
4728 
4729     @Test(dataProvider = "shortCompareOpMaskProvider")
4730     static void LTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4731                                                 IntFunction<boolean[]> fm) {
4732         short[] a = fa.apply(SPECIES.length());
4733         short[] b = fb.apply(SPECIES.length());
4734         boolean[] mask = fm.apply(SPECIES.length());
4735 
4736         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4737 
4738         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4739             for (int i = 0; i < a.length; i += SPECIES.length()) {
4740                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4741                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4742                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask);
4743 
4744                 // Check results as part of computation.
4745                 for (int j = 0; j < SPECIES.length(); j++) {
4746                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
4747                 }
4748             }
4749         }
4750     }
4751 
4752     @Test(dataProvider = "shortCompareOpProvider")
4753     static void GTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4754         short[] a = fa.apply(SPECIES.length());
4755         short[] b = fb.apply(SPECIES.length());
4756 
4757         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4758             for (int i = 0; i < a.length; i += SPECIES.length()) {
4759                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4760                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4761                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv);
4762 
4763                 // Check results as part of computation.
4764                 for (int j = 0; j < SPECIES.length(); j++) {
4765                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
4766                 }
4767             }
4768         }
4769     }
4770 
4771     @Test(dataProvider = "shortCompareOpMaskProvider")
4772     static void GTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4773                                                 IntFunction<boolean[]> fm) {
4774         short[] a = fa.apply(SPECIES.length());
4775         short[] b = fb.apply(SPECIES.length());
4776         boolean[] mask = fm.apply(SPECIES.length());
4777 
4778         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4779 
4780         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4781             for (int i = 0; i < a.length; i += SPECIES.length()) {
4782                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4783                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4784                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask);
4785 
4786                 // Check results as part of computation.
4787                 for (int j = 0; j < SPECIES.length(); j++) {
4788                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
4789                 }
4790             }
4791         }
4792     }
4793 
4794     @Test(dataProvider = "shortCompareOpProvider")
4795     static void EQShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4796         short[] a = fa.apply(SPECIES.length());
4797         short[] b = fb.apply(SPECIES.length());
4798 
4799         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4800             for (int i = 0; i < a.length; i += SPECIES.length()) {
4801                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4802                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4803                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv);
4804 
4805                 // Check results as part of computation.
4806                 for (int j = 0; j < SPECIES.length(); j++) {
4807                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4808                 }
4809             }
4810         }
4811     }
4812 
4813     @Test(dataProvider = "shortCompareOpProvider")
4814     static void eqShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4815         short[] a = fa.apply(SPECIES.length());
4816         short[] b = fb.apply(SPECIES.length());
4817 
4818         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4819             for (int i = 0; i < a.length; i += SPECIES.length()) {
4820                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4821                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4822                 VectorMask<Short> mv = av.eq(bv);
4823 
4824                 // Check results as part of computation.
4825                 for (int j = 0; j < SPECIES.length(); j++) {
4826                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4827                 }
4828             }
4829         }
4830     }
4831 
4832     @Test(dataProvider = "shortCompareOpMaskProvider")
4833     static void EQShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4834                                                 IntFunction<boolean[]> fm) {
4835         short[] a = fa.apply(SPECIES.length());
4836         short[] b = fb.apply(SPECIES.length());
4837         boolean[] mask = fm.apply(SPECIES.length());
4838 
4839         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4840 
4841         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4842             for (int i = 0; i < a.length; i += SPECIES.length()) {
4843                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4844                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4845                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask);
4846 
4847                 // Check results as part of computation.
4848                 for (int j = 0; j < SPECIES.length(); j++) {
4849                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4850                 }
4851             }
4852         }
4853     }
4854 
4855     @Test(dataProvider = "shortCompareOpProvider")
4856     static void NEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4857         short[] a = fa.apply(SPECIES.length());
4858         short[] b = fb.apply(SPECIES.length());
4859 
4860         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4861             for (int i = 0; i < a.length; i += SPECIES.length()) {
4862                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4863                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4864                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv);
4865 
4866                 // Check results as part of computation.
4867                 for (int j = 0; j < SPECIES.length(); j++) {
4868                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4869                 }
4870             }
4871         }
4872     }
4873 
4874     @Test(dataProvider = "shortCompareOpMaskProvider")
4875     static void NEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4876                                                 IntFunction<boolean[]> fm) {
4877         short[] a = fa.apply(SPECIES.length());
4878         short[] b = fb.apply(SPECIES.length());
4879         boolean[] mask = fm.apply(SPECIES.length());
4880 
4881         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4882 
4883         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4884             for (int i = 0; i < a.length; i += SPECIES.length()) {
4885                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4886                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4887                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask);
4888 
4889                 // Check results as part of computation.
4890                 for (int j = 0; j < SPECIES.length(); j++) {
4891                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4892                 }
4893             }
4894         }
4895     }
4896 
4897     @Test(dataProvider = "shortCompareOpProvider")
4898     static void LEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4899         short[] a = fa.apply(SPECIES.length());
4900         short[] b = fb.apply(SPECIES.length());
4901 
4902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4903             for (int i = 0; i < a.length; i += SPECIES.length()) {
4904                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4905                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4906                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv);
4907 
4908                 // Check results as part of computation.
4909                 for (int j = 0; j < SPECIES.length(); j++) {
4910                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4911                 }
4912             }
4913         }
4914     }
4915 
4916     @Test(dataProvider = "shortCompareOpMaskProvider")
4917     static void LEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4918                                                 IntFunction<boolean[]> fm) {
4919         short[] a = fa.apply(SPECIES.length());
4920         short[] b = fb.apply(SPECIES.length());
4921         boolean[] mask = fm.apply(SPECIES.length());
4922 
4923         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4924 
4925         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4926             for (int i = 0; i < a.length; i += SPECIES.length()) {
4927                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4928                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4929                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask);
4930 
4931                 // Check results as part of computation.
4932                 for (int j = 0; j < SPECIES.length(); j++) {
4933                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4934                 }
4935             }
4936         }
4937     }
4938 
4939     @Test(dataProvider = "shortCompareOpProvider")
4940     static void GEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4941         short[] a = fa.apply(SPECIES.length());
4942         short[] b = fb.apply(SPECIES.length());
4943 
4944         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4945             for (int i = 0; i < a.length; i += SPECIES.length()) {
4946                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4947                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4948                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv);
4949 
4950                 // Check results as part of computation.
4951                 for (int j = 0; j < SPECIES.length(); j++) {
4952                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4953                 }
4954             }
4955         }
4956     }
4957 
4958     @Test(dataProvider = "shortCompareOpMaskProvider")
4959     static void GEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4960                                                 IntFunction<boolean[]> fm) {
4961         short[] a = fa.apply(SPECIES.length());
4962         short[] b = fb.apply(SPECIES.length());
4963         boolean[] mask = fm.apply(SPECIES.length());
4964 
4965         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4966 
4967         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4968             for (int i = 0; i < a.length; i += SPECIES.length()) {
4969                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4970                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4971                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask);
4972 
4973                 // Check results as part of computation.
4974                 for (int j = 0; j < SPECIES.length(); j++) {
4975                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4976                 }
4977             }
4978         }
4979     }
4980 
4981     @Test(dataProvider = "shortCompareOpProvider")
4982     static void ULTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4983         short[] a = fa.apply(SPECIES.length());
4984         short[] b = fb.apply(SPECIES.length());
4985 
4986         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4987             for (int i = 0; i < a.length; i += SPECIES.length()) {
4988                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4989                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4990                 VectorMask<Short> mv = av.compare(VectorOperators.ULT, bv);
4991 
4992                 // Check results as part of computation.
4993                 for (int j = 0; j < SPECIES.length(); j++) {
4994                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4995                 }
4996             }
4997         }
4998     }
4999 
5000     @Test(dataProvider = "shortCompareOpMaskProvider")
5001     static void ULTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5002                                                 IntFunction<boolean[]> fm) {
5003         short[] a = fa.apply(SPECIES.length());
5004         short[] b = fb.apply(SPECIES.length());
5005         boolean[] mask = fm.apply(SPECIES.length());
5006 
5007         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5008 
5009         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5010             for (int i = 0; i < a.length; i += SPECIES.length()) {
5011                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5012                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5013                 VectorMask<Short> mv = av.compare(VectorOperators.ULT, bv, vmask);
5014 
5015                 // Check results as part of computation.
5016                 for (int j = 0; j < SPECIES.length(); j++) {
5017                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
5018                 }
5019             }
5020         }
5021     }
5022 
5023     @Test(dataProvider = "shortCompareOpProvider")
5024     static void UGTShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5025         short[] a = fa.apply(SPECIES.length());
5026         short[] b = fb.apply(SPECIES.length());
5027 
5028         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5029             for (int i = 0; i < a.length; i += SPECIES.length()) {
5030                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5031                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5032                 VectorMask<Short> mv = av.compare(VectorOperators.UGT, bv);
5033 
5034                 // Check results as part of computation.
5035                 for (int j = 0; j < SPECIES.length(); j++) {
5036                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
5037                 }
5038             }
5039         }
5040     }
5041 
5042     @Test(dataProvider = "shortCompareOpMaskProvider")
5043     static void UGTShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5044                                                 IntFunction<boolean[]> fm) {
5045         short[] a = fa.apply(SPECIES.length());
5046         short[] b = fb.apply(SPECIES.length());
5047         boolean[] mask = fm.apply(SPECIES.length());
5048 
5049         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5050 
5051         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5052             for (int i = 0; i < a.length; i += SPECIES.length()) {
5053                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5054                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5055                 VectorMask<Short> mv = av.compare(VectorOperators.UGT, bv, vmask);
5056 
5057                 // Check results as part of computation.
5058                 for (int j = 0; j < SPECIES.length(); j++) {
5059                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
5060                 }
5061             }
5062         }
5063     }
5064 
5065     @Test(dataProvider = "shortCompareOpProvider")
5066     static void ULEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5067         short[] a = fa.apply(SPECIES.length());
5068         short[] b = fb.apply(SPECIES.length());
5069 
5070         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5071             for (int i = 0; i < a.length; i += SPECIES.length()) {
5072                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5073                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5074                 VectorMask<Short> mv = av.compare(VectorOperators.ULE, bv);
5075 
5076                 // Check results as part of computation.
5077                 for (int j = 0; j < SPECIES.length(); j++) {
5078                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
5079                 }
5080             }
5081         }
5082     }
5083 
5084     @Test(dataProvider = "shortCompareOpMaskProvider")
5085     static void ULEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5086                                                 IntFunction<boolean[]> fm) {
5087         short[] a = fa.apply(SPECIES.length());
5088         short[] b = fb.apply(SPECIES.length());
5089         boolean[] mask = fm.apply(SPECIES.length());
5090 
5091         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5092 
5093         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5094             for (int i = 0; i < a.length; i += SPECIES.length()) {
5095                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5096                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5097                 VectorMask<Short> mv = av.compare(VectorOperators.ULE, bv, vmask);
5098 
5099                 // Check results as part of computation.
5100                 for (int j = 0; j < SPECIES.length(); j++) {
5101                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
5102                 }
5103             }
5104         }
5105     }
5106 
5107     @Test(dataProvider = "shortCompareOpProvider")
5108     static void UGEShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5109         short[] a = fa.apply(SPECIES.length());
5110         short[] b = fb.apply(SPECIES.length());
5111 
5112         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5113             for (int i = 0; i < a.length; i += SPECIES.length()) {
5114                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5115                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5116                 VectorMask<Short> mv = av.compare(VectorOperators.UGE, bv);
5117 
5118                 // Check results as part of computation.
5119                 for (int j = 0; j < SPECIES.length(); j++) {
5120                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
5121                 }
5122             }
5123         }
5124     }
5125 
5126     @Test(dataProvider = "shortCompareOpMaskProvider")
5127     static void UGEShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5128                                                 IntFunction<boolean[]> fm) {
5129         short[] a = fa.apply(SPECIES.length());
5130         short[] b = fb.apply(SPECIES.length());
5131         boolean[] mask = fm.apply(SPECIES.length());
5132 
5133         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5134 
5135         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5136             for (int i = 0; i < a.length; i += SPECIES.length()) {
5137                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5138                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5139                 VectorMask<Short> mv = av.compare(VectorOperators.UGE, bv, vmask);
5140 
5141                 // Check results as part of computation.
5142                 for (int j = 0; j < SPECIES.length(); j++) {
5143                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
5144                 }
5145             }
5146         }
5147     }
5148 
5149     @Test(dataProvider = "shortCompareOpProvider")
5150     static void LTShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5151         short[] a = fa.apply(SPECIES.length());
5152         short[] b = fb.apply(SPECIES.length());
5153 
5154         for (int i = 0; i < a.length; i += SPECIES.length()) {
5155             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5156             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]);
5157 
5158             // Check results as part of computation.
5159             for (int j = 0; j < SPECIES.length(); j++) {
5160                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5161             }
5162         }
5163     }
5164 
5165     @Test(dataProvider = "shortCompareOpMaskProvider")
5166     static void LTShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
5167                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5168         short[] a = fa.apply(SPECIES.length());
5169         short[] b = fb.apply(SPECIES.length());
5170         boolean[] mask = fm.apply(SPECIES.length());
5171 
5172         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5173 
5174         for (int i = 0; i < a.length; i += SPECIES.length()) {
5175             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5176             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask);
5177 
5178             // Check results as part of computation.
5179             for (int j = 0; j < SPECIES.length(); j++) {
5180                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
5181             }
5182         }
5183     }
5184 
5185     @Test(dataProvider = "shortCompareOpProvider")
5186     static void LTShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5187         short[] a = fa.apply(SPECIES.length());
5188         short[] b = fb.apply(SPECIES.length());
5189 
5190         for (int i = 0; i < a.length; i += SPECIES.length()) {
5191             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5192             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]);
5193 
5194             // Check results as part of computation.
5195             for (int j = 0; j < SPECIES.length(); j++) {
5196                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
5197             }
5198         }
5199     }
5200 
5201     @Test(dataProvider = "shortCompareOpMaskProvider")
5202     static void LTShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
5203                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5204         short[] a = fa.apply(SPECIES.length());
5205         short[] b = fb.apply(SPECIES.length());
5206         boolean[] mask = fm.apply(SPECIES.length());
5207 
5208         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5209 
5210         for (int i = 0; i < a.length; i += SPECIES.length()) {
5211             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5212             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
5213 
5214             // Check results as part of computation.
5215             for (int j = 0; j < SPECIES.length(); j++) {
5216                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i])));
5217             }
5218         }
5219     }
5220 
5221     @Test(dataProvider = "shortCompareOpProvider")
5222     static void EQShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5223         short[] a = fa.apply(SPECIES.length());
5224         short[] b = fb.apply(SPECIES.length());
5225 
5226         for (int i = 0; i < a.length; i += SPECIES.length()) {
5227             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5228             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]);
5229 
5230             // Check results as part of computation.
5231             for (int j = 0; j < SPECIES.length(); j++) {
5232                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5233             }
5234         }
5235     }
5236 
5237     @Test(dataProvider = "shortCompareOpMaskProvider")
5238     static void EQShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
5239                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5240         short[] a = fa.apply(SPECIES.length());
5241         short[] b = fb.apply(SPECIES.length());
5242         boolean[] mask = fm.apply(SPECIES.length());
5243 
5244         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5245 
5246         for (int i = 0; i < a.length; i += SPECIES.length()) {
5247             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5248             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask);
5249 
5250             // Check results as part of computation.
5251             for (int j = 0; j < SPECIES.length(); j++) {
5252                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
5253             }
5254         }
5255     }
5256 
5257     @Test(dataProvider = "shortCompareOpProvider")
5258     static void EQShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5259         short[] a = fa.apply(SPECIES.length());
5260         short[] b = fb.apply(SPECIES.length());
5261 
5262         for (int i = 0; i < a.length; i += SPECIES.length()) {
5263             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5264             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]);
5265 
5266             // Check results as part of computation.
5267             for (int j = 0; j < SPECIES.length(); j++) {
5268                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
5269             }
5270         }
5271     }
5272 
5273     @Test(dataProvider = "shortCompareOpMaskProvider")
5274     static void EQShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
5275                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5276         short[] a = fa.apply(SPECIES.length());
5277         short[] b = fb.apply(SPECIES.length());
5278         boolean[] mask = fm.apply(SPECIES.length());
5279 
5280         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5281 
5282         for (int i = 0; i < a.length; i += SPECIES.length()) {
5283             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5284             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
5285 
5286             // Check results as part of computation.
5287             for (int j = 0; j < SPECIES.length(); j++) {
5288                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i])));
5289             }
5290         }
5291     }
5292 
5293     static short blend(short a, short b, boolean mask) {
5294         return mask ? b : a;
5295     }
5296 
5297     @Test(dataProvider = "shortBinaryOpMaskProvider")
5298     static void blendShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
5299                                           IntFunction<boolean[]> fm) {
5300         short[] a = fa.apply(SPECIES.length());
5301         short[] b = fb.apply(SPECIES.length());
5302         short[] r = fr.apply(SPECIES.length());
5303         boolean[] mask = fm.apply(SPECIES.length());
5304         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5305 
5306         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5307             for (int i = 0; i < a.length; i += SPECIES.length()) {
5308                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5309                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5310                 av.blend(bv, vmask).intoArray(r, i);
5311             }
5312         }
5313 
5314         assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend);
5315     }
5316 
5317     @Test(dataProvider = "shortUnaryOpShuffleProvider")
5318     static void RearrangeShortMaxVectorTests(IntFunction<short[]> fa,
5319                                            BiFunction<Integer,Integer,int[]> fs) {
5320         short[] a = fa.apply(SPECIES.length());
5321         int[] order = fs.apply(a.length, SPECIES.length());
5322         short[] r = fr.apply(SPECIES.length());
5323 
5324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5325             for (int i = 0; i < a.length; i += SPECIES.length()) {
5326                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5327                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
5328             }
5329         }
5330 
5331         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
5332     }
5333 
5334     @Test(dataProvider = "shortUnaryOpShuffleMaskProvider")
5335     static void RearrangeShortMaxVectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
5336                                                           BiFunction<Integer,Integer,int[]> fs,
5337                                                           IntFunction<boolean[]> fm) {
5338         short[] a = fa.apply(SPECIES.length());
5339         int[] order = fs.apply(a.length, SPECIES.length());
5340         short[] r = fr.apply(SPECIES.length());
5341         boolean[] mask = fm.apply(SPECIES.length());
5342         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5343 
5344         for (int i = 0; i < a.length; i += SPECIES.length()) {
5345             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5346             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
5347         }
5348 
5349         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
5350     }
5351 
5352     @Test(dataProvider = "shortUnaryOpMaskProvider")
5353     static void compressShortMaxVectorTests(IntFunction<short[]> fa,
5354                                                 IntFunction<boolean[]> fm) {
5355         short[] a = fa.apply(SPECIES.length());
5356         short[] r = fr.apply(SPECIES.length());
5357         boolean[] mask = fm.apply(SPECIES.length());
5358         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5359 
5360         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5361             for (int i = 0; i < a.length; i += SPECIES.length()) {
5362                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5363                 av.compress(vmask).intoArray(r, i);
5364             }
5365         }
5366 
5367         assertcompressArraysEquals(r, a, mask, SPECIES.length());
5368     }
5369 
5370     @Test(dataProvider = "shortUnaryOpMaskProvider")
5371     static void expandShortMaxVectorTests(IntFunction<short[]> fa,
5372                                                 IntFunction<boolean[]> fm) {
5373         short[] a = fa.apply(SPECIES.length());
5374         short[] r = fr.apply(SPECIES.length());
5375         boolean[] mask = fm.apply(SPECIES.length());
5376         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5377 
5378         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5379             for (int i = 0; i < a.length; i += SPECIES.length()) {
5380                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5381                 av.expand(vmask).intoArray(r, i);
5382             }
5383         }
5384 
5385         assertexpandArraysEquals(r, a, mask, SPECIES.length());
5386     }
5387 
5388     @Test(dataProvider = "shortUnaryOpProvider")
5389     static void getShortMaxVectorTests(IntFunction<short[]> fa) {
5390         short[] a = fa.apply(SPECIES.length());
5391         short[] r = fr.apply(SPECIES.length());
5392 
5393         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5394             for (int i = 0; i < a.length; i += SPECIES.length()) {
5395                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5396                 int num_lanes = SPECIES.length();
5397                 // Manually unroll because full unroll happens after intrinsification.
5398                 // Unroll is needed because get intrinsic requires for index to be a known constant.
5399                 if (num_lanes == 1) {
5400                     r[i]=av.lane(0);
5401                 } else if (num_lanes == 2) {
5402                     r[i]=av.lane(0);
5403                     r[i+1]=av.lane(1);
5404                 } else if (num_lanes == 4) {
5405                     r[i]=av.lane(0);
5406                     r[i+1]=av.lane(1);
5407                     r[i+2]=av.lane(2);
5408                     r[i+3]=av.lane(3);
5409                 } else if (num_lanes == 8) {
5410                     r[i]=av.lane(0);
5411                     r[i+1]=av.lane(1);
5412                     r[i+2]=av.lane(2);
5413                     r[i+3]=av.lane(3);
5414                     r[i+4]=av.lane(4);
5415                     r[i+5]=av.lane(5);
5416                     r[i+6]=av.lane(6);
5417                     r[i+7]=av.lane(7);
5418                 } else if (num_lanes == 16) {
5419                     r[i]=av.lane(0);
5420                     r[i+1]=av.lane(1);
5421                     r[i+2]=av.lane(2);
5422                     r[i+3]=av.lane(3);
5423                     r[i+4]=av.lane(4);
5424                     r[i+5]=av.lane(5);
5425                     r[i+6]=av.lane(6);
5426                     r[i+7]=av.lane(7);
5427                     r[i+8]=av.lane(8);
5428                     r[i+9]=av.lane(9);
5429                     r[i+10]=av.lane(10);
5430                     r[i+11]=av.lane(11);
5431                     r[i+12]=av.lane(12);
5432                     r[i+13]=av.lane(13);
5433                     r[i+14]=av.lane(14);
5434                     r[i+15]=av.lane(15);
5435                 } else if (num_lanes == 32) {
5436                     r[i]=av.lane(0);
5437                     r[i+1]=av.lane(1);
5438                     r[i+2]=av.lane(2);
5439                     r[i+3]=av.lane(3);
5440                     r[i+4]=av.lane(4);
5441                     r[i+5]=av.lane(5);
5442                     r[i+6]=av.lane(6);
5443                     r[i+7]=av.lane(7);
5444                     r[i+8]=av.lane(8);
5445                     r[i+9]=av.lane(9);
5446                     r[i+10]=av.lane(10);
5447                     r[i+11]=av.lane(11);
5448                     r[i+12]=av.lane(12);
5449                     r[i+13]=av.lane(13);
5450                     r[i+14]=av.lane(14);
5451                     r[i+15]=av.lane(15);
5452                     r[i+16]=av.lane(16);
5453                     r[i+17]=av.lane(17);
5454                     r[i+18]=av.lane(18);
5455                     r[i+19]=av.lane(19);
5456                     r[i+20]=av.lane(20);
5457                     r[i+21]=av.lane(21);
5458                     r[i+22]=av.lane(22);
5459                     r[i+23]=av.lane(23);
5460                     r[i+24]=av.lane(24);
5461                     r[i+25]=av.lane(25);
5462                     r[i+26]=av.lane(26);
5463                     r[i+27]=av.lane(27);
5464                     r[i+28]=av.lane(28);
5465                     r[i+29]=av.lane(29);
5466                     r[i+30]=av.lane(30);
5467                     r[i+31]=av.lane(31);
5468                 } else if (num_lanes == 64) {
5469                     r[i]=av.lane(0);
5470                     r[i+1]=av.lane(1);
5471                     r[i+2]=av.lane(2);
5472                     r[i+3]=av.lane(3);
5473                     r[i+4]=av.lane(4);
5474                     r[i+5]=av.lane(5);
5475                     r[i+6]=av.lane(6);
5476                     r[i+7]=av.lane(7);
5477                     r[i+8]=av.lane(8);
5478                     r[i+9]=av.lane(9);
5479                     r[i+10]=av.lane(10);
5480                     r[i+11]=av.lane(11);
5481                     r[i+12]=av.lane(12);
5482                     r[i+13]=av.lane(13);
5483                     r[i+14]=av.lane(14);
5484                     r[i+15]=av.lane(15);
5485                     r[i+16]=av.lane(16);
5486                     r[i+17]=av.lane(17);
5487                     r[i+18]=av.lane(18);
5488                     r[i+19]=av.lane(19);
5489                     r[i+20]=av.lane(20);
5490                     r[i+21]=av.lane(21);
5491                     r[i+22]=av.lane(22);
5492                     r[i+23]=av.lane(23);
5493                     r[i+24]=av.lane(24);
5494                     r[i+25]=av.lane(25);
5495                     r[i+26]=av.lane(26);
5496                     r[i+27]=av.lane(27);
5497                     r[i+28]=av.lane(28);
5498                     r[i+29]=av.lane(29);
5499                     r[i+30]=av.lane(30);
5500                     r[i+31]=av.lane(31);
5501                     r[i+32]=av.lane(32);
5502                     r[i+33]=av.lane(33);
5503                     r[i+34]=av.lane(34);
5504                     r[i+35]=av.lane(35);
5505                     r[i+36]=av.lane(36);
5506                     r[i+37]=av.lane(37);
5507                     r[i+38]=av.lane(38);
5508                     r[i+39]=av.lane(39);
5509                     r[i+40]=av.lane(40);
5510                     r[i+41]=av.lane(41);
5511                     r[i+42]=av.lane(42);
5512                     r[i+43]=av.lane(43);
5513                     r[i+44]=av.lane(44);
5514                     r[i+45]=av.lane(45);
5515                     r[i+46]=av.lane(46);
5516                     r[i+47]=av.lane(47);
5517                     r[i+48]=av.lane(48);
5518                     r[i+49]=av.lane(49);
5519                     r[i+50]=av.lane(50);
5520                     r[i+51]=av.lane(51);
5521                     r[i+52]=av.lane(52);
5522                     r[i+53]=av.lane(53);
5523                     r[i+54]=av.lane(54);
5524                     r[i+55]=av.lane(55);
5525                     r[i+56]=av.lane(56);
5526                     r[i+57]=av.lane(57);
5527                     r[i+58]=av.lane(58);
5528                     r[i+59]=av.lane(59);
5529                     r[i+60]=av.lane(60);
5530                     r[i+61]=av.lane(61);
5531                     r[i+62]=av.lane(62);
5532                     r[i+63]=av.lane(63);
5533                 } else {
5534                     for (int j = 0; j < SPECIES.length(); j++) {
5535                         r[i+j]=av.lane(j);
5536                     }
5537                 }
5538             }
5539         }
5540 
5541         assertArraysStrictlyEquals(r, a);
5542     }
5543 
5544     @Test(dataProvider = "shortUnaryOpProvider")
5545     static void BroadcastShortMaxVectorTests(IntFunction<short[]> fa) {
5546         short[] a = fa.apply(SPECIES.length());
5547         short[] r = new short[a.length];
5548 
5549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5550             for (int i = 0; i < a.length; i += SPECIES.length()) {
5551                 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i);
5552             }
5553         }
5554 
5555         assertBroadcastArraysEquals(r, a);
5556     }
5557 
5558     @Test(dataProvider = "shortUnaryOpProvider")
5559     static void ZeroShortMaxVectorTests(IntFunction<short[]> fa) {
5560         short[] a = fa.apply(SPECIES.length());
5561         short[] r = new short[a.length];
5562 
5563         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5564             for (int i = 0; i < a.length; i += SPECIES.length()) {
5565                 ShortVector.zero(SPECIES).intoArray(a, i);
5566             }
5567         }
5568 
5569         Assert.assertEquals(a, r);
5570     }
5571 
5572     static short[] sliceUnary(short[] a, int origin, int idx) {
5573         short[] res = new short[SPECIES.length()];
5574         for (int i = 0; i < SPECIES.length(); i++){
5575             if(i+origin < SPECIES.length())
5576                 res[i] = a[idx+i+origin];
5577             else
5578                 res[i] = (short)0;
5579         }
5580         return res;
5581     }
5582 
5583     @Test(dataProvider = "shortUnaryOpProvider")
5584     static void sliceUnaryShortMaxVectorTests(IntFunction<short[]> fa) {
5585         short[] a = fa.apply(SPECIES.length());
5586         short[] r = new short[a.length];
5587         int origin = RAND.nextInt(SPECIES.length());
5588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5589             for (int i = 0; i < a.length; i += SPECIES.length()) {
5590                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5591                 av.slice(origin).intoArray(r, i);
5592             }
5593         }
5594 
5595         assertArraysEquals(r, a, origin, ShortMaxVectorTests::sliceUnary);
5596     }
5597 
5598     static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
5599         short[] res = new short[SPECIES.length()];
5600         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5601             if(i+origin < SPECIES.length())
5602                 res[i] = a[idx+i+origin];
5603             else {
5604                 res[i] = b[idx+j];
5605                 j++;
5606             }
5607         }
5608         return res;
5609     }
5610 
5611     @Test(dataProvider = "shortBinaryOpProvider")
5612     static void sliceBinaryShortMaxVectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5613         short[] a = fa.apply(SPECIES.length());
5614         short[] b = fb.apply(SPECIES.length());
5615         short[] r = new short[a.length];
5616         int origin = RAND.nextInt(SPECIES.length());
5617         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5618             for (int i = 0; i < a.length; i += SPECIES.length()) {
5619                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5620                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5621                 av.slice(origin, bv).intoArray(r, i);
5622             }
5623         }
5624 
5625         assertArraysEquals(r, a, b, origin, ShortMaxVectorTests::sliceBinary);
5626     }
5627 
5628     static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
5629         short[] res = new short[SPECIES.length()];
5630         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5631             if(i+origin < SPECIES.length())
5632                 res[i] = mask[i] ? a[idx+i+origin] : (short)0;
5633             else {
5634                 res[i] = mask[i] ? b[idx+j] : (short)0;
5635                 j++;
5636             }
5637         }
5638         return res;
5639     }
5640 
5641     @Test(dataProvider = "shortBinaryOpMaskProvider")
5642     static void sliceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5643     IntFunction<boolean[]> fm) {
5644         short[] a = fa.apply(SPECIES.length());
5645         short[] b = fb.apply(SPECIES.length());
5646         boolean[] mask = fm.apply(SPECIES.length());
5647         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5648 
5649         short[] r = new short[a.length];
5650         int origin = RAND.nextInt(SPECIES.length());
5651         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5652             for (int i = 0; i < a.length; i += SPECIES.length()) {
5653                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5654                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5655                 av.slice(origin, bv, vmask).intoArray(r, i);
5656             }
5657         }
5658 
5659         assertArraysEquals(r, a, b, origin, mask, ShortMaxVectorTests::slice);
5660     }
5661 
5662     static short[] unsliceUnary(short[] a, int origin, int idx) {
5663         short[] res = new short[SPECIES.length()];
5664         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5665             if(i < origin)
5666                 res[i] = (short)0;
5667             else {
5668                 res[i] = a[idx+j];
5669                 j++;
5670             }
5671         }
5672         return res;
5673     }
5674 
5675     @Test(dataProvider = "shortUnaryOpProvider")
5676     static void unsliceUnaryShortMaxVectorTests(IntFunction<short[]> fa) {
5677         short[] a = fa.apply(SPECIES.length());
5678         short[] r = new short[a.length];
5679         int origin = RAND.nextInt(SPECIES.length());
5680         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5681             for (int i = 0; i < a.length; i += SPECIES.length()) {
5682                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5683                 av.unslice(origin).intoArray(r, i);
5684             }
5685         }
5686 
5687         assertArraysEquals(r, a, origin, ShortMaxVectorTests::unsliceUnary);
5688     }
5689 
5690     static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
5691         short[] res = new short[SPECIES.length()];
5692         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5693             if (part == 0) {
5694                 if (i < origin)
5695                     res[i] = b[idx+i];
5696                 else {
5697                     res[i] = a[idx+j];
5698                     j++;
5699                 }
5700             } else if (part == 1) {
5701                 if (i < origin)
5702                     res[i] = a[idx+SPECIES.length()-origin+i];
5703                 else {
5704                     res[i] = b[idx+origin+j];
5705                     j++;
5706                 }
5707             }
5708         }
5709         return res;
5710     }
5711 
5712     @Test(dataProvider = "shortBinaryOpProvider")
5713     static void unsliceBinaryShortMaxVectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5714         short[] a = fa.apply(SPECIES.length());
5715         short[] b = fb.apply(SPECIES.length());
5716         short[] r = new short[a.length];
5717         int origin = RAND.nextInt(SPECIES.length());
5718         int part = RAND.nextInt(2);
5719         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5720             for (int i = 0; i < a.length; i += SPECIES.length()) {
5721                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5722                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5723                 av.unslice(origin, bv, part).intoArray(r, i);
5724             }
5725         }
5726 
5727         assertArraysEquals(r, a, b, origin, part, ShortMaxVectorTests::unsliceBinary);
5728     }
5729 
5730     static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
5731         short[] res = new short[SPECIES.length()];
5732         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5733             if(i+origin < SPECIES.length())
5734                 res[i] = b[idx+i+origin];
5735             else {
5736                 res[i] = b[idx+j];
5737                 j++;
5738             }
5739         }
5740         for (int i = 0; i < SPECIES.length(); i++){
5741             res[i] = mask[i] ? a[idx+i] : res[i];
5742         }
5743         short[] res1 = new short[SPECIES.length()];
5744         if (part == 0) {
5745             for (int i = 0, j = 0; i < SPECIES.length(); i++){
5746                 if (i < origin)
5747                     res1[i] = b[idx+i];
5748                 else {
5749                    res1[i] = res[j];
5750                    j++;
5751                 }
5752             }
5753         } else if (part == 1) {
5754             for (int i = 0, j = 0; i < SPECIES.length(); i++){
5755                 if (i < origin)
5756                     res1[i] = res[SPECIES.length()-origin+i];
5757                 else {
5758                     res1[i] = b[idx+origin+j];
5759                     j++;
5760                 }
5761             }
5762         }
5763         return res1;
5764     }
5765 
5766     @Test(dataProvider = "shortBinaryOpMaskProvider")
5767     static void unsliceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5768     IntFunction<boolean[]> fm) {
5769         short[] a = fa.apply(SPECIES.length());
5770         short[] b = fb.apply(SPECIES.length());
5771         boolean[] mask = fm.apply(SPECIES.length());
5772         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5773         short[] r = new short[a.length];
5774         int origin = RAND.nextInt(SPECIES.length());
5775         int part = RAND.nextInt(2);
5776         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5777             for (int i = 0; i < a.length; i += SPECIES.length()) {
5778                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5779                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5780                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
5781             }
5782         }
5783 
5784         assertArraysEquals(r, a, b, origin, part, mask, ShortMaxVectorTests::unslice);
5785     }
5786 
5787     static short BITWISE_BLEND(short a, short b, short c) {
5788         return (short)((a&~(c))|(b&c));
5789     }
5790 
5791     static short bitwiseBlend(short a, short b, short c) {
5792         return (short)((a&~(c))|(b&c));
5793     }
5794 
5795     @Test(dataProvider = "shortTernaryOpProvider")
5796     static void BITWISE_BLENDShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5797         short[] a = fa.apply(SPECIES.length());
5798         short[] b = fb.apply(SPECIES.length());
5799         short[] c = fc.apply(SPECIES.length());
5800         short[] r = fr.apply(SPECIES.length());
5801 
5802         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5803             for (int i = 0; i < a.length; i += SPECIES.length()) {
5804                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5805                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5806                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5807                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5808             }
5809         }
5810 
5811         assertArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND);
5812     }
5813 
5814     @Test(dataProvider = "shortTernaryOpProvider")
5815     static void bitwiseBlendShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5816         short[] a = fa.apply(SPECIES.length());
5817         short[] b = fb.apply(SPECIES.length());
5818         short[] c = fc.apply(SPECIES.length());
5819         short[] r = fr.apply(SPECIES.length());
5820 
5821         for (int i = 0; i < a.length; i += SPECIES.length()) {
5822             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5823             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5824             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5825             av.bitwiseBlend(bv, cv).intoArray(r, i);
5826         }
5827 
5828         assertArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend);
5829     }
5830 
5831     @Test(dataProvider = "shortTernaryOpMaskProvider")
5832     static void BITWISE_BLENDShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5833                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5834         short[] a = fa.apply(SPECIES.length());
5835         short[] b = fb.apply(SPECIES.length());
5836         short[] c = fc.apply(SPECIES.length());
5837         short[] r = fr.apply(SPECIES.length());
5838         boolean[] mask = fm.apply(SPECIES.length());
5839         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5840 
5841         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5842             for (int i = 0; i < a.length; i += SPECIES.length()) {
5843                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5844                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5845                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5846                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5847             }
5848         }
5849 
5850         assertArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND);
5851     }
5852 
5853     @Test(dataProvider = "shortTernaryOpProvider")
5854     static void BITWISE_BLENDShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5855         short[] a = fa.apply(SPECIES.length());
5856         short[] b = fb.apply(SPECIES.length());
5857         short[] c = fc.apply(SPECIES.length());
5858         short[] r = fr.apply(SPECIES.length());
5859 
5860         for (int i = 0; i < a.length; i += SPECIES.length()) {
5861             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5862             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5863             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5864         }
5865         assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND);
5866     }
5867 
5868     @Test(dataProvider = "shortTernaryOpProvider")
5869     static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5870         short[] a = fa.apply(SPECIES.length());
5871         short[] b = fb.apply(SPECIES.length());
5872         short[] c = fc.apply(SPECIES.length());
5873         short[] r = fr.apply(SPECIES.length());
5874 
5875         for (int i = 0; i < a.length; i += SPECIES.length()) {
5876             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5877             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5878             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5879         }
5880         assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND);
5881     }
5882 
5883     @Test(dataProvider = "shortTernaryOpProvider")
5884     static void bitwiseBlendShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5885         short[] a = fa.apply(SPECIES.length());
5886         short[] b = fb.apply(SPECIES.length());
5887         short[] c = fc.apply(SPECIES.length());
5888         short[] r = fr.apply(SPECIES.length());
5889 
5890         for (int i = 0; i < a.length; i += SPECIES.length()) {
5891             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5892             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5893             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5894         }
5895         assertBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend);
5896     }
5897 
5898     @Test(dataProvider = "shortTernaryOpProvider")
5899     static void bitwiseBlendShortMaxVectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5900         short[] a = fa.apply(SPECIES.length());
5901         short[] b = fb.apply(SPECIES.length());
5902         short[] c = fc.apply(SPECIES.length());
5903         short[] r = fr.apply(SPECIES.length());
5904 
5905         for (int i = 0; i < a.length; i += SPECIES.length()) {
5906             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5907             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5908             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5909         }
5910         assertAltBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend);
5911     }
5912 
5913     @Test(dataProvider = "shortTernaryOpMaskProvider")
5914     static void BITWISE_BLENDShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5915                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5916         short[] a = fa.apply(SPECIES.length());
5917         short[] b = fb.apply(SPECIES.length());
5918         short[] c = fc.apply(SPECIES.length());
5919         short[] r = fr.apply(SPECIES.length());
5920         boolean[] mask = fm.apply(SPECIES.length());
5921         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5922 
5923         for (int i = 0; i < a.length; i += SPECIES.length()) {
5924             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5925             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5926             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5927         }
5928 
5929         assertBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND);
5930     }
5931 
5932     @Test(dataProvider = "shortTernaryOpMaskProvider")
5933     static void BITWISE_BLENDShortMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5934                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5935         short[] a = fa.apply(SPECIES.length());
5936         short[] b = fb.apply(SPECIES.length());
5937         short[] c = fc.apply(SPECIES.length());
5938         short[] r = fr.apply(SPECIES.length());
5939         boolean[] mask = fm.apply(SPECIES.length());
5940         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5941 
5942         for (int i = 0; i < a.length; i += SPECIES.length()) {
5943             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5944             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5945             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5946         }
5947 
5948         assertAltBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND);
5949     }
5950 
5951     @Test(dataProvider = "shortTernaryOpProvider")
5952     static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5953         short[] a = fa.apply(SPECIES.length());
5954         short[] b = fb.apply(SPECIES.length());
5955         short[] c = fc.apply(SPECIES.length());
5956         short[] r = fr.apply(SPECIES.length());
5957 
5958         for (int i = 0; i < a.length; i += SPECIES.length()) {
5959             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5960             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5961         }
5962 
5963         assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::BITWISE_BLEND);
5964     }
5965 
5966     @Test(dataProvider = "shortTernaryOpProvider")
5967     static void bitwiseBlendShortMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5968         short[] a = fa.apply(SPECIES.length());
5969         short[] b = fb.apply(SPECIES.length());
5970         short[] c = fc.apply(SPECIES.length());
5971         short[] r = fr.apply(SPECIES.length());
5972 
5973         for (int i = 0; i < a.length; i += SPECIES.length()) {
5974             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5975             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5976         }
5977 
5978         assertDoubleBroadcastArraysEquals(r, a, b, c, ShortMaxVectorTests::bitwiseBlend);
5979     }
5980 
5981     @Test(dataProvider = "shortTernaryOpMaskProvider")
5982     static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5983                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5984         short[] a = fa.apply(SPECIES.length());
5985         short[] b = fb.apply(SPECIES.length());
5986         short[] c = fc.apply(SPECIES.length());
5987         short[] r = fr.apply(SPECIES.length());
5988         boolean[] mask = fm.apply(SPECIES.length());
5989         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5990 
5991         for (int i = 0; i < a.length; i += SPECIES.length()) {
5992             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5993             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5994         }
5995 
5996         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ShortMaxVectorTests::BITWISE_BLEND);
5997     }
5998 
5999     static short NEG(short a) {
6000         return (short)(-((short)a));
6001     }
6002 
6003     static short neg(short a) {
6004         return (short)(-((short)a));
6005     }
6006 
6007     @Test(dataProvider = "shortUnaryOpProvider")
6008     static void NEGShortMaxVectorTests(IntFunction<short[]> fa) {
6009         short[] a = fa.apply(SPECIES.length());
6010         short[] r = fr.apply(SPECIES.length());
6011 
6012         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6013             for (int i = 0; i < a.length; i += SPECIES.length()) {
6014                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6015                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
6016             }
6017         }
6018 
6019         assertArraysEquals(r, a, ShortMaxVectorTests::NEG);
6020     }
6021 
6022     @Test(dataProvider = "shortUnaryOpProvider")
6023     static void negShortMaxVectorTests(IntFunction<short[]> fa) {
6024         short[] a = fa.apply(SPECIES.length());
6025         short[] r = fr.apply(SPECIES.length());
6026 
6027         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6028             for (int i = 0; i < a.length; i += SPECIES.length()) {
6029                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6030                 av.neg().intoArray(r, i);
6031             }
6032         }
6033 
6034         assertArraysEquals(r, a, ShortMaxVectorTests::neg);
6035     }
6036 
6037     @Test(dataProvider = "shortUnaryOpMaskProvider")
6038     static void NEGMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6039                                                 IntFunction<boolean[]> fm) {
6040         short[] a = fa.apply(SPECIES.length());
6041         short[] r = fr.apply(SPECIES.length());
6042         boolean[] mask = fm.apply(SPECIES.length());
6043         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6044 
6045         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6046             for (int i = 0; i < a.length; i += SPECIES.length()) {
6047                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6048                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
6049             }
6050         }
6051 
6052         assertArraysEquals(r, a, mask, ShortMaxVectorTests::NEG);
6053     }
6054 
6055     static short ABS(short a) {
6056         return (short)(Math.abs((short)a));
6057     }
6058 
6059     static short abs(short a) {
6060         return (short)(Math.abs((short)a));
6061     }
6062 
6063     @Test(dataProvider = "shortUnaryOpProvider")
6064     static void ABSShortMaxVectorTests(IntFunction<short[]> fa) {
6065         short[] a = fa.apply(SPECIES.length());
6066         short[] r = fr.apply(SPECIES.length());
6067 
6068         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6069             for (int i = 0; i < a.length; i += SPECIES.length()) {
6070                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6071                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
6072             }
6073         }
6074 
6075         assertArraysEquals(r, a, ShortMaxVectorTests::ABS);
6076     }
6077 
6078     @Test(dataProvider = "shortUnaryOpProvider")
6079     static void absShortMaxVectorTests(IntFunction<short[]> fa) {
6080         short[] a = fa.apply(SPECIES.length());
6081         short[] r = fr.apply(SPECIES.length());
6082 
6083         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6084             for (int i = 0; i < a.length; i += SPECIES.length()) {
6085                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6086                 av.abs().intoArray(r, i);
6087             }
6088         }
6089 
6090         assertArraysEquals(r, a, ShortMaxVectorTests::abs);
6091     }
6092 
6093     @Test(dataProvider = "shortUnaryOpMaskProvider")
6094     static void ABSMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6095                                                 IntFunction<boolean[]> fm) {
6096         short[] a = fa.apply(SPECIES.length());
6097         short[] r = fr.apply(SPECIES.length());
6098         boolean[] mask = fm.apply(SPECIES.length());
6099         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6100 
6101         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6102             for (int i = 0; i < a.length; i += SPECIES.length()) {
6103                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6104                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
6105             }
6106         }
6107 
6108         assertArraysEquals(r, a, mask, ShortMaxVectorTests::ABS);
6109     }
6110 
6111     static short NOT(short a) {
6112         return (short)(~((short)a));
6113     }
6114 
6115     static short not(short a) {
6116         return (short)(~((short)a));
6117     }
6118 
6119     @Test(dataProvider = "shortUnaryOpProvider")
6120     static void NOTShortMaxVectorTests(IntFunction<short[]> fa) {
6121         short[] a = fa.apply(SPECIES.length());
6122         short[] r = fr.apply(SPECIES.length());
6123 
6124         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6125             for (int i = 0; i < a.length; i += SPECIES.length()) {
6126                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6127                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
6128             }
6129         }
6130 
6131         assertArraysEquals(r, a, ShortMaxVectorTests::NOT);
6132     }
6133 
6134     @Test(dataProvider = "shortUnaryOpProvider")
6135     static void notShortMaxVectorTests(IntFunction<short[]> fa) {
6136         short[] a = fa.apply(SPECIES.length());
6137         short[] r = fr.apply(SPECIES.length());
6138 
6139         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6140             for (int i = 0; i < a.length; i += SPECIES.length()) {
6141                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6142                 av.not().intoArray(r, i);
6143             }
6144         }
6145 
6146         assertArraysEquals(r, a, ShortMaxVectorTests::not);
6147     }
6148 
6149     @Test(dataProvider = "shortUnaryOpMaskProvider")
6150     static void NOTMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6151                                                 IntFunction<boolean[]> fm) {
6152         short[] a = fa.apply(SPECIES.length());
6153         short[] r = fr.apply(SPECIES.length());
6154         boolean[] mask = fm.apply(SPECIES.length());
6155         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6156 
6157         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6158             for (int i = 0; i < a.length; i += SPECIES.length()) {
6159                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6160                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
6161             }
6162         }
6163 
6164         assertArraysEquals(r, a, mask, ShortMaxVectorTests::NOT);
6165     }
6166 
6167     static short ZOMO(short a) {
6168         return (short)((a==0?0:-1));
6169     }
6170 
6171     @Test(dataProvider = "shortUnaryOpProvider")
6172     static void ZOMOShortMaxVectorTests(IntFunction<short[]> fa) {
6173         short[] a = fa.apply(SPECIES.length());
6174         short[] r = fr.apply(SPECIES.length());
6175 
6176         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6177             for (int i = 0; i < a.length; i += SPECIES.length()) {
6178                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6179                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
6180             }
6181         }
6182 
6183         assertArraysEquals(r, a, ShortMaxVectorTests::ZOMO);
6184     }
6185 
6186     @Test(dataProvider = "shortUnaryOpMaskProvider")
6187     static void ZOMOMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6188                                                 IntFunction<boolean[]> fm) {
6189         short[] a = fa.apply(SPECIES.length());
6190         short[] r = fr.apply(SPECIES.length());
6191         boolean[] mask = fm.apply(SPECIES.length());
6192         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6193 
6194         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6195             for (int i = 0; i < a.length; i += SPECIES.length()) {
6196                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6197                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
6198             }
6199         }
6200 
6201         assertArraysEquals(r, a, mask, ShortMaxVectorTests::ZOMO);
6202     }
6203 
6204     static short BIT_COUNT(short a) {
6205         return (short)(Integer.bitCount((int)a & 0xFFFF));
6206     }
6207 
6208     @Test(dataProvider = "shortUnaryOpProvider")
6209     static void BIT_COUNTShortMaxVectorTests(IntFunction<short[]> fa) {
6210         short[] a = fa.apply(SPECIES.length());
6211         short[] r = fr.apply(SPECIES.length());
6212 
6213         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6214             for (int i = 0; i < a.length; i += SPECIES.length()) {
6215                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6216                 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
6217             }
6218         }
6219 
6220         assertArraysEquals(r, a, ShortMaxVectorTests::BIT_COUNT);
6221     }
6222 
6223     @Test(dataProvider = "shortUnaryOpMaskProvider")
6224     static void BIT_COUNTMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6225                                                 IntFunction<boolean[]> fm) {
6226         short[] a = fa.apply(SPECIES.length());
6227         short[] r = fr.apply(SPECIES.length());
6228         boolean[] mask = fm.apply(SPECIES.length());
6229         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6230 
6231         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6232             for (int i = 0; i < a.length; i += SPECIES.length()) {
6233                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6234                 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
6235             }
6236         }
6237 
6238         assertArraysEquals(r, a, mask, ShortMaxVectorTests::BIT_COUNT);
6239     }
6240 
6241     static short TRAILING_ZEROS_COUNT(short a) {
6242         return (short)(TRAILING_ZEROS_COUNT_scalar(a));
6243     }
6244 
6245     @Test(dataProvider = "shortUnaryOpProvider")
6246     static void TRAILING_ZEROS_COUNTShortMaxVectorTests(IntFunction<short[]> fa) {
6247         short[] a = fa.apply(SPECIES.length());
6248         short[] r = fr.apply(SPECIES.length());
6249 
6250         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6251             for (int i = 0; i < a.length; i += SPECIES.length()) {
6252                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6253                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
6254             }
6255         }
6256 
6257         assertArraysEquals(r, a, ShortMaxVectorTests::TRAILING_ZEROS_COUNT);
6258     }
6259 
6260     @Test(dataProvider = "shortUnaryOpMaskProvider")
6261     static void TRAILING_ZEROS_COUNTMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6262                                                 IntFunction<boolean[]> fm) {
6263         short[] a = fa.apply(SPECIES.length());
6264         short[] r = fr.apply(SPECIES.length());
6265         boolean[] mask = fm.apply(SPECIES.length());
6266         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6267 
6268         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6269             for (int i = 0; i < a.length; i += SPECIES.length()) {
6270                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6271                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
6272             }
6273         }
6274 
6275         assertArraysEquals(r, a, mask, ShortMaxVectorTests::TRAILING_ZEROS_COUNT);
6276     }
6277 
6278     static short LEADING_ZEROS_COUNT(short a) {
6279         return (short)(LEADING_ZEROS_COUNT_scalar(a));
6280     }
6281 
6282     @Test(dataProvider = "shortUnaryOpProvider")
6283     static void LEADING_ZEROS_COUNTShortMaxVectorTests(IntFunction<short[]> fa) {
6284         short[] a = fa.apply(SPECIES.length());
6285         short[] r = fr.apply(SPECIES.length());
6286 
6287         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6288             for (int i = 0; i < a.length; i += SPECIES.length()) {
6289                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6290                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
6291             }
6292         }
6293 
6294         assertArraysEquals(r, a, ShortMaxVectorTests::LEADING_ZEROS_COUNT);
6295     }
6296 
6297     @Test(dataProvider = "shortUnaryOpMaskProvider")
6298     static void LEADING_ZEROS_COUNTMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6299                                                 IntFunction<boolean[]> fm) {
6300         short[] a = fa.apply(SPECIES.length());
6301         short[] r = fr.apply(SPECIES.length());
6302         boolean[] mask = fm.apply(SPECIES.length());
6303         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6304 
6305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6306             for (int i = 0; i < a.length; i += SPECIES.length()) {
6307                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6308                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
6309             }
6310         }
6311 
6312         assertArraysEquals(r, a, mask, ShortMaxVectorTests::LEADING_ZEROS_COUNT);
6313     }
6314 
6315     static short REVERSE(short a) {
6316         return (short)(REVERSE_scalar(a));
6317     }
6318 
6319     @Test(dataProvider = "shortUnaryOpProvider")
6320     static void REVERSEShortMaxVectorTests(IntFunction<short[]> fa) {
6321         short[] a = fa.apply(SPECIES.length());
6322         short[] r = fr.apply(SPECIES.length());
6323 
6324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6325             for (int i = 0; i < a.length; i += SPECIES.length()) {
6326                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6327                 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
6328             }
6329         }
6330 
6331         assertArraysEquals(r, a, ShortMaxVectorTests::REVERSE);
6332     }
6333 
6334     @Test(dataProvider = "shortUnaryOpMaskProvider")
6335     static void REVERSEMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6336                                                 IntFunction<boolean[]> fm) {
6337         short[] a = fa.apply(SPECIES.length());
6338         short[] r = fr.apply(SPECIES.length());
6339         boolean[] mask = fm.apply(SPECIES.length());
6340         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6341 
6342         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6343             for (int i = 0; i < a.length; i += SPECIES.length()) {
6344                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6345                 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
6346             }
6347         }
6348 
6349         assertArraysEquals(r, a, mask, ShortMaxVectorTests::REVERSE);
6350     }
6351 
6352     static short REVERSE_BYTES(short a) {
6353         return (short)(Short.reverseBytes(a));
6354     }
6355 
6356     @Test(dataProvider = "shortUnaryOpProvider")
6357     static void REVERSE_BYTESShortMaxVectorTests(IntFunction<short[]> fa) {
6358         short[] a = fa.apply(SPECIES.length());
6359         short[] r = fr.apply(SPECIES.length());
6360 
6361         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6362             for (int i = 0; i < a.length; i += SPECIES.length()) {
6363                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6364                 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
6365             }
6366         }
6367 
6368         assertArraysEquals(r, a, ShortMaxVectorTests::REVERSE_BYTES);
6369     }
6370 
6371     @Test(dataProvider = "shortUnaryOpMaskProvider")
6372     static void REVERSE_BYTESMaskedShortMaxVectorTests(IntFunction<short[]> fa,
6373                                                 IntFunction<boolean[]> fm) {
6374         short[] a = fa.apply(SPECIES.length());
6375         short[] r = fr.apply(SPECIES.length());
6376         boolean[] mask = fm.apply(SPECIES.length());
6377         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6378 
6379         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6380             for (int i = 0; i < a.length; i += SPECIES.length()) {
6381                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6382                 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
6383             }
6384         }
6385 
6386         assertArraysEquals(r, a, mask, ShortMaxVectorTests::REVERSE_BYTES);
6387     }
6388 
6389     @Test(dataProvider = "shortCompareOpProvider")
6390     static void ltShortMaxVectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
6391         short[] a = fa.apply(SPECIES.length());
6392         short[] b = fb.apply(SPECIES.length());
6393 
6394         for (int i = 0; i < a.length; i += SPECIES.length()) {
6395             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6396             VectorMask<Short> mv = av.lt(b[i]);
6397 
6398             // Check results as part of computation.
6399             for (int j = 0; j < SPECIES.length(); j++) {
6400                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
6401             }
6402         }
6403     }
6404 
6405     @Test(dataProvider = "shortCompareOpProvider")
6406     static void eqShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
6407         short[] a = fa.apply(SPECIES.length());
6408         short[] b = fb.apply(SPECIES.length());
6409 
6410         for (int i = 0; i < a.length; i += SPECIES.length()) {
6411             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6412             VectorMask<Short> mv = av.eq(b[i]);
6413 
6414             // Check results as part of computation.
6415             for (int j = 0; j < SPECIES.length(); j++) {
6416                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
6417             }
6418         }
6419     }
6420 
6421     @Test(dataProvider = "shortUnaryOpProvider")
6422     static void toIntArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6423         short[] a = fa.apply(SPECIES.length());
6424 
6425         for (int i = 0; i < a.length; i += SPECIES.length()) {
6426             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6427             int[] r = av.toIntArray();
6428             assertArraysEquals(r, a, i);
6429         }
6430     }
6431 
6432     @Test(dataProvider = "shortUnaryOpProvider")
6433     static void toLongArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6434         short[] a = fa.apply(SPECIES.length());
6435 
6436         for (int i = 0; i < a.length; i += SPECIES.length()) {
6437             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6438             long[] r = av.toLongArray();
6439             assertArraysEquals(r, a, i);
6440         }
6441     }
6442 
6443     @Test(dataProvider = "shortUnaryOpProvider")
6444     static void toDoubleArrayShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6445         short[] a = fa.apply(SPECIES.length());
6446 
6447         for (int i = 0; i < a.length; i += SPECIES.length()) {
6448             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6449             double[] r = av.toDoubleArray();
6450             assertArraysEquals(r, a, i);
6451         }
6452     }
6453 
6454     @Test(dataProvider = "shortUnaryOpProvider")
6455     static void toStringShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6456         short[] a = fa.apply(SPECIES.length());
6457 
6458         for (int i = 0; i < a.length; i += SPECIES.length()) {
6459             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6460             String str = av.toString();
6461 
6462             short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6463             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6464         }
6465     }
6466 
6467     @Test(dataProvider = "shortUnaryOpProvider")
6468     static void hashCodeShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6469         short[] a = fa.apply(SPECIES.length());
6470 
6471         for (int i = 0; i < a.length; i += SPECIES.length()) {
6472             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6473             int hash = av.hashCode();
6474 
6475             short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6476             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6477             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6478         }
6479     }
6480 
6481 
6482     static long ADDReduceLong(short[] a, int idx) {
6483         short res = 0;
6484         for (int i = idx; i < (idx + SPECIES.length()); i++) {
6485             res += a[i];
6486         }
6487 
6488         return (long)res;
6489     }
6490 
6491     static long ADDReduceAllLong(short[] a) {
6492         long res = 0;
6493         for (int i = 0; i < a.length; i += SPECIES.length()) {
6494             res += ADDReduceLong(a, i);
6495         }
6496 
6497         return res;
6498     }
6499 
6500     @Test(dataProvider = "shortUnaryOpProvider")
6501     static void ADDReduceLongShortMaxVectorTests(IntFunction<short[]> fa) {
6502         short[] a = fa.apply(SPECIES.length());
6503         long[] r = lfr.apply(SPECIES.length());
6504         long ra = 0;
6505 
6506         for (int i = 0; i < a.length; i += SPECIES.length()) {
6507             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6508             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
6509         }
6510 
6511         ra = 0;
6512         for (int i = 0; i < a.length; i ++) {
6513             ra += r[i];
6514         }
6515 
6516         assertReductionLongArraysEquals(r, ra, a,
6517                 ShortMaxVectorTests::ADDReduceLong, ShortMaxVectorTests::ADDReduceAllLong);
6518     }
6519 
6520     static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) {
6521         short res = 0;
6522         for (int i = idx; i < (idx + SPECIES.length()); i++) {
6523             if(mask[i % SPECIES.length()])
6524                 res += a[i];
6525         }
6526 
6527         return (long)res;
6528     }
6529 
6530     static long ADDReduceAllLongMasked(short[] a, boolean[] mask) {
6531         long res = 0;
6532         for (int i = 0; i < a.length; i += SPECIES.length()) {
6533             res += ADDReduceLongMasked(a, i, mask);
6534         }
6535 
6536         return res;
6537     }
6538 
6539     @Test(dataProvider = "shortUnaryOpMaskProvider")
6540     static void ADDReduceLongShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
6541         short[] a = fa.apply(SPECIES.length());
6542         long[] r = lfr.apply(SPECIES.length());
6543         boolean[] mask = fm.apply(SPECIES.length());
6544         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6545         long ra = 0;
6546 
6547         for (int i = 0; i < a.length; i += SPECIES.length()) {
6548             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6549             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
6550         }
6551 
6552         ra = 0;
6553         for (int i = 0; i < a.length; i ++) {
6554             ra += r[i];
6555         }
6556 
6557         assertReductionLongArraysEqualsMasked(r, ra, a, mask,
6558                 ShortMaxVectorTests::ADDReduceLongMasked, ShortMaxVectorTests::ADDReduceAllLongMasked);
6559     }
6560 
6561     @Test(dataProvider = "shortUnaryOpProvider")
6562     static void BroadcastLongShortMaxVectorTestsSmokeTest(IntFunction<short[]> fa) {
6563         short[] a = fa.apply(SPECIES.length());
6564         short[] r = new short[a.length];
6565 
6566         for (int i = 0; i < a.length; i += SPECIES.length()) {
6567             ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
6568         }
6569         assertBroadcastArraysEquals(r, a);
6570     }
6571 
6572     @Test(dataProvider = "shortBinaryOpMaskProvider")
6573     static void blendShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
6574                                           IntFunction<boolean[]> fm) {
6575         short[] a = fa.apply(SPECIES.length());
6576         short[] b = fb.apply(SPECIES.length());
6577         short[] r = fr.apply(SPECIES.length());
6578         boolean[] mask = fm.apply(SPECIES.length());
6579         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6580 
6581         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6582             for (int i = 0; i < a.length; i += SPECIES.length()) {
6583                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6584                 av.blend((long)b[i], vmask).intoArray(r, i);
6585             }
6586         }
6587         assertBroadcastLongArraysEquals(r, a, b, mask, ShortMaxVectorTests::blend);
6588     }
6589 
6590 
6591     @Test(dataProvider = "shortUnaryOpSelectFromProvider")
6592     static void SelectFromShortMaxVectorTests(IntFunction<short[]> fa,
6593                                            BiFunction<Integer,Integer,short[]> fs) {
6594         short[] a = fa.apply(SPECIES.length());
6595         short[] order = fs.apply(a.length, SPECIES.length());
6596         short[] r = fr.apply(SPECIES.length());
6597 
6598         for (int i = 0; i < a.length; i += SPECIES.length()) {
6599             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6600             ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
6601             bv.selectFrom(av).intoArray(r, i);
6602         }
6603 
6604         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
6605     }
6606 
6607     @Test(dataProvider = "shortSelectFromTwoVectorOpProvider")
6608     static void SelectFromTwoVectorShortMaxVectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
6609         short[] a = fa.apply(SPECIES.length());
6610         short[] b = fb.apply(SPECIES.length());
6611         short[] idx = fc.apply(SPECIES.length());
6612         short[] r = fr.apply(SPECIES.length());
6613 
6614         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6615             for (int i = 0; i < idx.length; i += SPECIES.length()) {
6616                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6617                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
6618                 ShortVector idxv = ShortVector.fromArray(SPECIES, idx, i);
6619                 idxv.selectFrom(av, bv).intoArray(r, i);
6620             }
6621         }
6622         assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length());
6623     }
6624 
6625     @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider")
6626     static void SelectFromShortMaxVectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
6627                                                            BiFunction<Integer,Integer,short[]> fs,
6628                                                            IntFunction<boolean[]> fm) {
6629         short[] a = fa.apply(SPECIES.length());
6630         short[] order = fs.apply(a.length, SPECIES.length());
6631         short[] r = fr.apply(SPECIES.length());
6632         boolean[] mask = fm.apply(SPECIES.length());
6633         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6634 
6635         for (int i = 0; i < a.length; i += SPECIES.length()) {
6636             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6637             ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
6638             bv.selectFrom(av, vmask).intoArray(r, i);
6639         }
6640 
6641         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
6642     }
6643 
6644     @Test(dataProvider = "shuffleProvider")
6645     static void shuffleMiscellaneousShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6646         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6647 
6648         for (int i = 0; i < a.length; i += SPECIES.length()) {
6649             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6650             int hash = shuffle.hashCode();
6651             int length = shuffle.length();
6652 
6653             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6654             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6655             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6656             Assert.assertEquals(length, SPECIES.length());
6657         }
6658     }
6659 
6660     @Test(dataProvider = "shuffleProvider")
6661     static void shuffleToStringShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6662         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6663 
6664         for (int i = 0; i < a.length; i += SPECIES.length()) {
6665             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6666             String str = shuffle.toString();
6667 
6668             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6669             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
6670                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6671         }
6672     }
6673 
6674     @Test(dataProvider = "shuffleCompareOpProvider")
6675     static void shuffleEqualsShortMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
6676         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6677         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6678 
6679         for (int i = 0; i < a.length; i += SPECIES.length()) {
6680             var av = VectorShuffle.fromArray(SPECIES, a, i);
6681             var bv = VectorShuffle.fromArray(SPECIES, b, i);
6682             boolean eq = av.equals(bv);
6683             int to = i + SPECIES.length();
6684             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
6685         }
6686     }
6687 
6688     @Test(dataProvider = "maskCompareOpProvider")
6689     static void maskEqualsShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6690         boolean[] a = fa.apply(SPECIES.length());
6691         boolean[] b = fb.apply(SPECIES.length());
6692 
6693         for (int i = 0; i < a.length; i += SPECIES.length()) {
6694             var av = SPECIES.loadMask(a, i);
6695             var bv = SPECIES.loadMask(b, i);
6696             boolean equals = av.equals(bv);
6697             int to = i + SPECIES.length();
6698             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
6699         }
6700     }
6701 
6702     static boolean band(boolean a, boolean b) {
6703         return a & b;
6704     }
6705 
6706     @Test(dataProvider = "maskCompareOpProvider")
6707     static void maskAndShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6708         boolean[] a = fa.apply(SPECIES.length());
6709         boolean[] b = fb.apply(SPECIES.length());
6710         boolean[] r = new boolean[a.length];
6711 
6712         for (int i = 0; i < a.length; i += SPECIES.length()) {
6713             var av = SPECIES.loadMask(a, i);
6714             var bv = SPECIES.loadMask(b, i);
6715             var cv = av.and(bv);
6716             cv.intoArray(r, i);
6717         }
6718         assertArraysEquals(r, a, b, ShortMaxVectorTests::band);
6719     }
6720 
6721     static boolean bor(boolean a, boolean b) {
6722         return a | b;
6723     }
6724 
6725     @Test(dataProvider = "maskCompareOpProvider")
6726     static void maskOrShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6727         boolean[] a = fa.apply(SPECIES.length());
6728         boolean[] b = fb.apply(SPECIES.length());
6729         boolean[] r = new boolean[a.length];
6730 
6731         for (int i = 0; i < a.length; i += SPECIES.length()) {
6732             var av = SPECIES.loadMask(a, i);
6733             var bv = SPECIES.loadMask(b, i);
6734             var cv = av.or(bv);
6735             cv.intoArray(r, i);
6736         }
6737         assertArraysEquals(r, a, b, ShortMaxVectorTests::bor);
6738     }
6739 
6740     static boolean bxor(boolean a, boolean b) {
6741         return a != b;
6742     }
6743 
6744     @Test(dataProvider = "maskCompareOpProvider")
6745     static void maskXorShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6746         boolean[] a = fa.apply(SPECIES.length());
6747         boolean[] b = fb.apply(SPECIES.length());
6748         boolean[] r = new boolean[a.length];
6749 
6750         for (int i = 0; i < a.length; i += SPECIES.length()) {
6751             var av = SPECIES.loadMask(a, i);
6752             var bv = SPECIES.loadMask(b, i);
6753             var cv = av.xor(bv);
6754             cv.intoArray(r, i);
6755         }
6756         assertArraysEquals(r, a, b, ShortMaxVectorTests::bxor);
6757     }
6758 
6759     static boolean bandNot(boolean a, boolean b) {
6760         return a & !b;
6761     }
6762 
6763     @Test(dataProvider = "maskCompareOpProvider")
6764     static void maskAndNotShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6765         boolean[] a = fa.apply(SPECIES.length());
6766         boolean[] b = fb.apply(SPECIES.length());
6767         boolean[] r = new boolean[a.length];
6768 
6769         for (int i = 0; i < a.length; i += SPECIES.length()) {
6770             var av = SPECIES.loadMask(a, i);
6771             var bv = SPECIES.loadMask(b, i);
6772             var cv = av.andNot(bv);
6773             cv.intoArray(r, i);
6774         }
6775         assertArraysEquals(r, a, b, ShortMaxVectorTests::bandNot);
6776     }
6777 
6778     static boolean beq(boolean a, boolean b) {
6779         return (a == b);
6780     }
6781 
6782     @Test(dataProvider = "maskCompareOpProvider")
6783     static void maskEqShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6784         boolean[] a = fa.apply(SPECIES.length());
6785         boolean[] b = fb.apply(SPECIES.length());
6786         boolean[] r = new boolean[a.length];
6787 
6788         for (int i = 0; i < a.length; i += SPECIES.length()) {
6789             var av = SPECIES.loadMask(a, i);
6790             var bv = SPECIES.loadMask(b, i);
6791             var cv = av.eq(bv);
6792             cv.intoArray(r, i);
6793         }
6794         assertArraysEquals(r, a, b, ShortMaxVectorTests::beq);
6795     }
6796 
6797     @Test(dataProvider = "maskProvider")
6798     static void maskHashCodeShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6799         boolean[] a = fa.apply(SPECIES.length());
6800 
6801         for (int i = 0; i < a.length; i += SPECIES.length()) {
6802             var vmask = SPECIES.loadMask(a, i);
6803             int hash = vmask.hashCode();
6804 
6805             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6806             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6807             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6808         }
6809     }
6810 
6811     static int maskTrueCount(boolean[] a, int idx) {
6812         int trueCount = 0;
6813         for (int i = idx; i < idx + SPECIES.length(); i++) {
6814             trueCount += a[i] ? 1 : 0;
6815         }
6816         return trueCount;
6817     }
6818 
6819     @Test(dataProvider = "maskProvider")
6820     static void maskTrueCountShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6821         boolean[] a = fa.apply(SPECIES.length());
6822         int[] r = new int[a.length];
6823 
6824         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6825             for (int i = 0; i < a.length; i += SPECIES.length()) {
6826                 var vmask = SPECIES.loadMask(a, i);
6827                 r[i] = vmask.trueCount();
6828             }
6829         }
6830 
6831         assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskTrueCount);
6832     }
6833 
6834     static int maskLastTrue(boolean[] a, int idx) {
6835         int i = idx + SPECIES.length() - 1;
6836         for (; i >= idx; i--) {
6837             if (a[i]) {
6838                 break;
6839             }
6840         }
6841         return i - idx;
6842     }
6843 
6844     @Test(dataProvider = "maskProvider")
6845     static void maskLastTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6846         boolean[] a = fa.apply(SPECIES.length());
6847         int[] r = new int[a.length];
6848 
6849         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6850             for (int i = 0; i < a.length; i += SPECIES.length()) {
6851                 var vmask = SPECIES.loadMask(a, i);
6852                 r[i] = vmask.lastTrue();
6853             }
6854         }
6855 
6856         assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskLastTrue);
6857     }
6858 
6859     static int maskFirstTrue(boolean[] a, int idx) {
6860         int i = idx;
6861         for (; i < idx + SPECIES.length(); i++) {
6862             if (a[i]) {
6863                 break;
6864             }
6865         }
6866         return i - idx;
6867     }
6868 
6869     @Test(dataProvider = "maskProvider")
6870     static void maskFirstTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6871         boolean[] a = fa.apply(SPECIES.length());
6872         int[] r = new int[a.length];
6873 
6874         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6875             for (int i = 0; i < a.length; i += SPECIES.length()) {
6876                 var vmask = SPECIES.loadMask(a, i);
6877                 r[i] = vmask.firstTrue();
6878             }
6879         }
6880 
6881         assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskFirstTrue);
6882     }
6883 
6884     @Test(dataProvider = "maskProvider")
6885     static void maskCompressShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6886         int trueCount = 0;
6887         boolean[] a = fa.apply(SPECIES.length());
6888 
6889         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6890             for (int i = 0; i < a.length; i += SPECIES.length()) {
6891                 var vmask = SPECIES.loadMask(a, i);
6892                 trueCount = vmask.trueCount();
6893                 var rmask = vmask.compress();
6894                 for (int j = 0; j < SPECIES.length(); j++)  {
6895                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
6896                 }
6897             }
6898         }
6899     }
6900 
6901 
6902     @DataProvider
6903     public static Object[][] offsetProvider() {
6904         return new Object[][]{
6905                 {0},
6906                 {-1},
6907                 {+1},
6908                 {+2},
6909                 {-2},
6910         };
6911     }
6912 
6913     @Test(dataProvider = "offsetProvider")
6914     static void indexInRangeShortMaxVectorTestsSmokeTest(int offset) {
6915         int limit = SPECIES.length() * BUFFER_REPS;
6916         for (int i = 0; i < limit; i += SPECIES.length()) {
6917             var actualMask = SPECIES.indexInRange(i + offset, limit);
6918             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6919             assert(actualMask.equals(expectedMask));
6920             for (int j = 0; j < SPECIES.length(); j++)  {
6921                 int index = i + j + offset;
6922                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6923             }
6924         }
6925     }
6926 
6927     @Test(dataProvider = "offsetProvider")
6928     static void indexInRangeLongShortMaxVectorTestsSmokeTest(int offset) {
6929         long limit = SPECIES.length() * BUFFER_REPS;
6930         for (long i = 0; i < limit; i += SPECIES.length()) {
6931             var actualMask = SPECIES.indexInRange(i + offset, limit);
6932             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6933             assert(actualMask.equals(expectedMask));
6934             for (int j = 0; j < SPECIES.length(); j++)  {
6935                 long index = i + j + offset;
6936                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6937             }
6938         }
6939     }
6940 
6941     @DataProvider
6942     public static Object[][] lengthProvider() {
6943         return new Object[][]{
6944                 {0},
6945                 {1},
6946                 {32},
6947                 {37},
6948                 {1024},
6949                 {1024+1},
6950                 {1024+5},
6951         };
6952     }
6953 
6954     @Test(dataProvider = "lengthProvider")
6955     static void loopBoundShortMaxVectorTestsSmokeTest(int length) {
6956         int actualLoopBound = SPECIES.loopBound(length);
6957         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6958         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6959     }
6960 
6961     @Test(dataProvider = "lengthProvider")
6962     static void loopBoundLongShortMaxVectorTestsSmokeTest(int _length) {
6963         long length = _length;
6964         long actualLoopBound = SPECIES.loopBound(length);
6965         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6966         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6967     }
6968 
6969     @Test
6970     static void ElementSizeShortMaxVectorTestsSmokeTest() {
6971         ShortVector av = ShortVector.zero(SPECIES);
6972         int elsize = av.elementSize();
6973         Assert.assertEquals(elsize, Short.SIZE);
6974     }
6975 
6976     @Test
6977     static void VectorShapeShortMaxVectorTestsSmokeTest() {
6978         ShortVector av = ShortVector.zero(SPECIES);
6979         VectorShape vsh = av.shape();
6980         assert(vsh.equals(VectorShape.S_Max_BIT));
6981     }
6982 
6983     @Test
6984     static void ShapeWithLanesShortMaxVectorTestsSmokeTest() {
6985         ShortVector av = ShortVector.zero(SPECIES);
6986         VectorShape vsh = av.shape();
6987         VectorSpecies species = vsh.withLanes(short.class);
6988         assert(species.equals(SPECIES));
6989     }
6990 
6991     @Test
6992     static void ElementTypeShortMaxVectorTestsSmokeTest() {
6993         ShortVector av = ShortVector.zero(SPECIES);
6994         assert(av.species().elementType() == short.class);
6995     }
6996 
6997     @Test
6998     static void SpeciesElementSizeShortMaxVectorTestsSmokeTest() {
6999         ShortVector av = ShortVector.zero(SPECIES);
7000         assert(av.species().elementSize() == Short.SIZE);
7001     }
7002 
7003     @Test
7004     static void VectorTypeShortMaxVectorTestsSmokeTest() {
7005         ShortVector av = ShortVector.zero(SPECIES);
7006         assert(av.species().vectorType() == av.getClass());
7007     }
7008 
7009     @Test
7010     static void WithLanesShortMaxVectorTestsSmokeTest() {
7011         ShortVector av = ShortVector.zero(SPECIES);
7012         VectorSpecies species = av.species().withLanes(short.class);
7013         assert(species.equals(SPECIES));
7014     }
7015 
7016     @Test
7017     static void WithShapeShortMaxVectorTestsSmokeTest() {
7018         ShortVector av = ShortVector.zero(SPECIES);
7019         VectorShape vsh = av.shape();
7020         VectorSpecies species = av.species().withShape(vsh);
7021         assert(species.equals(SPECIES));
7022     }
7023 
7024     @Test
7025     static void MaskAllTrueShortMaxVectorTestsSmokeTest() {
7026         for (int ic = 0; ic < INVOC_COUNT; ic++) {
7027           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
7028         }
7029     }
7030 }