1 /*
   2  * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Short256VectorTests
  28  */
  29 
  30 // -- This file was mechanically generated: Do not edit! -- //
  31 
  32 import jdk.incubator.vector.VectorShape;
  33 import jdk.incubator.vector.VectorSpecies;
  34 import jdk.incubator.vector.VectorShuffle;
  35 import jdk.incubator.vector.VectorMask;
  36 import jdk.incubator.vector.VectorOperators;
  37 import jdk.incubator.vector.Vector;
  38 
  39 import jdk.incubator.vector.ShortVector;
  40 
  41 import org.testng.Assert;
  42 import org.testng.annotations.DataProvider;
  43 import org.testng.annotations.Test;
  44 
  45 import java.lang.Integer;
  46 import java.util.List;
  47 import java.util.Arrays;
  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class Short256VectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Short> SPECIES =
  58                 ShortVector.SPECIES_256;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62 
  63     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
  64 
  65     interface FUnOp {
  66         short apply(short a);
  67     }
  68 
  69     static void assertArraysEquals(short[] r, short[] a, FUnOp f) {
  70         int i = 0;
  71         try {
  72             for (; i < a.length; i++) {
  73                 Assert.assertEquals(r[i], f.apply(a[i]));
  74             }
  75         } catch (AssertionError e) {
  76             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  77         }
  78     }
  79 
  80     interface FUnArrayOp {
  81         short[] apply(short a);
  82     }
  83 
  84     static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) {
  85         int i = 0;
  86         try {
  87             for (; i < a.length; i += SPECIES.length()) {
  88                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
  89                   f.apply(a[i]));
  90             }
  91         } catch (AssertionError e) {
  92             short[] ref = f.apply(a[i]);
  93             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
  94             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
  95               + ", res: " + Arrays.toString(res)
  96               + "), at index #" + i);
  97         }
  98     }
  99 
 100     static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) {
 101         int i = 0;
 102         try {
 103             for (; i < a.length; i++) {
 104                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 105             }
 106         } catch (AssertionError e) {
 107             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()]);
 108         }
 109     }
 110 
 111     interface FReductionOp {
 112         short apply(short[] a, int idx);
 113     }
 114 
 115     interface FReductionAllOp {
 116         short apply(short[] a);
 117     }
 118 
 119     static void assertReductionArraysEquals(short[] r, short rc, short[] a,
 120                                             FReductionOp f, FReductionAllOp fa) {
 121         int i = 0;
 122         try {
 123             Assert.assertEquals(rc, fa.apply(a));
 124             for (; i < a.length; i += SPECIES.length()) {
 125                 Assert.assertEquals(r[i], f.apply(a, i));
 126             }
 127         } catch (AssertionError e) {
 128             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 129             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 130         }
 131     }
 132 
 133     interface FReductionMaskedOp {
 134         short apply(short[] a, int idx, boolean[] mask);
 135     }
 136 
 137     interface FReductionAllMaskedOp {
 138         short apply(short[] a, boolean[] mask);
 139     }
 140 
 141     static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask,
 142                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 143         int i = 0;
 144         try {
 145             Assert.assertEquals(rc, fa.apply(a, mask));
 146             for (; i < a.length; i += SPECIES.length()) {
 147                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 148             }
 149         } catch (AssertionError e) {
 150             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 151             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 152         }
 153     }
 154 
 155     interface FReductionOpLong {
 156         long apply(short[] a, int idx);
 157     }
 158 
 159     interface FReductionAllOpLong {
 160         long apply(short[] a);
 161     }
 162 
 163     static void assertReductionLongArraysEquals(long[] r, long rc, short[] a,
 164                                             FReductionOpLong f, FReductionAllOpLong fa) {
 165         int i = 0;
 166         try {
 167             Assert.assertEquals(rc, fa.apply(a));
 168             for (; i < a.length; i += SPECIES.length()) {
 169                 Assert.assertEquals(r[i], f.apply(a, i));
 170             }
 171         } catch (AssertionError e) {
 172             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 173             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 174         }
 175     }
 176 
 177     interface FReductionMaskedOpLong {
 178         long apply(short[] a, int idx, boolean[] mask);
 179     }
 180 
 181     interface FReductionAllMaskedOpLong {
 182         long apply(short[] a, boolean[] mask);
 183     }
 184 
 185     static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask,
 186                                             FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {
 187         int i = 0;
 188         try {
 189             Assert.assertEquals(rc, fa.apply(a, mask));
 190             for (; i < a.length; i += SPECIES.length()) {
 191                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 192             }
 193         } catch (AssertionError e) {
 194             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 195             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 196         }
 197     }
 198 
 199     interface FBoolReductionOp {
 200         boolean apply(boolean[] a, int idx);
 201     }
 202 
 203     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 204         int i = 0;
 205         try {
 206             for (; i < a.length; i += SPECIES.length()) {
 207                 Assert.assertEquals(r[i], f.apply(a, i));
 208             }
 209         } catch (AssertionError e) {
 210             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 211         }
 212     }
 213 
 214     interface FMaskReductionOp {
 215         int apply(boolean[] a, int idx);
 216     }
 217 
 218     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 219         int i = 0;
 220         try {
 221             for (; i < a.length; i += SPECIES.length()) {
 222                 Assert.assertEquals(r[i], f.apply(a, i));
 223             }
 224         } catch (AssertionError e) {
 225             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 226         }
 227     }
 228 
 229     static void assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
 230         int i = 0;
 231         try {
 232             for (; i < a.length; i += 1) {
 233                 if(i%SPECIES.length() == index) {
 234                     Assert.assertEquals(r[i], element);
 235                 } else {
 236                     Assert.assertEquals(r[i], a[i]);
 237                 }
 238             }
 239         } catch (AssertionError e) {
 240             if (i%SPECIES.length() == index) {
 241                 Assert.assertEquals(r[i], element, "at index #" + i);
 242             } else {
 243                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 244             }
 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 assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
 312         int i = 0, j = 0;
 313         try {
 314             for (; i < a.length; i += vector_len) {
 315                 for (j = 0; j < vector_len; j++) {
 316                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 317                 }
 318             }
 319         } catch (AssertionError e) {
 320             int idx = i + j;
 321             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 322         }
 323     }
 324 
 325     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) {
 326         int i = 0, j = 0;
 327         try {
 328             for (; i < a.length; i += vector_len) {
 329                 for (j = 0; j < vector_len; j++) {
 330                     if (mask[j % SPECIES.length()])
 331                          Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 332                     else
 333                          Assert.assertEquals(r[i+j], (short)0);
 334                 }
 335             }
 336         } catch (AssertionError e) {
 337             int idx = i + j;
 338             if (mask[j % SPECIES.length()])
 339                 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 340             else
 341                 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 342         }
 343     }
 344 
 345     static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) {
 346         int i = 0, j = 0;
 347         try {
 348             for (; i < a.length; i += vector_len) {
 349                 for (j = 0; j < vector_len; j++) {
 350                     if (mask[j % SPECIES.length()])
 351                          Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 352                     else
 353                          Assert.assertEquals(r[i+j], (short)0);
 354                 }
 355             }
 356         } catch (AssertionError e) {
 357             int idx = i + j;
 358             if (mask[j % SPECIES.length()])
 359                 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()]);
 360             else
 361                 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 362         }
 363     }
 364 
 365     static void assertBroadcastArraysEquals(short[] r, short[] a) {
 366         int i = 0;
 367         for (; i < a.length; i += SPECIES.length()) {
 368             int idx = i;
 369             for (int j = idx; j < (idx + SPECIES.length()); j++)
 370                 a[j]=a[idx];
 371         }
 372 
 373         try {
 374             for (i = 0; i < a.length; i++) {
 375                 Assert.assertEquals(r[i], a[i]);
 376             }
 377         } catch (AssertionError e) {
 378             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 379         }
 380     }
 381 
 382     interface FBinOp {
 383         short apply(short a, short b);
 384     }
 385 
 386     interface FBinMaskOp {
 387         short apply(short a, short b, boolean m);
 388 
 389         static FBinMaskOp lift(FBinOp f) {
 390             return (a, b, m) -> m ? f.apply(a, b) : a;
 391         }
 392     }
 393 
 394     static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 395         int i = 0;
 396         try {
 397             for (; i < a.length; i++) {
 398                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 399             }
 400         } catch (AssertionError e) {
 401             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 402         }
 403     }
 404 
 405     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 406         int i = 0;
 407         try {
 408             for (; i < a.length; i++) {
 409                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 410             }
 411         } catch (AssertionError e) {
 412             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 413                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 414         }
 415     }
 416 
 417     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 418         int i = 0;
 419         try {
 420             for (; i < a.length; i++) {
 421                 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 422             }
 423         } catch (AssertionError e) {
 424             Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
 425                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 426         }
 427     }
 428 
 429     static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 430         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 431     }
 432 
 433     static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 434         int i = 0;
 435         try {
 436             for (; i < a.length; i++) {
 437                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 438             }
 439         } catch (AssertionError err) {
 440             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()]);
 441         }
 442     }
 443 
 444     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 445         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 446     }
 447 
 448     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 449         int i = 0;
 450         try {
 451             for (; i < a.length; i++) {
 452                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 453             }
 454         } catch (AssertionError err) {
 455             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 456                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 457                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 458                                 mask[i % SPECIES.length()]);
 459         }
 460     }
 461 
 462     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 463         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 464     }
 465 
 466     static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 467         int i = 0;
 468         try {
 469             for (; i < a.length; i++) {
 470                 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
 471             }
 472         } catch (AssertionError err) {
 473             Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
 474                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 475                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 476                                 mask[i % SPECIES.length()]);
 477         }
 478     }
 479 
 480     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
 481         int i = 0;
 482         int j = 0;
 483         try {
 484             for (; j < a.length; j += SPECIES.length()) {
 485                 for (i = 0; i < SPECIES.length(); i++) {
 486                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 487                 }
 488             }
 489         } catch (AssertionError e) {
 490             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 491         }
 492     }
 493 
 494     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
 495         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 496     }
 497 
 498     static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
 499         int i = 0;
 500         int j = 0;
 501         try {
 502             for (; j < a.length; j += SPECIES.length()) {
 503                 for (i = 0; i < SPECIES.length(); i++) {
 504                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 505                 }
 506             }
 507         } catch (AssertionError err) {
 508             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]);
 509         }
 510     }
 511 
 512     interface FTernOp {
 513         short apply(short a, short b, short c);
 514     }
 515 
 516     interface FTernMaskOp {
 517         short apply(short a, short b, short c, boolean m);
 518 
 519         static FTernMaskOp lift(FTernOp f) {
 520             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 521         }
 522     }
 523 
 524     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 525         int i = 0;
 526         try {
 527             for (; i < a.length; i++) {
 528                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 529             }
 530         } catch (AssertionError e) {
 531             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 532         }
 533     }
 534 
 535     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) {
 536         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 537     }
 538 
 539     static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) {
 540         int i = 0;
 541         try {
 542             for (; i < a.length; i++) {
 543                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 544             }
 545         } catch (AssertionError err) {
 546             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 547               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 548         }
 549     }
 550 
 551     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 552         int i = 0;
 553         try {
 554             for (; i < a.length; i++) {
 555                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
 556             }
 557         } catch (AssertionError e) {
 558             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
 559                                 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
 560                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 561         }
 562     }
 563 
 564     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 565         int i = 0;
 566         try {
 567             for (; i < a.length; i++) {
 568                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
 569             }
 570         } catch (AssertionError e) {
 571             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
 572                                 i + ", input1 = " + a[i] + ", input2 = " +
 573                                 b[(i / SPECIES.length()) * SPECIES.length()] + ",  input3 = " + c[i]);
 574         }
 575     }
 576 
 577     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 578                                             FTernOp f) {
 579         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 580     }
 581 
 582     static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 583                                             FTernMaskOp f) {
 584         int i = 0;
 585         try {
 586             for (; i < a.length; i++) {
 587                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 588                                     mask[i % SPECIES.length()]));
 589             }
 590         } catch (AssertionError err) {
 591             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 592                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 593                                 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 594                                 mask[i % SPECIES.length()]);
 595         }
 596     }
 597 
 598     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 599                                             FTernOp f) {
 600         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 601     }
 602 
 603     static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 604                                             FTernMaskOp f) {
 605         int i = 0;
 606         try {
 607             for (; i < a.length; i++) {
 608                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 609                                     mask[i % SPECIES.length()]));
 610             }
 611         } catch (AssertionError err) {
 612             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 613                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 614                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 615                                 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 616         }
 617     }
 618 
 619     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
 620         int i = 0;
 621         try {
 622             for (; i < a.length; i++) {
 623                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 624                                     c[(i / SPECIES.length()) * SPECIES.length()]));
 625             }
 626         } catch (AssertionError e) {
 627             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 628                                 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
 629                                 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
 630                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 631         }
 632     }
 633 
 634     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 635                                                   FTernOp f) {
 636         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 637     }
 638 
 639     static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
 640                                                   FTernMaskOp f) {
 641         int i = 0;
 642         try {
 643             for (; i < a.length; i++) {
 644                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 645                                     c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 646             }
 647         } catch (AssertionError err) {
 648             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 649                                 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
 650                                 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 651                                 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 652                                 mask[i % SPECIES.length()]);
 653         }
 654     }
 655 
 656 
 657 
 658     interface FBinArrayOp {
 659         short apply(short[] a, int b);
 660     }
 661 
 662     static void assertArraysEquals(short[] r, short[] a, FBinArrayOp f) {
 663         int i = 0;
 664         try {
 665             for (; i < a.length; i++) {
 666                 Assert.assertEquals(r[i], f.apply(a, i));
 667             }
 668         } catch (AssertionError e) {
 669             Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);
 670         }
 671     }
 672 
 673     interface FGatherScatterOp {
 674         short[] apply(short[] a, int ix, int[] b, int iy);
 675     }
 676 
 677     static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) {
 678         int i = 0;
 679         try {
 680             for (; i < a.length; i += SPECIES.length()) {
 681                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 682                   f.apply(a, i, b, i));
 683             }
 684         } catch (AssertionError e) {
 685             short[] ref = f.apply(a, i, b, i);
 686             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 687             Assert.assertEquals(res, ref,
 688               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 689               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 690               + ", b: "
 691               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 692               + " at index #" + i);
 693         }
 694     }
 695 
 696     interface FGatherMaskedOp {
 697         short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy);
 698     }
 699 
 700     interface FScatterMaskedOp {
 701         short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy);
 702     }
 703 
 704     static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
 705         int i = 0;
 706         try {
 707             for (; i < a.length; i += SPECIES.length()) {
 708                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 709                   f.apply(a, i, mask, b, i));
 710             }
 711         } catch (AssertionError e) {
 712             short[] ref = f.apply(a, i, mask, b, i);
 713             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 714             Assert.assertEquals(res, ref,
 715               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 716               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 717               + ", b: "
 718               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 719               + ", mask: "
 720               + Arrays.toString(mask)
 721               + " at index #" + i);
 722         }
 723     }
 724 
 725     static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
 726         int i = 0;
 727         try {
 728             for (; i < a.length; i += SPECIES.length()) {
 729                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 730                   f.apply(r, a, i, mask, b, i));
 731             }
 732         } catch (AssertionError e) {
 733             short[] ref = f.apply(r, a, i, mask, b, i);
 734             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 735             Assert.assertEquals(res, ref,
 736               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 737               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 738               + ", b: "
 739               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 740               + ", r: "
 741               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 742               + ", mask: "
 743               + Arrays.toString(mask)
 744               + " at index #" + i);
 745         }
 746     }
 747 
 748     interface FLaneOp {
 749         short[] apply(short[] a, int origin, int idx);
 750     }
 751 
 752     static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) {
 753         int i = 0;
 754         try {
 755             for (; i < a.length; i += SPECIES.length()) {
 756                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 757                   f.apply(a, origin, i));
 758             }
 759         } catch (AssertionError e) {
 760             short[] ref = f.apply(a, origin, i);
 761             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 762             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 763               + ", res: " + Arrays.toString(res)
 764               + "), at index #" + i);
 765         }
 766     }
 767 
 768     interface FLaneBop {
 769         short[] apply(short[] a, short[] b, int origin, int idx);
 770     }
 771 
 772     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) {
 773         int i = 0;
 774         try {
 775             for (; i < a.length; i += SPECIES.length()) {
 776                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 777                   f.apply(a, b, origin, i));
 778             }
 779         } catch (AssertionError e) {
 780             short[] ref = f.apply(a, b, origin, i);
 781             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 782             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 783               + ", res: " + Arrays.toString(res)
 784               + "), at index #" + i
 785               + ", at origin #" + origin);
 786         }
 787     }
 788 
 789     interface FLaneMaskedBop {
 790         short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx);
 791     }
 792 
 793     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
 794         int i = 0;
 795         try {
 796             for (; i < a.length; i += SPECIES.length()) {
 797                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 798                   f.apply(a, b, origin, mask, i));
 799             }
 800         } catch (AssertionError e) {
 801             short[] ref = f.apply(a, b, origin, mask, i);
 802             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 803             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 804               + ", res: " + Arrays.toString(res)
 805               + "), at index #" + i
 806               + ", at origin #" + origin);
 807         }
 808     }
 809 
 810     interface FLanePartBop {
 811         short[] apply(short[] a, short[] b, int origin, int part, int idx);
 812     }
 813 
 814     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) {
 815         int i = 0;
 816         try {
 817             for (; i < a.length; i += SPECIES.length()) {
 818                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 819                   f.apply(a, b, origin, part, i));
 820             }
 821         } catch (AssertionError e) {
 822             short[] ref = f.apply(a, b, origin, part, i);
 823             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 824             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 825               + ", res: " + Arrays.toString(res)
 826               + "), at index #" + i
 827               + ", at origin #" + origin
 828               + ", with part #" + part);
 829         }
 830     }
 831 
 832     interface FLanePartMaskedBop {
 833         short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx);
 834     }
 835 
 836     static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 837         int i = 0;
 838         try {
 839             for (; i < a.length; i += SPECIES.length()) {
 840                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 841                   f.apply(a, b, origin, part, mask, i));
 842             }
 843         } catch (AssertionError e) {
 844             short[] ref = f.apply(a, b, origin, part, mask, i);
 845             short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 846             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 847               + ", res: " + Arrays.toString(res)
 848               + "), at index #" + i
 849               + ", at origin #" + origin
 850               + ", with part #" + part);
 851         }
 852     }
 853 
 854 
 855     static void assertArraysEquals(int[] r, short[] a, int offs) {
 856         int i = 0;
 857         try {
 858             for (; i < r.length; i++) {
 859                 Assert.assertEquals(r[i], (int)(a[i+offs]));
 860             }
 861         } catch (AssertionError e) {
 862             Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 863         }
 864     }
 865 
 866 
 867 
 868     static void assertArraysEquals(long[] r, short[] a, int offs) {
 869         int i = 0;
 870         try {
 871             for (; i < r.length; i++) {
 872                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 873             }
 874         } catch (AssertionError e) {
 875             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 876         }
 877     }
 878 
 879     static void assertArraysEquals(double[] r, short[] a, int offs) {
 880         int i = 0;
 881         try {
 882             for (; i < r.length; i++) {
 883                 Assert.assertEquals(r[i], (double)(a[i+offs]));
 884             }
 885         } catch (AssertionError e) {
 886             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 887         }
 888     }
 889 
 890 
 891     static short bits(short e) {
 892         return  e;
 893     }
 894 
 895     static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
 896             withToString("short[-i * 5]", (int s) -> {
 897                 return fill(s * BUFFER_REPS,
 898                             i -> (short)(-i * 5));
 899             }),
 900             withToString("short[i * 5]", (int s) -> {
 901                 return fill(s * BUFFER_REPS,
 902                             i -> (short)(i * 5));
 903             }),
 904             withToString("short[i + 1]", (int s) -> {
 905                 return fill(s * BUFFER_REPS,
 906                             i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1)));
 907             }),
 908             withToString("short[cornerCaseValue(i)]", (int s) -> {
 909                 return fill(s * BUFFER_REPS,
 910                             i -> cornerCaseValue(i));
 911             })
 912     );
 913 
 914     // Create combinations of pairs
 915     // @@@ Might be sensitive to order e.g. div by 0
 916     static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_PAIRS =
 917         Stream.of(SHORT_GENERATORS.get(0)).
 918                 flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 919                 collect(Collectors.toList());
 920 
 921     @DataProvider
 922     public Object[][] boolUnaryOpProvider() {
 923         return BOOL_ARRAY_GENERATORS.stream().
 924                 map(f -> new Object[]{f}).
 925                 toArray(Object[][]::new);
 926     }
 927 
 928     static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_TRIPLES =
 929         SHORT_GENERATOR_PAIRS.stream().
 930                 flatMap(pair -> SHORT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 931                 collect(Collectors.toList());
 932 
 933     @DataProvider
 934     public Object[][] shortBinaryOpProvider() {
 935         return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
 936                 toArray(Object[][]::new);
 937     }
 938 
 939     @DataProvider
 940     public Object[][] shortIndexedOpProvider() {
 941         return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
 942                 toArray(Object[][]::new);
 943     }
 944 
 945     @DataProvider
 946     public Object[][] shortBinaryOpMaskProvider() {
 947         return BOOLEAN_MASK_GENERATORS.stream().
 948                 flatMap(fm -> SHORT_GENERATOR_PAIRS.stream().map(lfa -> {
 949                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 950                 })).
 951                 toArray(Object[][]::new);
 952     }
 953 
 954     @DataProvider
 955     public Object[][] shortTernaryOpProvider() {
 956         return SHORT_GENERATOR_TRIPLES.stream().map(List::toArray).
 957                 toArray(Object[][]::new);
 958     }
 959 
 960     @DataProvider
 961     public Object[][] shortTernaryOpMaskProvider() {
 962         return BOOLEAN_MASK_GENERATORS.stream().
 963                 flatMap(fm -> SHORT_GENERATOR_TRIPLES.stream().map(lfa -> {
 964                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 965                 })).
 966                 toArray(Object[][]::new);
 967     }
 968 
 969     @DataProvider
 970     public Object[][] shortUnaryOpProvider() {
 971         return SHORT_GENERATORS.stream().
 972                 map(f -> new Object[]{f}).
 973                 toArray(Object[][]::new);
 974     }
 975 
 976     @DataProvider
 977     public Object[][] shortUnaryOpMaskProvider() {
 978         return BOOLEAN_MASK_GENERATORS.stream().
 979                 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> {
 980                     return new Object[] {fa, fm};
 981                 })).
 982                 toArray(Object[][]::new);
 983     }
 984 
 985 
 986 
 987     @DataProvider
 988     public Object[][] maskProvider() {
 989         return BOOLEAN_MASK_GENERATORS.stream().
 990                 map(f -> new Object[]{f}).
 991                 toArray(Object[][]::new);
 992     }
 993 
 994     @DataProvider
 995     public Object[][] maskCompareOpProvider() {
 996         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 997                 toArray(Object[][]::new);
 998     }
 999 
1000     @DataProvider
1001     public Object[][] shuffleProvider() {
1002         return INT_SHUFFLE_GENERATORS.stream().
1003                 map(f -> new Object[]{f}).
1004                 toArray(Object[][]::new);
1005     }
1006 
1007     @DataProvider
1008     public Object[][] shuffleCompareOpProvider() {
1009         return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1010                 toArray(Object[][]::new);
1011     }
1012 
1013     @DataProvider
1014     public Object[][] shortUnaryOpShuffleProvider() {
1015         return INT_SHUFFLE_GENERATORS.stream().
1016                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1017                     return new Object[] {fa, fs};
1018                 })).
1019                 toArray(Object[][]::new);
1020     }
1021 
1022     @DataProvider
1023     public Object[][] shortUnaryOpShuffleMaskProvider() {
1024         return BOOLEAN_MASK_GENERATORS.stream().
1025                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1026                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1027                         return new Object[] {fa, fs, fm};
1028                 }))).
1029                 toArray(Object[][]::new);
1030     }
1031 
1032     static final List<BiFunction<Integer,Integer,short[]>> SHORT_SHUFFLE_GENERATORS = List.of(
1033             withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1034                 short[] a = new short[l];
1035                 int upper = m;
1036                 for (int i = 0; i < 1; i++) {
1037                     a[i] = (short)RAND.nextInt(upper);
1038                 }
1039                 return a;
1040             })
1041     );
1042 
1043     @DataProvider
1044     public Object[][] shortUnaryOpSelectFromProvider() {
1045         return SHORT_SHUFFLE_GENERATORS.stream().
1046                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1047                     return new Object[] {fa, fs};
1048                 })).
1049                 toArray(Object[][]::new);
1050     }
1051 
1052     @DataProvider
1053     public Object[][] shortUnaryOpSelectFromMaskProvider() {
1054         return BOOLEAN_MASK_GENERATORS.stream().
1055                 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream().
1056                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1057                         return new Object[] {fa, fs, fm};
1058                 }))).
1059                 toArray(Object[][]::new);
1060     }
1061 
1062 
1063     static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
1064             withToString("short[i]", (int s) -> {
1065                 return fill(s * BUFFER_REPS,
1066                             i -> (short)i);
1067             }),
1068             withToString("short[i - length / 2]", (int s) -> {
1069                 return fill(s * BUFFER_REPS,
1070                             i -> (short)(i - (s * BUFFER_REPS / 2)));
1071             }),
1072             withToString("short[i + 1]", (int s) -> {
1073                 return fill(s * BUFFER_REPS,
1074                             i -> (short)(i + 1));
1075             }),
1076             withToString("short[i - 2]", (int s) -> {
1077                 return fill(s * BUFFER_REPS,
1078                             i -> (short)(i - 2));
1079             }),
1080             withToString("short[zigZag(i)]", (int s) -> {
1081                 return fill(s * BUFFER_REPS,
1082                             i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2)));
1083             }),
1084             withToString("short[cornerCaseValue(i)]", (int s) -> {
1085                 return fill(s * BUFFER_REPS,
1086                             i -> cornerCaseValue(i));
1087             })
1088     );
1089 
1090     static final List<List<IntFunction<short[]>>> SHORT_TEST_GENERATOR_ARGS =
1091         SHORT_COMPARE_GENERATORS.stream().
1092                 map(fa -> List.of(fa)).
1093                 collect(Collectors.toList());
1094 
1095     @DataProvider
1096     public Object[][] shortTestOpProvider() {
1097         return SHORT_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1098                 toArray(Object[][]::new);
1099     }
1100 
1101     @DataProvider
1102     public Object[][] shortTestOpMaskProvider() {
1103         return BOOLEAN_MASK_GENERATORS.stream().
1104                 flatMap(fm -> SHORT_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1105                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1106                 })).
1107                 toArray(Object[][]::new);
1108     }
1109 
1110     static final List<List<IntFunction<short[]>>> SHORT_COMPARE_GENERATOR_PAIRS =
1111         SHORT_COMPARE_GENERATORS.stream().
1112                 flatMap(fa -> SHORT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1113                 collect(Collectors.toList());
1114 
1115     @DataProvider
1116     public Object[][] shortCompareOpProvider() {
1117         return SHORT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1118                 toArray(Object[][]::new);
1119     }
1120 
1121     @DataProvider
1122     public Object[][] shortCompareOpMaskProvider() {
1123         return BOOLEAN_MASK_GENERATORS.stream().
1124                 flatMap(fm -> SHORT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1125                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1126                 })).
1127                 toArray(Object[][]::new);
1128     }
1129 
1130     interface ToShortF {
1131         short apply(int i);
1132     }
1133 
1134     static short[] fill(int s , ToShortF f) {
1135         return fill(new short[s], f);
1136     }
1137 
1138     static short[] fill(short[] a, ToShortF f) {
1139         for (int i = 0; i < a.length; i++) {
1140             a[i] = f.apply(i);
1141         }
1142         return a;
1143     }
1144 
1145     static short cornerCaseValue(int i) {
1146         switch(i % 5) {
1147             case 0:
1148                 return Short.MAX_VALUE;
1149             case 1:
1150                 return Short.MIN_VALUE;
1151             case 2:
1152                 return Short.MIN_VALUE;
1153             case 3:
1154                 return Short.MAX_VALUE;
1155             default:
1156                 return (short)0;
1157         }
1158     }
1159 
1160     static short get(short[] a, int i) {
1161         return (short) a[i];
1162     }
1163 
1164     static final IntFunction<short[]> fr = (vl) -> {
1165         int length = BUFFER_REPS * vl;
1166         return new short[length];
1167     };
1168 
1169     static final IntFunction<boolean[]> fmr = (vl) -> {
1170         int length = BUFFER_REPS * vl;
1171         return new boolean[length];
1172     };
1173 
1174     static final IntFunction<long[]> lfr = (vl) -> {
1175         int length = BUFFER_REPS * vl;
1176         return new long[length];
1177     };
1178 
1179     static void replaceZero(short[] a, short v) {
1180         for (int i = 0; i < a.length; i++) {
1181             if (a[i] == 0) {
1182                 a[i] = v;
1183             }
1184         }
1185     }
1186 
1187     static void replaceZero(short[] a, boolean[] mask, short v) {
1188         for (int i = 0; i < a.length; i++) {
1189             if (mask[i % mask.length] && a[i] == 0) {
1190                 a[i] = v;
1191             }
1192         }
1193     }
1194 
1195     static short ROL_scalar(short a, short b) {
1196         return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15))));
1197     }
1198 
1199     static short ROR_scalar(short a, short b) {
1200         return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
1201     }
1202 
1203     static boolean eq(short a, short b) {
1204         return a == b;
1205     }
1206 
1207     static boolean neq(short a, short b) {
1208         return a != b;
1209     }
1210 
1211     static boolean lt(short a, short b) {
1212         return a < b;
1213     }
1214 
1215     static boolean le(short a, short b) {
1216         return a <= b;
1217     }
1218 
1219     static boolean gt(short a, short b) {
1220         return a > b;
1221     }
1222 
1223     static boolean ge(short a, short b) {
1224         return a >= b;
1225     }
1226 
1227     static boolean ult(short a, short b) {
1228         return Short.compareUnsigned(a, b) < 0;
1229     }
1230 
1231     static boolean ule(short a, short b) {
1232         return Short.compareUnsigned(a, b) <= 0;
1233     }
1234 
1235     static boolean ugt(short a, short b) {
1236         return Short.compareUnsigned(a, b) > 0;
1237     }
1238 
1239     static boolean uge(short a, short b) {
1240         return Short.compareUnsigned(a, b) >= 0;
1241     }
1242 
1243     @Test
1244     static void smokeTest1() {
1245         ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3);
1246         ShortVector three2 = (ShortVector) SPECIES.broadcast(-3);
1247         assert(three.eq(three2).allTrue());
1248         ShortVector three3 = three2.broadcast(1).broadcast(-3);
1249         assert(three.eq(three3).allTrue());
1250         int scale = 2;
1251         Class<?> ETYPE = short.class;
1252         if (ETYPE == double.class || ETYPE == long.class)
1253             scale = 1000000;
1254         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1255             scale = 1;
1256         ShortVector higher = three.addIndex(scale);
1257         VectorMask<Short> m = three.compare(VectorOperators.LE, higher);
1258         assert(m.allTrue());
1259         m = higher.min((short)-1).test(VectorOperators.IS_NEGATIVE);
1260         assert(m.allTrue());
1261         short max = higher.reduceLanes(VectorOperators.MAX);
1262         assert(max == -3 + scale * (SPECIES.length()-1));
1263     }
1264 
1265     private static short[]
1266     bothToArray(ShortVector a, ShortVector b) {
1267         short[] r = new short[a.length() + b.length()];
1268         a.intoArray(r, 0);
1269         b.intoArray(r, a.length());
1270         return r;
1271     }
1272 
1273     @Test
1274     static void smokeTest2() {
1275         // Do some zipping and shuffling.
1276         ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1277         ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1278         Assert.assertEquals(io, io2);
1279         ShortVector a = io.add((short)1); //[1,2]
1280         ShortVector b = a.neg();  //[-1,-2]
1281         short[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1282         VectorShuffle<Short> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1283         VectorShuffle<Short> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1284         ShortVector zab0 = a.rearrange(zip0,b); //[1,-1]
1285         ShortVector zab1 = a.rearrange(zip1,b); //[2,-2]
1286         short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1287         // manually zip
1288         short[] manual = new short[zabValues.length];
1289         for (int i = 0; i < manual.length; i += 2) {
1290             manual[i+0] = abValues[i/2];
1291             manual[i+1] = abValues[a.length() + i/2];
1292         }
1293         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1294         VectorShuffle<Short> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1295         VectorShuffle<Short> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1296         ShortVector uab0 = zab0.rearrange(unz0,zab1);
1297         ShortVector uab1 = zab0.rearrange(unz1,zab1);
1298         short[] abValues1 = bothToArray(uab0, uab1);
1299         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1300     }
1301 
1302     static void iotaShuffle() {
1303         ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1304         ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1305         Assert.assertEquals(io, io2);
1306     }
1307 
1308     @Test
1309     // Test all shuffle related operations.
1310     static void shuffleTest() {
1311         // To test backend instructions, make sure that C2 is used.
1312         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1313             iotaShuffle();
1314         }
1315     }
1316 
1317     @Test
1318     void viewAsIntegeralLanesTest() {
1319         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1320         Assert.assertEquals(asIntegral.species(), SPECIES);
1321     }
1322 
1323     @Test(expectedExceptions = UnsupportedOperationException.class)
1324     void viewAsFloatingLanesTest() {
1325         SPECIES.zero().viewAsFloatingLanes();
1326     }
1327 
1328     @Test
1329     // Test div by 0.
1330     static void bitwiseDivByZeroSmokeTest() {
1331         try {
1332             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1333             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1334             a.div(b);
1335             Assert.fail();
1336         } catch (ArithmeticException e) {
1337         }
1338 
1339         try {
1340             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1341             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1342             VectorMask<Short> m = a.lt((short) 1);
1343             a.div(b, m);
1344             Assert.fail();
1345         } catch (ArithmeticException e) {
1346         }
1347     }
1348     static short ADD(short a, short b) {
1349         return (short)(a + b);
1350     }
1351 
1352     @Test(dataProvider = "shortBinaryOpProvider")
1353     static void ADDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1354         short[] a = fa.apply(SPECIES.length());
1355         short[] b = fb.apply(SPECIES.length());
1356         short[] r = fr.apply(SPECIES.length());
1357 
1358         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1359             for (int i = 0; i < a.length; i += SPECIES.length()) {
1360                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1361                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1362                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1363             }
1364         }
1365 
1366         assertArraysEquals(r, a, b, Short256VectorTests::ADD);
1367     }
1368     static short add(short a, short b) {
1369         return (short)(a + b);
1370     }
1371 
1372     @Test(dataProvider = "shortBinaryOpProvider")
1373     static void addShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1374         short[] a = fa.apply(SPECIES.length());
1375         short[] b = fb.apply(SPECIES.length());
1376         short[] r = fr.apply(SPECIES.length());
1377 
1378         for (int i = 0; i < a.length; i += SPECIES.length()) {
1379             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1380             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1381             av.add(bv).intoArray(r, i);
1382         }
1383 
1384         assertArraysEquals(r, a, b, Short256VectorTests::add);
1385     }
1386 
1387     @Test(dataProvider = "shortBinaryOpMaskProvider")
1388     static void ADDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1389                                           IntFunction<boolean[]> fm) {
1390         short[] a = fa.apply(SPECIES.length());
1391         short[] b = fb.apply(SPECIES.length());
1392         short[] r = fr.apply(SPECIES.length());
1393         boolean[] mask = fm.apply(SPECIES.length());
1394         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1395 
1396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1397             for (int i = 0; i < a.length; i += SPECIES.length()) {
1398                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1399                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1400                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1401             }
1402         }
1403 
1404         assertArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
1405     }
1406 
1407     @Test(dataProvider = "shortBinaryOpMaskProvider")
1408     static void addShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1409                                           IntFunction<boolean[]> fm) {
1410         short[] a = fa.apply(SPECIES.length());
1411         short[] b = fb.apply(SPECIES.length());
1412         short[] r = fr.apply(SPECIES.length());
1413         boolean[] mask = fm.apply(SPECIES.length());
1414         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1415 
1416         for (int i = 0; i < a.length; i += SPECIES.length()) {
1417             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1418             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1419             av.add(bv, vmask).intoArray(r, i);
1420         }
1421 
1422         assertArraysEquals(r, a, b, mask, Short256VectorTests::add);
1423     }
1424     static short SUB(short a, short b) {
1425         return (short)(a - b);
1426     }
1427 
1428     @Test(dataProvider = "shortBinaryOpProvider")
1429     static void SUBShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1430         short[] a = fa.apply(SPECIES.length());
1431         short[] b = fb.apply(SPECIES.length());
1432         short[] r = fr.apply(SPECIES.length());
1433 
1434         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1435             for (int i = 0; i < a.length; i += SPECIES.length()) {
1436                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1437                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1438                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1439             }
1440         }
1441 
1442         assertArraysEquals(r, a, b, Short256VectorTests::SUB);
1443     }
1444     static short sub(short a, short b) {
1445         return (short)(a - b);
1446     }
1447 
1448     @Test(dataProvider = "shortBinaryOpProvider")
1449     static void subShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1450         short[] a = fa.apply(SPECIES.length());
1451         short[] b = fb.apply(SPECIES.length());
1452         short[] r = fr.apply(SPECIES.length());
1453 
1454         for (int i = 0; i < a.length; i += SPECIES.length()) {
1455             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1456             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1457             av.sub(bv).intoArray(r, i);
1458         }
1459 
1460         assertArraysEquals(r, a, b, Short256VectorTests::sub);
1461     }
1462 
1463     @Test(dataProvider = "shortBinaryOpMaskProvider")
1464     static void SUBShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1465                                           IntFunction<boolean[]> fm) {
1466         short[] a = fa.apply(SPECIES.length());
1467         short[] b = fb.apply(SPECIES.length());
1468         short[] r = fr.apply(SPECIES.length());
1469         boolean[] mask = fm.apply(SPECIES.length());
1470         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1471 
1472         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1473             for (int i = 0; i < a.length; i += SPECIES.length()) {
1474                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1475                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1476                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1477             }
1478         }
1479 
1480         assertArraysEquals(r, a, b, mask, Short256VectorTests::SUB);
1481     }
1482 
1483     @Test(dataProvider = "shortBinaryOpMaskProvider")
1484     static void subShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1485                                           IntFunction<boolean[]> fm) {
1486         short[] a = fa.apply(SPECIES.length());
1487         short[] b = fb.apply(SPECIES.length());
1488         short[] r = fr.apply(SPECIES.length());
1489         boolean[] mask = fm.apply(SPECIES.length());
1490         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1491 
1492         for (int i = 0; i < a.length; i += SPECIES.length()) {
1493             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1494             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1495             av.sub(bv, vmask).intoArray(r, i);
1496         }
1497 
1498         assertArraysEquals(r, a, b, mask, Short256VectorTests::sub);
1499     }
1500     static short MUL(short a, short b) {
1501         return (short)(a * b);
1502     }
1503 
1504     @Test(dataProvider = "shortBinaryOpProvider")
1505     static void MULShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1506         short[] a = fa.apply(SPECIES.length());
1507         short[] b = fb.apply(SPECIES.length());
1508         short[] r = fr.apply(SPECIES.length());
1509 
1510         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1511             for (int i = 0; i < a.length; i += SPECIES.length()) {
1512                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1513                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1514                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1515             }
1516         }
1517 
1518         assertArraysEquals(r, a, b, Short256VectorTests::MUL);
1519     }
1520     static short mul(short a, short b) {
1521         return (short)(a * b);
1522     }
1523 
1524     @Test(dataProvider = "shortBinaryOpProvider")
1525     static void mulShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1526         short[] a = fa.apply(SPECIES.length());
1527         short[] b = fb.apply(SPECIES.length());
1528         short[] r = fr.apply(SPECIES.length());
1529 
1530         for (int i = 0; i < a.length; i += SPECIES.length()) {
1531             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1532             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1533             av.mul(bv).intoArray(r, i);
1534         }
1535 
1536         assertArraysEquals(r, a, b, Short256VectorTests::mul);
1537     }
1538 
1539     @Test(dataProvider = "shortBinaryOpMaskProvider")
1540     static void MULShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1541                                           IntFunction<boolean[]> fm) {
1542         short[] a = fa.apply(SPECIES.length());
1543         short[] b = fb.apply(SPECIES.length());
1544         short[] r = fr.apply(SPECIES.length());
1545         boolean[] mask = fm.apply(SPECIES.length());
1546         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1547 
1548         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1549             for (int i = 0; i < a.length; i += SPECIES.length()) {
1550                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1551                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1552                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1553             }
1554         }
1555 
1556         assertArraysEquals(r, a, b, mask, Short256VectorTests::MUL);
1557     }
1558 
1559     @Test(dataProvider = "shortBinaryOpMaskProvider")
1560     static void mulShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1561                                           IntFunction<boolean[]> fm) {
1562         short[] a = fa.apply(SPECIES.length());
1563         short[] b = fb.apply(SPECIES.length());
1564         short[] r = fr.apply(SPECIES.length());
1565         boolean[] mask = fm.apply(SPECIES.length());
1566         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1567 
1568         for (int i = 0; i < a.length; i += SPECIES.length()) {
1569             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1570             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1571             av.mul(bv, vmask).intoArray(r, i);
1572         }
1573 
1574         assertArraysEquals(r, a, b, mask, Short256VectorTests::mul);
1575     }
1576 
1577 
1578 
1579     static short DIV(short a, short b) {
1580         return (short)(a / b);
1581     }
1582 
1583     @Test(dataProvider = "shortBinaryOpProvider")
1584     static void DIVShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1585         short[] a = fa.apply(SPECIES.length());
1586         short[] b = fb.apply(SPECIES.length());
1587         short[] r = fr.apply(SPECIES.length());
1588 
1589         replaceZero(b, (short) 1);
1590 
1591         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1592             for (int i = 0; i < a.length; i += SPECIES.length()) {
1593                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1594                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1595                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1596             }
1597         }
1598 
1599         assertArraysEquals(r, a, b, Short256VectorTests::DIV);
1600     }
1601     static short div(short a, short b) {
1602         return (short)(a / b);
1603     }
1604 
1605     @Test(dataProvider = "shortBinaryOpProvider")
1606     static void divShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1607         short[] a = fa.apply(SPECIES.length());
1608         short[] b = fb.apply(SPECIES.length());
1609         short[] r = fr.apply(SPECIES.length());
1610 
1611         replaceZero(b, (short) 1);
1612 
1613         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1614             for (int i = 0; i < a.length; i += SPECIES.length()) {
1615                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1616                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1617                 av.div(bv).intoArray(r, i);
1618             }
1619         }
1620 
1621         assertArraysEquals(r, a, b, Short256VectorTests::div);
1622     }
1623 
1624 
1625 
1626     @Test(dataProvider = "shortBinaryOpMaskProvider")
1627     static void DIVShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1628                                           IntFunction<boolean[]> fm) {
1629         short[] a = fa.apply(SPECIES.length());
1630         short[] b = fb.apply(SPECIES.length());
1631         short[] r = fr.apply(SPECIES.length());
1632         boolean[] mask = fm.apply(SPECIES.length());
1633         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1634 
1635         replaceZero(b, mask, (short) 1);
1636 
1637         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1638             for (int i = 0; i < a.length; i += SPECIES.length()) {
1639                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1640                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1641                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1642             }
1643         }
1644 
1645         assertArraysEquals(r, a, b, mask, Short256VectorTests::DIV);
1646     }
1647 
1648     @Test(dataProvider = "shortBinaryOpMaskProvider")
1649     static void divShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1650                                           IntFunction<boolean[]> fm) {
1651         short[] a = fa.apply(SPECIES.length());
1652         short[] b = fb.apply(SPECIES.length());
1653         short[] r = fr.apply(SPECIES.length());
1654         boolean[] mask = fm.apply(SPECIES.length());
1655         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1656 
1657         replaceZero(b, mask, (short) 1);
1658 
1659         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1660             for (int i = 0; i < a.length; i += SPECIES.length()) {
1661                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1662                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1663                 av.div(bv, vmask).intoArray(r, i);
1664             }
1665         }
1666 
1667         assertArraysEquals(r, a, b, mask, Short256VectorTests::div);
1668     }
1669 
1670     static short FIRST_NONZERO(short a, short b) {
1671         return (short)((a)!=0?a:b);
1672     }
1673 
1674     @Test(dataProvider = "shortBinaryOpProvider")
1675     static void FIRST_NONZEROShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1676         short[] a = fa.apply(SPECIES.length());
1677         short[] b = fb.apply(SPECIES.length());
1678         short[] r = fr.apply(SPECIES.length());
1679 
1680         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1681             for (int i = 0; i < a.length; i += SPECIES.length()) {
1682                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1683                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1684                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1685             }
1686         }
1687 
1688         assertArraysEquals(r, a, b, Short256VectorTests::FIRST_NONZERO);
1689     }
1690 
1691     @Test(dataProvider = "shortBinaryOpMaskProvider")
1692     static void FIRST_NONZEROShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1693                                           IntFunction<boolean[]> fm) {
1694         short[] a = fa.apply(SPECIES.length());
1695         short[] b = fb.apply(SPECIES.length());
1696         short[] r = fr.apply(SPECIES.length());
1697         boolean[] mask = fm.apply(SPECIES.length());
1698         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1699 
1700         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1701             for (int i = 0; i < a.length; i += SPECIES.length()) {
1702                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1703                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1704                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1705             }
1706         }
1707 
1708         assertArraysEquals(r, a, b, mask, Short256VectorTests::FIRST_NONZERO);
1709     }
1710 
1711     static short AND(short a, short b) {
1712         return (short)(a & b);
1713     }
1714 
1715     @Test(dataProvider = "shortBinaryOpProvider")
1716     static void ANDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1717         short[] a = fa.apply(SPECIES.length());
1718         short[] b = fb.apply(SPECIES.length());
1719         short[] r = fr.apply(SPECIES.length());
1720 
1721         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1722             for (int i = 0; i < a.length; i += SPECIES.length()) {
1723                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1724                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1725                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1726             }
1727         }
1728 
1729         assertArraysEquals(r, a, b, Short256VectorTests::AND);
1730     }
1731     static short and(short a, short b) {
1732         return (short)(a & b);
1733     }
1734 
1735     @Test(dataProvider = "shortBinaryOpProvider")
1736     static void andShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1737         short[] a = fa.apply(SPECIES.length());
1738         short[] b = fb.apply(SPECIES.length());
1739         short[] r = fr.apply(SPECIES.length());
1740 
1741         for (int i = 0; i < a.length; i += SPECIES.length()) {
1742             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1743             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1744             av.and(bv).intoArray(r, i);
1745         }
1746 
1747         assertArraysEquals(r, a, b, Short256VectorTests::and);
1748     }
1749 
1750 
1751 
1752     @Test(dataProvider = "shortBinaryOpMaskProvider")
1753     static void ANDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1754                                           IntFunction<boolean[]> fm) {
1755         short[] a = fa.apply(SPECIES.length());
1756         short[] b = fb.apply(SPECIES.length());
1757         short[] r = fr.apply(SPECIES.length());
1758         boolean[] mask = fm.apply(SPECIES.length());
1759         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1760 
1761         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1762             for (int i = 0; i < a.length; i += SPECIES.length()) {
1763                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1764                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1765                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1766             }
1767         }
1768 
1769         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND);
1770     }
1771 
1772 
1773     static short AND_NOT(short a, short b) {
1774         return (short)(a & ~b);
1775     }
1776 
1777     @Test(dataProvider = "shortBinaryOpProvider")
1778     static void AND_NOTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1779         short[] a = fa.apply(SPECIES.length());
1780         short[] b = fb.apply(SPECIES.length());
1781         short[] r = fr.apply(SPECIES.length());
1782 
1783         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1784             for (int i = 0; i < a.length; i += SPECIES.length()) {
1785                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1786                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1787                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1788             }
1789         }
1790 
1791         assertArraysEquals(r, a, b, Short256VectorTests::AND_NOT);
1792     }
1793 
1794 
1795 
1796     @Test(dataProvider = "shortBinaryOpMaskProvider")
1797     static void AND_NOTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1798                                           IntFunction<boolean[]> fm) {
1799         short[] a = fa.apply(SPECIES.length());
1800         short[] b = fb.apply(SPECIES.length());
1801         short[] r = fr.apply(SPECIES.length());
1802         boolean[] mask = fm.apply(SPECIES.length());
1803         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1804 
1805         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1806             for (int i = 0; i < a.length; i += SPECIES.length()) {
1807                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1808                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1809                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1810             }
1811         }
1812 
1813         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND_NOT);
1814     }
1815 
1816 
1817     static short OR(short a, short b) {
1818         return (short)(a | b);
1819     }
1820 
1821     @Test(dataProvider = "shortBinaryOpProvider")
1822     static void ORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1823         short[] a = fa.apply(SPECIES.length());
1824         short[] b = fb.apply(SPECIES.length());
1825         short[] r = fr.apply(SPECIES.length());
1826 
1827         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1828             for (int i = 0; i < a.length; i += SPECIES.length()) {
1829                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1830                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1831                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1832             }
1833         }
1834 
1835         assertArraysEquals(r, a, b, Short256VectorTests::OR);
1836     }
1837     static short or(short a, short b) {
1838         return (short)(a | b);
1839     }
1840 
1841     @Test(dataProvider = "shortBinaryOpProvider")
1842     static void orShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1843         short[] a = fa.apply(SPECIES.length());
1844         short[] b = fb.apply(SPECIES.length());
1845         short[] r = fr.apply(SPECIES.length());
1846 
1847         for (int i = 0; i < a.length; i += SPECIES.length()) {
1848             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1849             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1850             av.or(bv).intoArray(r, i);
1851         }
1852 
1853         assertArraysEquals(r, a, b, Short256VectorTests::or);
1854     }
1855 
1856 
1857 
1858     @Test(dataProvider = "shortBinaryOpMaskProvider")
1859     static void ORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1860                                           IntFunction<boolean[]> fm) {
1861         short[] a = fa.apply(SPECIES.length());
1862         short[] b = fb.apply(SPECIES.length());
1863         short[] r = fr.apply(SPECIES.length());
1864         boolean[] mask = fm.apply(SPECIES.length());
1865         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1866 
1867         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1868             for (int i = 0; i < a.length; i += SPECIES.length()) {
1869                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1870                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1871                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1872             }
1873         }
1874 
1875         assertArraysEquals(r, a, b, mask, Short256VectorTests::OR);
1876     }
1877 
1878 
1879     static short XOR(short a, short b) {
1880         return (short)(a ^ b);
1881     }
1882 
1883     @Test(dataProvider = "shortBinaryOpProvider")
1884     static void XORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1885         short[] a = fa.apply(SPECIES.length());
1886         short[] b = fb.apply(SPECIES.length());
1887         short[] r = fr.apply(SPECIES.length());
1888 
1889         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1890             for (int i = 0; i < a.length; i += SPECIES.length()) {
1891                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1892                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1893                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1894             }
1895         }
1896 
1897         assertArraysEquals(r, a, b, Short256VectorTests::XOR);
1898     }
1899 
1900 
1901 
1902     @Test(dataProvider = "shortBinaryOpMaskProvider")
1903     static void XORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1904                                           IntFunction<boolean[]> fm) {
1905         short[] a = fa.apply(SPECIES.length());
1906         short[] b = fb.apply(SPECIES.length());
1907         short[] r = fr.apply(SPECIES.length());
1908         boolean[] mask = fm.apply(SPECIES.length());
1909         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1910 
1911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1912             for (int i = 0; i < a.length; i += SPECIES.length()) {
1913                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1914                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1915                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1916             }
1917         }
1918 
1919         assertArraysEquals(r, a, b, mask, Short256VectorTests::XOR);
1920     }
1921 
1922 
1923     @Test(dataProvider = "shortBinaryOpProvider")
1924     static void addShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1925         short[] a = fa.apply(SPECIES.length());
1926         short[] b = fb.apply(SPECIES.length());
1927         short[] r = fr.apply(SPECIES.length());
1928 
1929         for (int i = 0; i < a.length; i += SPECIES.length()) {
1930             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1931             av.add(b[i]).intoArray(r, i);
1932         }
1933 
1934         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::add);
1935     }
1936 
1937     @Test(dataProvider = "shortBinaryOpMaskProvider")
1938     static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1939                                           IntFunction<boolean[]> fm) {
1940         short[] a = fa.apply(SPECIES.length());
1941         short[] b = fb.apply(SPECIES.length());
1942         short[] r = fr.apply(SPECIES.length());
1943         boolean[] mask = fm.apply(SPECIES.length());
1944         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1945 
1946         for (int i = 0; i < a.length; i += SPECIES.length()) {
1947             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1948             av.add(b[i], vmask).intoArray(r, i);
1949         }
1950 
1951         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::add);
1952     }
1953 
1954     @Test(dataProvider = "shortBinaryOpProvider")
1955     static void subShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1956         short[] a = fa.apply(SPECIES.length());
1957         short[] b = fb.apply(SPECIES.length());
1958         short[] r = fr.apply(SPECIES.length());
1959 
1960         for (int i = 0; i < a.length; i += SPECIES.length()) {
1961             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1962             av.sub(b[i]).intoArray(r, i);
1963         }
1964 
1965         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::sub);
1966     }
1967 
1968     @Test(dataProvider = "shortBinaryOpMaskProvider")
1969     static void subShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1970                                           IntFunction<boolean[]> fm) {
1971         short[] a = fa.apply(SPECIES.length());
1972         short[] b = fb.apply(SPECIES.length());
1973         short[] r = fr.apply(SPECIES.length());
1974         boolean[] mask = fm.apply(SPECIES.length());
1975         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1976 
1977         for (int i = 0; i < a.length; i += SPECIES.length()) {
1978             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1979             av.sub(b[i], vmask).intoArray(r, i);
1980         }
1981 
1982         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::sub);
1983     }
1984 
1985     @Test(dataProvider = "shortBinaryOpProvider")
1986     static void mulShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1987         short[] a = fa.apply(SPECIES.length());
1988         short[] b = fb.apply(SPECIES.length());
1989         short[] r = fr.apply(SPECIES.length());
1990 
1991         for (int i = 0; i < a.length; i += SPECIES.length()) {
1992             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1993             av.mul(b[i]).intoArray(r, i);
1994         }
1995 
1996         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::mul);
1997     }
1998 
1999     @Test(dataProvider = "shortBinaryOpMaskProvider")
2000     static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2001                                           IntFunction<boolean[]> fm) {
2002         short[] a = fa.apply(SPECIES.length());
2003         short[] b = fb.apply(SPECIES.length());
2004         short[] r = fr.apply(SPECIES.length());
2005         boolean[] mask = fm.apply(SPECIES.length());
2006         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2007 
2008         for (int i = 0; i < a.length; i += SPECIES.length()) {
2009             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2010             av.mul(b[i], vmask).intoArray(r, i);
2011         }
2012 
2013         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::mul);
2014     }
2015 
2016 
2017 
2018 
2019     @Test(dataProvider = "shortBinaryOpProvider")
2020     static void divShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2021         short[] a = fa.apply(SPECIES.length());
2022         short[] b = fb.apply(SPECIES.length());
2023         short[] r = fr.apply(SPECIES.length());
2024 
2025         replaceZero(b, (short) 1);
2026 
2027         for (int i = 0; i < a.length; i += SPECIES.length()) {
2028             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2029             av.div(b[i]).intoArray(r, i);
2030         }
2031 
2032         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::div);
2033     }
2034 
2035 
2036 
2037     @Test(dataProvider = "shortBinaryOpMaskProvider")
2038     static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2039                                           IntFunction<boolean[]> fm) {
2040         short[] a = fa.apply(SPECIES.length());
2041         short[] b = fb.apply(SPECIES.length());
2042         short[] r = fr.apply(SPECIES.length());
2043         boolean[] mask = fm.apply(SPECIES.length());
2044         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2045 
2046         replaceZero(b, (short) 1);
2047 
2048         for (int i = 0; i < a.length; i += SPECIES.length()) {
2049             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2050             av.div(b[i], vmask).intoArray(r, i);
2051         }
2052 
2053         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::div);
2054     }
2055 
2056 
2057 
2058     @Test(dataProvider = "shortBinaryOpProvider")
2059     static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2060         short[] a = fa.apply(SPECIES.length());
2061         short[] b = fb.apply(SPECIES.length());
2062         short[] r = fr.apply(SPECIES.length());
2063 
2064         for (int i = 0; i < a.length; i += SPECIES.length()) {
2065             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2066             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2067         }
2068 
2069         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::OR);
2070     }
2071 
2072     @Test(dataProvider = "shortBinaryOpProvider")
2073     static void orShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2074         short[] a = fa.apply(SPECIES.length());
2075         short[] b = fb.apply(SPECIES.length());
2076         short[] r = fr.apply(SPECIES.length());
2077 
2078         for (int i = 0; i < a.length; i += SPECIES.length()) {
2079             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2080             av.or(b[i]).intoArray(r, i);
2081         }
2082 
2083         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::or);
2084     }
2085 
2086 
2087 
2088     @Test(dataProvider = "shortBinaryOpMaskProvider")
2089     static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2090                                           IntFunction<boolean[]> fm) {
2091         short[] a = fa.apply(SPECIES.length());
2092         short[] b = fb.apply(SPECIES.length());
2093         short[] r = fr.apply(SPECIES.length());
2094         boolean[] mask = fm.apply(SPECIES.length());
2095         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2096 
2097         for (int i = 0; i < a.length; i += SPECIES.length()) {
2098             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2099             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2100         }
2101 
2102         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2103     }
2104 
2105 
2106 
2107     @Test(dataProvider = "shortBinaryOpProvider")
2108     static void ANDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2109         short[] a = fa.apply(SPECIES.length());
2110         short[] b = fb.apply(SPECIES.length());
2111         short[] r = fr.apply(SPECIES.length());
2112 
2113         for (int i = 0; i < a.length; i += SPECIES.length()) {
2114             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2115             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2116         }
2117 
2118         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::AND);
2119     }
2120 
2121     @Test(dataProvider = "shortBinaryOpProvider")
2122     static void andShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2123         short[] a = fa.apply(SPECIES.length());
2124         short[] b = fb.apply(SPECIES.length());
2125         short[] r = fr.apply(SPECIES.length());
2126 
2127         for (int i = 0; i < a.length; i += SPECIES.length()) {
2128             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2129             av.and(b[i]).intoArray(r, i);
2130         }
2131 
2132         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::and);
2133     }
2134 
2135 
2136 
2137     @Test(dataProvider = "shortBinaryOpMaskProvider")
2138     static void ANDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2139                                           IntFunction<boolean[]> fm) {
2140         short[] a = fa.apply(SPECIES.length());
2141         short[] b = fb.apply(SPECIES.length());
2142         short[] r = fr.apply(SPECIES.length());
2143         boolean[] mask = fm.apply(SPECIES.length());
2144         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2145 
2146         for (int i = 0; i < a.length; i += SPECIES.length()) {
2147             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2148             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2149         }
2150 
2151         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::AND);
2152     }
2153 
2154 
2155 
2156     @Test(dataProvider = "shortBinaryOpProvider")
2157     static void ORShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2158         short[] a = fa.apply(SPECIES.length());
2159         short[] b = fb.apply(SPECIES.length());
2160         short[] r = fr.apply(SPECIES.length());
2161 
2162         for (int i = 0; i < a.length; i += SPECIES.length()) {
2163             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2164             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2165         }
2166 
2167         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::OR);
2168     }
2169 
2170 
2171 
2172     @Test(dataProvider = "shortBinaryOpMaskProvider")
2173     static void ORShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2174                                           IntFunction<boolean[]> fm) {
2175         short[] a = fa.apply(SPECIES.length());
2176         short[] b = fb.apply(SPECIES.length());
2177         short[] r = fr.apply(SPECIES.length());
2178         boolean[] mask = fm.apply(SPECIES.length());
2179         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2180 
2181         for (int i = 0; i < a.length; i += SPECIES.length()) {
2182             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2183             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2184         }
2185 
2186         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2187     }
2188 
2189 
2190     @Test(dataProvider = "shortBinaryOpProvider")
2191     static void ADDShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2192         short[] a = fa.apply(SPECIES.length());
2193         short[] b = fb.apply(SPECIES.length());
2194         short[] r = fr.apply(SPECIES.length());
2195 
2196         for (int i = 0; i < a.length; i += SPECIES.length()) {
2197             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2198             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2199         }
2200 
2201         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::ADD);
2202     }
2203 
2204     @Test(dataProvider = "shortBinaryOpMaskProvider")
2205     static void ADDShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2206                                           IntFunction<boolean[]> fm) {
2207         short[] a = fa.apply(SPECIES.length());
2208         short[] b = fb.apply(SPECIES.length());
2209         short[] r = fr.apply(SPECIES.length());
2210         boolean[] mask = fm.apply(SPECIES.length());
2211         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2212 
2213         for (int i = 0; i < a.length; i += SPECIES.length()) {
2214             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2215             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2216         }
2217 
2218         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
2219     }
2220 
2221 
2222 
2223 
2224 
2225     static short LSHL(short a, short b) {
2226         return (short)((a << (b & 0xF)));
2227     }
2228 
2229     @Test(dataProvider = "shortBinaryOpProvider")
2230     static void LSHLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2231         short[] a = fa.apply(SPECIES.length());
2232         short[] b = fb.apply(SPECIES.length());
2233         short[] r = fr.apply(SPECIES.length());
2234 
2235         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2236             for (int i = 0; i < a.length; i += SPECIES.length()) {
2237                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2238                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2239                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2240             }
2241         }
2242 
2243         assertArraysEquals(r, a, b, Short256VectorTests::LSHL);
2244     }
2245 
2246 
2247 
2248     @Test(dataProvider = "shortBinaryOpMaskProvider")
2249     static void LSHLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2250                                           IntFunction<boolean[]> fm) {
2251         short[] a = fa.apply(SPECIES.length());
2252         short[] b = fb.apply(SPECIES.length());
2253         short[] r = fr.apply(SPECIES.length());
2254         boolean[] mask = fm.apply(SPECIES.length());
2255         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2256 
2257         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2258             for (int i = 0; i < a.length; i += SPECIES.length()) {
2259                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2260                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2261                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2262             }
2263         }
2264 
2265         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHL);
2266     }
2267 
2268 
2269 
2270 
2271 
2272 
2273     static short ASHR(short a, short b) {
2274         return (short)((a >> (b & 0xF)));
2275     }
2276 
2277     @Test(dataProvider = "shortBinaryOpProvider")
2278     static void ASHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2279         short[] a = fa.apply(SPECIES.length());
2280         short[] b = fb.apply(SPECIES.length());
2281         short[] r = fr.apply(SPECIES.length());
2282 
2283         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2284             for (int i = 0; i < a.length; i += SPECIES.length()) {
2285                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2286                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2287                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2288             }
2289         }
2290 
2291         assertArraysEquals(r, a, b, Short256VectorTests::ASHR);
2292     }
2293 
2294 
2295 
2296     @Test(dataProvider = "shortBinaryOpMaskProvider")
2297     static void ASHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2298                                           IntFunction<boolean[]> fm) {
2299         short[] a = fa.apply(SPECIES.length());
2300         short[] b = fb.apply(SPECIES.length());
2301         short[] r = fr.apply(SPECIES.length());
2302         boolean[] mask = fm.apply(SPECIES.length());
2303         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2304 
2305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2306             for (int i = 0; i < a.length; i += SPECIES.length()) {
2307                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2308                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2309                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2310             }
2311         }
2312 
2313         assertArraysEquals(r, a, b, mask, Short256VectorTests::ASHR);
2314     }
2315 
2316 
2317 
2318 
2319 
2320 
2321     static short LSHR(short a, short b) {
2322         return (short)(((a & 0xFFFF) >>> (b & 0xF)));
2323     }
2324 
2325     @Test(dataProvider = "shortBinaryOpProvider")
2326     static void LSHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2327         short[] a = fa.apply(SPECIES.length());
2328         short[] b = fb.apply(SPECIES.length());
2329         short[] r = fr.apply(SPECIES.length());
2330 
2331         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2332             for (int i = 0; i < a.length; i += SPECIES.length()) {
2333                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2334                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2335                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2336             }
2337         }
2338 
2339         assertArraysEquals(r, a, b, Short256VectorTests::LSHR);
2340     }
2341 
2342 
2343 
2344     @Test(dataProvider = "shortBinaryOpMaskProvider")
2345     static void LSHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2346                                           IntFunction<boolean[]> fm) {
2347         short[] a = fa.apply(SPECIES.length());
2348         short[] b = fb.apply(SPECIES.length());
2349         short[] r = fr.apply(SPECIES.length());
2350         boolean[] mask = fm.apply(SPECIES.length());
2351         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2352 
2353         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2354             for (int i = 0; i < a.length; i += SPECIES.length()) {
2355                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2356                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2357                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2358             }
2359         }
2360 
2361         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHR);
2362     }
2363 
2364 
2365 
2366 
2367 
2368 
2369     static short LSHL_unary(short a, short b) {
2370         return (short)((a << (b & 15)));
2371     }
2372 
2373     @Test(dataProvider = "shortBinaryOpProvider")
2374     static void LSHLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2375         short[] a = fa.apply(SPECIES.length());
2376         short[] b = fb.apply(SPECIES.length());
2377         short[] r = fr.apply(SPECIES.length());
2378 
2379         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2380             for (int i = 0; i < a.length; i += SPECIES.length()) {
2381                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2382                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2383             }
2384         }
2385 
2386         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHL_unary);
2387     }
2388 
2389 
2390 
2391     @Test(dataProvider = "shortBinaryOpMaskProvider")
2392     static void LSHLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2393                                           IntFunction<boolean[]> fm) {
2394         short[] a = fa.apply(SPECIES.length());
2395         short[] b = fb.apply(SPECIES.length());
2396         short[] r = fr.apply(SPECIES.length());
2397         boolean[] mask = fm.apply(SPECIES.length());
2398         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2399 
2400         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2401             for (int i = 0; i < a.length; i += SPECIES.length()) {
2402                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2403                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2404             }
2405         }
2406 
2407         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHL_unary);
2408     }
2409 
2410 
2411 
2412 
2413 
2414 
2415     static short LSHR_unary(short a, short b) {
2416         return (short)(((a & 0xFFFF) >>> (b & 15)));
2417     }
2418 
2419     @Test(dataProvider = "shortBinaryOpProvider")
2420     static void LSHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2421         short[] a = fa.apply(SPECIES.length());
2422         short[] b = fb.apply(SPECIES.length());
2423         short[] r = fr.apply(SPECIES.length());
2424 
2425         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2426             for (int i = 0; i < a.length; i += SPECIES.length()) {
2427                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2428                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2429             }
2430         }
2431 
2432         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHR_unary);
2433     }
2434 
2435 
2436 
2437     @Test(dataProvider = "shortBinaryOpMaskProvider")
2438     static void LSHRShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2439                                           IntFunction<boolean[]> fm) {
2440         short[] a = fa.apply(SPECIES.length());
2441         short[] b = fb.apply(SPECIES.length());
2442         short[] r = fr.apply(SPECIES.length());
2443         boolean[] mask = fm.apply(SPECIES.length());
2444         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2445 
2446         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2447             for (int i = 0; i < a.length; i += SPECIES.length()) {
2448                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2449                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2450             }
2451         }
2452 
2453         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHR_unary);
2454     }
2455 
2456 
2457 
2458 
2459 
2460 
2461     static short ASHR_unary(short a, short b) {
2462         return (short)((a >> (b & 15)));
2463     }
2464 
2465     @Test(dataProvider = "shortBinaryOpProvider")
2466     static void ASHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2467         short[] a = fa.apply(SPECIES.length());
2468         short[] b = fb.apply(SPECIES.length());
2469         short[] r = fr.apply(SPECIES.length());
2470 
2471         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2472             for (int i = 0; i < a.length; i += SPECIES.length()) {
2473                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2474                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2475             }
2476         }
2477 
2478         assertShiftArraysEquals(r, a, b, Short256VectorTests::ASHR_unary);
2479     }
2480 
2481 
2482 
2483     @Test(dataProvider = "shortBinaryOpMaskProvider")
2484     static void ASHRShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2485                                           IntFunction<boolean[]> fm) {
2486         short[] a = fa.apply(SPECIES.length());
2487         short[] b = fb.apply(SPECIES.length());
2488         short[] r = fr.apply(SPECIES.length());
2489         boolean[] mask = fm.apply(SPECIES.length());
2490         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2491 
2492         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2493             for (int i = 0; i < a.length; i += SPECIES.length()) {
2494                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2495                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2496             }
2497         }
2498 
2499         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ASHR_unary);
2500     }
2501 
2502 
2503     static short ROR(short a, short b) {
2504         return (short)(ROR_scalar(a,b));
2505     }
2506 
2507     @Test(dataProvider = "shortBinaryOpProvider")
2508     static void RORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2509         short[] a = fa.apply(SPECIES.length());
2510         short[] b = fb.apply(SPECIES.length());
2511         short[] r = fr.apply(SPECIES.length());
2512 
2513         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2514             for (int i = 0; i < a.length; i += SPECIES.length()) {
2515                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2516                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2517                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2518             }
2519         }
2520 
2521         assertArraysEquals(r, a, b, Short256VectorTests::ROR);
2522     }
2523 
2524 
2525 
2526     @Test(dataProvider = "shortBinaryOpMaskProvider")
2527     static void RORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2528                                           IntFunction<boolean[]> fm) {
2529         short[] a = fa.apply(SPECIES.length());
2530         short[] b = fb.apply(SPECIES.length());
2531         short[] r = fr.apply(SPECIES.length());
2532         boolean[] mask = fm.apply(SPECIES.length());
2533         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2534 
2535         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2536             for (int i = 0; i < a.length; i += SPECIES.length()) {
2537                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2538                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2539                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2540             }
2541         }
2542 
2543         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROR);
2544     }
2545 
2546 
2547     static short ROL(short a, short b) {
2548         return (short)(ROL_scalar(a,b));
2549     }
2550 
2551     @Test(dataProvider = "shortBinaryOpProvider")
2552     static void ROLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2553         short[] a = fa.apply(SPECIES.length());
2554         short[] b = fb.apply(SPECIES.length());
2555         short[] r = fr.apply(SPECIES.length());
2556 
2557         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2558             for (int i = 0; i < a.length; i += SPECIES.length()) {
2559                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2560                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2561                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2562             }
2563         }
2564 
2565         assertArraysEquals(r, a, b, Short256VectorTests::ROL);
2566     }
2567 
2568 
2569 
2570     @Test(dataProvider = "shortBinaryOpMaskProvider")
2571     static void ROLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2572                                           IntFunction<boolean[]> fm) {
2573         short[] a = fa.apply(SPECIES.length());
2574         short[] b = fb.apply(SPECIES.length());
2575         short[] r = fr.apply(SPECIES.length());
2576         boolean[] mask = fm.apply(SPECIES.length());
2577         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
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                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2583                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2584             }
2585         }
2586 
2587         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROL);
2588     }
2589 
2590 
2591     static short ROR_unary(short a, short b) {
2592         return (short)(ROR_scalar(a,b));
2593     }
2594 
2595     @Test(dataProvider = "shortBinaryOpProvider")
2596     static void RORShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2597         short[] a = fa.apply(SPECIES.length());
2598         short[] b = fb.apply(SPECIES.length());
2599         short[] r = fr.apply(SPECIES.length());
2600 
2601         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2602             for (int i = 0; i < a.length; i += SPECIES.length()) {
2603                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2604                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2605             }
2606         }
2607 
2608         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROR_unary);
2609     }
2610 
2611 
2612 
2613     @Test(dataProvider = "shortBinaryOpMaskProvider")
2614     static void RORShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2615                                           IntFunction<boolean[]> fm) {
2616         short[] a = fa.apply(SPECIES.length());
2617         short[] b = fb.apply(SPECIES.length());
2618         short[] r = fr.apply(SPECIES.length());
2619         boolean[] mask = fm.apply(SPECIES.length());
2620         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2621 
2622         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2623             for (int i = 0; i < a.length; i += SPECIES.length()) {
2624                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2625                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2626             }
2627         }
2628 
2629         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROR_unary);
2630     }
2631 
2632 
2633     static short ROL_unary(short a, short b) {
2634         return (short)(ROL_scalar(a,b));
2635     }
2636 
2637     @Test(dataProvider = "shortBinaryOpProvider")
2638     static void ROLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2639         short[] a = fa.apply(SPECIES.length());
2640         short[] b = fb.apply(SPECIES.length());
2641         short[] r = fr.apply(SPECIES.length());
2642 
2643         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2644             for (int i = 0; i < a.length; i += SPECIES.length()) {
2645                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2646                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2647             }
2648         }
2649 
2650         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROL_unary);
2651     }
2652 
2653 
2654 
2655     @Test(dataProvider = "shortBinaryOpMaskProvider")
2656     static void ROLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2657                                           IntFunction<boolean[]> fm) {
2658         short[] a = fa.apply(SPECIES.length());
2659         short[] b = fb.apply(SPECIES.length());
2660         short[] r = fr.apply(SPECIES.length());
2661         boolean[] mask = fm.apply(SPECIES.length());
2662         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2663 
2664         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2665             for (int i = 0; i < a.length; i += SPECIES.length()) {
2666                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2667                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2668             }
2669         }
2670 
2671         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROL_unary);
2672     }
2673 
2674     static short MIN(short a, short b) {
2675         return (short)(Math.min(a, b));
2676     }
2677 
2678     @Test(dataProvider = "shortBinaryOpProvider")
2679     static void MINShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2680         short[] a = fa.apply(SPECIES.length());
2681         short[] b = fb.apply(SPECIES.length());
2682         short[] r = fr.apply(SPECIES.length());
2683 
2684         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2685             for (int i = 0; i < a.length; i += SPECIES.length()) {
2686                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2687                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2688                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2689             }
2690         }
2691 
2692         assertArraysEquals(r, a, b, Short256VectorTests::MIN);
2693     }
2694     static short min(short a, short b) {
2695         return (short)(Math.min(a, b));
2696     }
2697 
2698     @Test(dataProvider = "shortBinaryOpProvider")
2699     static void minShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2700         short[] a = fa.apply(SPECIES.length());
2701         short[] b = fb.apply(SPECIES.length());
2702         short[] r = fr.apply(SPECIES.length());
2703 
2704         for (int i = 0; i < a.length; i += SPECIES.length()) {
2705             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2706             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2707             av.min(bv).intoArray(r, i);
2708         }
2709 
2710         assertArraysEquals(r, a, b, Short256VectorTests::min);
2711     }
2712     static short MAX(short a, short b) {
2713         return (short)(Math.max(a, b));
2714     }
2715 
2716     @Test(dataProvider = "shortBinaryOpProvider")
2717     static void MAXShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2718         short[] a = fa.apply(SPECIES.length());
2719         short[] b = fb.apply(SPECIES.length());
2720         short[] r = fr.apply(SPECIES.length());
2721 
2722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2723             for (int i = 0; i < a.length; i += SPECIES.length()) {
2724                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2725                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2726                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2727             }
2728         }
2729 
2730         assertArraysEquals(r, a, b, Short256VectorTests::MAX);
2731     }
2732     static short max(short a, short b) {
2733         return (short)(Math.max(a, b));
2734     }
2735 
2736     @Test(dataProvider = "shortBinaryOpProvider")
2737     static void maxShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2738         short[] a = fa.apply(SPECIES.length());
2739         short[] b = fb.apply(SPECIES.length());
2740         short[] r = fr.apply(SPECIES.length());
2741 
2742         for (int i = 0; i < a.length; i += SPECIES.length()) {
2743             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2744             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2745             av.max(bv).intoArray(r, i);
2746         }
2747 
2748         assertArraysEquals(r, a, b, Short256VectorTests::max);
2749     }
2750 
2751     @Test(dataProvider = "shortBinaryOpProvider")
2752     static void MINShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2753         short[] a = fa.apply(SPECIES.length());
2754         short[] b = fb.apply(SPECIES.length());
2755         short[] r = fr.apply(SPECIES.length());
2756 
2757         for (int i = 0; i < a.length; i += SPECIES.length()) {
2758             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2759             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
2760         }
2761 
2762         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MIN);
2763     }
2764 
2765     @Test(dataProvider = "shortBinaryOpProvider")
2766     static void minShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2767         short[] a = fa.apply(SPECIES.length());
2768         short[] b = fb.apply(SPECIES.length());
2769         short[] r = fr.apply(SPECIES.length());
2770 
2771         for (int i = 0; i < a.length; i += SPECIES.length()) {
2772             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2773             av.min(b[i]).intoArray(r, i);
2774         }
2775 
2776         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::min);
2777     }
2778 
2779     @Test(dataProvider = "shortBinaryOpProvider")
2780     static void MAXShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2781         short[] a = fa.apply(SPECIES.length());
2782         short[] b = fb.apply(SPECIES.length());
2783         short[] r = fr.apply(SPECIES.length());
2784 
2785         for (int i = 0; i < a.length; i += SPECIES.length()) {
2786             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2787             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2788         }
2789 
2790         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::MAX);
2791     }
2792 
2793     @Test(dataProvider = "shortBinaryOpProvider")
2794     static void maxShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2795         short[] a = fa.apply(SPECIES.length());
2796         short[] b = fb.apply(SPECIES.length());
2797         short[] r = fr.apply(SPECIES.length());
2798 
2799         for (int i = 0; i < a.length; i += SPECIES.length()) {
2800             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2801             av.max(b[i]).intoArray(r, i);
2802         }
2803 
2804         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::max);
2805     }
2806 
2807     static short ANDReduce(short[] a, int idx) {
2808         short res = -1;
2809         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2810             res &= a[i];
2811         }
2812 
2813         return res;
2814     }
2815 
2816     static short ANDReduceAll(short[] a) {
2817         short res = -1;
2818         for (int i = 0; i < a.length; i += SPECIES.length()) {
2819             res &= ANDReduce(a, i);
2820         }
2821 
2822         return res;
2823     }
2824 
2825 
2826     @Test(dataProvider = "shortUnaryOpProvider")
2827     static void ANDReduceShort256VectorTests(IntFunction<short[]> fa) {
2828         short[] a = fa.apply(SPECIES.length());
2829         short[] r = fr.apply(SPECIES.length());
2830         short ra = -1;
2831 
2832         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2833             for (int i = 0; i < a.length; i += SPECIES.length()) {
2834                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2835                 r[i] = av.reduceLanes(VectorOperators.AND);
2836             }
2837         }
2838 
2839         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2840             ra = -1;
2841             for (int i = 0; i < a.length; i += SPECIES.length()) {
2842                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2843                 ra &= av.reduceLanes(VectorOperators.AND);
2844             }
2845         }
2846 
2847         assertReductionArraysEquals(r, ra, a,
2848                 Short256VectorTests::ANDReduce, Short256VectorTests::ANDReduceAll);
2849     }
2850 
2851 
2852     static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
2853         short res = -1;
2854         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2855             if (mask[i % SPECIES.length()])
2856                 res &= a[i];
2857         }
2858 
2859         return res;
2860     }
2861 
2862     static short ANDReduceAllMasked(short[] a, boolean[] mask) {
2863         short res = -1;
2864         for (int i = 0; i < a.length; i += SPECIES.length()) {
2865             res &= ANDReduceMasked(a, i, mask);
2866         }
2867 
2868         return res;
2869     }
2870 
2871 
2872     @Test(dataProvider = "shortUnaryOpMaskProvider")
2873     static void ANDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
2874         short[] a = fa.apply(SPECIES.length());
2875         short[] r = fr.apply(SPECIES.length());
2876         boolean[] mask = fm.apply(SPECIES.length());
2877         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2878         short ra = -1;
2879 
2880         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2881             for (int i = 0; i < a.length; i += SPECIES.length()) {
2882                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2883                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
2884             }
2885         }
2886 
2887         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2888             ra = -1;
2889             for (int i = 0; i < a.length; i += SPECIES.length()) {
2890                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2891                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
2892             }
2893         }
2894 
2895         assertReductionArraysEqualsMasked(r, ra, a, mask,
2896                 Short256VectorTests::ANDReduceMasked, Short256VectorTests::ANDReduceAllMasked);
2897     }
2898 
2899 
2900     static short ORReduce(short[] a, int idx) {
2901         short res = 0;
2902         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2903             res |= a[i];
2904         }
2905 
2906         return res;
2907     }
2908 
2909     static short ORReduceAll(short[] a) {
2910         short res = 0;
2911         for (int i = 0; i < a.length; i += SPECIES.length()) {
2912             res |= ORReduce(a, i);
2913         }
2914 
2915         return res;
2916     }
2917 
2918 
2919     @Test(dataProvider = "shortUnaryOpProvider")
2920     static void ORReduceShort256VectorTests(IntFunction<short[]> fa) {
2921         short[] a = fa.apply(SPECIES.length());
2922         short[] r = fr.apply(SPECIES.length());
2923         short ra = 0;
2924 
2925         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2926             for (int i = 0; i < a.length; i += SPECIES.length()) {
2927                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2928                 r[i] = av.reduceLanes(VectorOperators.OR);
2929             }
2930         }
2931 
2932         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2933             ra = 0;
2934             for (int i = 0; i < a.length; i += SPECIES.length()) {
2935                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2936                 ra |= av.reduceLanes(VectorOperators.OR);
2937             }
2938         }
2939 
2940         assertReductionArraysEquals(r, ra, a,
2941                 Short256VectorTests::ORReduce, Short256VectorTests::ORReduceAll);
2942     }
2943 
2944 
2945     static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
2946         short res = 0;
2947         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2948             if (mask[i % SPECIES.length()])
2949                 res |= a[i];
2950         }
2951 
2952         return res;
2953     }
2954 
2955     static short ORReduceAllMasked(short[] a, boolean[] mask) {
2956         short res = 0;
2957         for (int i = 0; i < a.length; i += SPECIES.length()) {
2958             res |= ORReduceMasked(a, i, mask);
2959         }
2960 
2961         return res;
2962     }
2963 
2964 
2965     @Test(dataProvider = "shortUnaryOpMaskProvider")
2966     static void ORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
2967         short[] a = fa.apply(SPECIES.length());
2968         short[] r = fr.apply(SPECIES.length());
2969         boolean[] mask = fm.apply(SPECIES.length());
2970         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2971         short ra = 0;
2972 
2973         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2974             for (int i = 0; i < a.length; i += SPECIES.length()) {
2975                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2976                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
2977             }
2978         }
2979 
2980         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2981             ra = 0;
2982             for (int i = 0; i < a.length; i += SPECIES.length()) {
2983                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2984                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
2985             }
2986         }
2987 
2988         assertReductionArraysEqualsMasked(r, ra, a, mask,
2989                 Short256VectorTests::ORReduceMasked, Short256VectorTests::ORReduceAllMasked);
2990     }
2991 
2992 
2993     static short XORReduce(short[] a, int idx) {
2994         short res = 0;
2995         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2996             res ^= a[i];
2997         }
2998 
2999         return res;
3000     }
3001 
3002     static short XORReduceAll(short[] a) {
3003         short res = 0;
3004         for (int i = 0; i < a.length; i += SPECIES.length()) {
3005             res ^= XORReduce(a, i);
3006         }
3007 
3008         return res;
3009     }
3010 
3011 
3012     @Test(dataProvider = "shortUnaryOpProvider")
3013     static void XORReduceShort256VectorTests(IntFunction<short[]> fa) {
3014         short[] a = fa.apply(SPECIES.length());
3015         short[] r = fr.apply(SPECIES.length());
3016         short ra = 0;
3017 
3018         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3019             for (int i = 0; i < a.length; i += SPECIES.length()) {
3020                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3021                 r[i] = av.reduceLanes(VectorOperators.XOR);
3022             }
3023         }
3024 
3025         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3026             ra = 0;
3027             for (int i = 0; i < a.length; i += SPECIES.length()) {
3028                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3029                 ra ^= av.reduceLanes(VectorOperators.XOR);
3030             }
3031         }
3032 
3033         assertReductionArraysEquals(r, ra, a,
3034                 Short256VectorTests::XORReduce, Short256VectorTests::XORReduceAll);
3035     }
3036 
3037 
3038     static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
3039         short res = 0;
3040         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3041             if (mask[i % SPECIES.length()])
3042                 res ^= a[i];
3043         }
3044 
3045         return res;
3046     }
3047 
3048     static short XORReduceAllMasked(short[] a, boolean[] mask) {
3049         short res = 0;
3050         for (int i = 0; i < a.length; i += SPECIES.length()) {
3051             res ^= XORReduceMasked(a, i, mask);
3052         }
3053 
3054         return res;
3055     }
3056 
3057 
3058     @Test(dataProvider = "shortUnaryOpMaskProvider")
3059     static void XORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3060         short[] a = fa.apply(SPECIES.length());
3061         short[] r = fr.apply(SPECIES.length());
3062         boolean[] mask = fm.apply(SPECIES.length());
3063         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3064         short ra = 0;
3065 
3066         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3067             for (int i = 0; i < a.length; i += SPECIES.length()) {
3068                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3069                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3070             }
3071         }
3072 
3073         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3074             ra = 0;
3075             for (int i = 0; i < a.length; i += SPECIES.length()) {
3076                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3077                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3078             }
3079         }
3080 
3081         assertReductionArraysEqualsMasked(r, ra, a, mask,
3082                 Short256VectorTests::XORReduceMasked, Short256VectorTests::XORReduceAllMasked);
3083     }
3084 
3085     static short ADDReduce(short[] a, int idx) {
3086         short res = 0;
3087         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3088             res += a[i];
3089         }
3090 
3091         return res;
3092     }
3093 
3094     static short ADDReduceAll(short[] a) {
3095         short res = 0;
3096         for (int i = 0; i < a.length; i += SPECIES.length()) {
3097             res += ADDReduce(a, i);
3098         }
3099 
3100         return res;
3101     }
3102     @Test(dataProvider = "shortUnaryOpProvider")
3103     static void ADDReduceShort256VectorTests(IntFunction<short[]> fa) {
3104         short[] a = fa.apply(SPECIES.length());
3105         short[] r = fr.apply(SPECIES.length());
3106         short ra = 0;
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                 r[i] = av.reduceLanes(VectorOperators.ADD);
3112             }
3113         }
3114 
3115         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3116             ra = 0;
3117             for (int i = 0; i < a.length; i += SPECIES.length()) {
3118                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3119                 ra += av.reduceLanes(VectorOperators.ADD);
3120             }
3121         }
3122 
3123         assertReductionArraysEquals(r, ra, a,
3124                 Short256VectorTests::ADDReduce, Short256VectorTests::ADDReduceAll);
3125     }
3126     static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
3127         short res = 0;
3128         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3129             if (mask[i % SPECIES.length()])
3130                 res += a[i];
3131         }
3132 
3133         return res;
3134     }
3135 
3136     static short ADDReduceAllMasked(short[] a, boolean[] mask) {
3137         short res = 0;
3138         for (int i = 0; i < a.length; i += SPECIES.length()) {
3139             res += ADDReduceMasked(a, i, mask);
3140         }
3141 
3142         return res;
3143     }
3144     @Test(dataProvider = "shortUnaryOpMaskProvider")
3145     static void ADDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3146         short[] a = fa.apply(SPECIES.length());
3147         short[] r = fr.apply(SPECIES.length());
3148         boolean[] mask = fm.apply(SPECIES.length());
3149         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3150         short ra = 0;
3151 
3152         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3153             for (int i = 0; i < a.length; i += SPECIES.length()) {
3154                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3155                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3156             }
3157         }
3158 
3159         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3160             ra = 0;
3161             for (int i = 0; i < a.length; i += SPECIES.length()) {
3162                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3163                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3164             }
3165         }
3166 
3167         assertReductionArraysEqualsMasked(r, ra, a, mask,
3168                 Short256VectorTests::ADDReduceMasked, Short256VectorTests::ADDReduceAllMasked);
3169     }
3170     static short MULReduce(short[] a, int idx) {
3171         short res = 1;
3172         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3173             res *= a[i];
3174         }
3175 
3176         return res;
3177     }
3178 
3179     static short MULReduceAll(short[] a) {
3180         short res = 1;
3181         for (int i = 0; i < a.length; i += SPECIES.length()) {
3182             res *= MULReduce(a, i);
3183         }
3184 
3185         return res;
3186     }
3187     @Test(dataProvider = "shortUnaryOpProvider")
3188     static void MULReduceShort256VectorTests(IntFunction<short[]> fa) {
3189         short[] a = fa.apply(SPECIES.length());
3190         short[] r = fr.apply(SPECIES.length());
3191         short ra = 1;
3192 
3193         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3194             for (int i = 0; i < a.length; i += SPECIES.length()) {
3195                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3196                 r[i] = av.reduceLanes(VectorOperators.MUL);
3197             }
3198         }
3199 
3200         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3201             ra = 1;
3202             for (int i = 0; i < a.length; i += SPECIES.length()) {
3203                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3204                 ra *= av.reduceLanes(VectorOperators.MUL);
3205             }
3206         }
3207 
3208         assertReductionArraysEquals(r, ra, a,
3209                 Short256VectorTests::MULReduce, Short256VectorTests::MULReduceAll);
3210     }
3211     static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
3212         short res = 1;
3213         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3214             if (mask[i % SPECIES.length()])
3215                 res *= a[i];
3216         }
3217 
3218         return res;
3219     }
3220 
3221     static short MULReduceAllMasked(short[] a, boolean[] mask) {
3222         short res = 1;
3223         for (int i = 0; i < a.length; i += SPECIES.length()) {
3224             res *= MULReduceMasked(a, i, mask);
3225         }
3226 
3227         return res;
3228     }
3229     @Test(dataProvider = "shortUnaryOpMaskProvider")
3230     static void MULReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3231         short[] a = fa.apply(SPECIES.length());
3232         short[] r = fr.apply(SPECIES.length());
3233         boolean[] mask = fm.apply(SPECIES.length());
3234         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3235         short ra = 1;
3236 
3237         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3238             for (int i = 0; i < a.length; i += SPECIES.length()) {
3239                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3240                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3241             }
3242         }
3243 
3244         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3245             ra = 1;
3246             for (int i = 0; i < a.length; i += SPECIES.length()) {
3247                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3248                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3249             }
3250         }
3251 
3252         assertReductionArraysEqualsMasked(r, ra, a, mask,
3253                 Short256VectorTests::MULReduceMasked, Short256VectorTests::MULReduceAllMasked);
3254     }
3255     static short MINReduce(short[] a, int idx) {
3256         short res = Short.MAX_VALUE;
3257         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3258             res = (short)Math.min(res, a[i]);
3259         }
3260 
3261         return res;
3262     }
3263 
3264     static short MINReduceAll(short[] a) {
3265         short res = Short.MAX_VALUE;
3266         for (int i = 0; i < a.length; i++) {
3267             res = (short)Math.min(res, a[i]);
3268         }
3269 
3270         return res;
3271     }
3272     @Test(dataProvider = "shortUnaryOpProvider")
3273     static void MINReduceShort256VectorTests(IntFunction<short[]> fa) {
3274         short[] a = fa.apply(SPECIES.length());
3275         short[] r = fr.apply(SPECIES.length());
3276         short ra = Short.MAX_VALUE;
3277 
3278         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3279             for (int i = 0; i < a.length; i += SPECIES.length()) {
3280                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3281                 r[i] = av.reduceLanes(VectorOperators.MIN);
3282             }
3283         }
3284 
3285         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3286             ra = Short.MAX_VALUE;
3287             for (int i = 0; i < a.length; i += SPECIES.length()) {
3288                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3289                 ra = (short)Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3290             }
3291         }
3292 
3293         assertReductionArraysEquals(r, ra, a,
3294                 Short256VectorTests::MINReduce, Short256VectorTests::MINReduceAll);
3295     }
3296     static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
3297         short res = Short.MAX_VALUE;
3298         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3299             if(mask[i % SPECIES.length()])
3300                 res = (short)Math.min(res, a[i]);
3301         }
3302 
3303         return res;
3304     }
3305 
3306     static short MINReduceAllMasked(short[] a, boolean[] mask) {
3307         short res = Short.MAX_VALUE;
3308         for (int i = 0; i < a.length; i++) {
3309             if(mask[i % SPECIES.length()])
3310                 res = (short)Math.min(res, a[i]);
3311         }
3312 
3313         return res;
3314     }
3315     @Test(dataProvider = "shortUnaryOpMaskProvider")
3316     static void MINReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3317         short[] a = fa.apply(SPECIES.length());
3318         short[] r = fr.apply(SPECIES.length());
3319         boolean[] mask = fm.apply(SPECIES.length());
3320         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3321         short ra = Short.MAX_VALUE;
3322 
3323         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3324             for (int i = 0; i < a.length; i += SPECIES.length()) {
3325                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3326                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3327             }
3328         }
3329 
3330         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3331             ra = Short.MAX_VALUE;
3332             for (int i = 0; i < a.length; i += SPECIES.length()) {
3333                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3334                 ra = (short)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3335             }
3336         }
3337 
3338         assertReductionArraysEqualsMasked(r, ra, a, mask,
3339                 Short256VectorTests::MINReduceMasked, Short256VectorTests::MINReduceAllMasked);
3340     }
3341     static short MAXReduce(short[] a, int idx) {
3342         short res = Short.MIN_VALUE;
3343         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3344             res = (short)Math.max(res, a[i]);
3345         }
3346 
3347         return res;
3348     }
3349 
3350     static short MAXReduceAll(short[] a) {
3351         short res = Short.MIN_VALUE;
3352         for (int i = 0; i < a.length; i++) {
3353             res = (short)Math.max(res, a[i]);
3354         }
3355 
3356         return res;
3357     }
3358     @Test(dataProvider = "shortUnaryOpProvider")
3359     static void MAXReduceShort256VectorTests(IntFunction<short[]> fa) {
3360         short[] a = fa.apply(SPECIES.length());
3361         short[] r = fr.apply(SPECIES.length());
3362         short ra = Short.MIN_VALUE;
3363 
3364         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3365             for (int i = 0; i < a.length; i += SPECIES.length()) {
3366                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3367                 r[i] = av.reduceLanes(VectorOperators.MAX);
3368             }
3369         }
3370 
3371         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3372             ra = Short.MIN_VALUE;
3373             for (int i = 0; i < a.length; i += SPECIES.length()) {
3374                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3375                 ra = (short)Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3376             }
3377         }
3378 
3379         assertReductionArraysEquals(r, ra, a,
3380                 Short256VectorTests::MAXReduce, Short256VectorTests::MAXReduceAll);
3381     }
3382     static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
3383         short res = Short.MIN_VALUE;
3384         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3385             if(mask[i % SPECIES.length()])
3386                 res = (short)Math.max(res, a[i]);
3387         }
3388 
3389         return res;
3390     }
3391 
3392     static short MAXReduceAllMasked(short[] a, boolean[] mask) {
3393         short res = Short.MIN_VALUE;
3394         for (int i = 0; i < a.length; i++) {
3395             if(mask[i % SPECIES.length()])
3396                 res = (short)Math.max(res, a[i]);
3397         }
3398 
3399         return res;
3400     }
3401     @Test(dataProvider = "shortUnaryOpMaskProvider")
3402     static void MAXReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3403         short[] a = fa.apply(SPECIES.length());
3404         short[] r = fr.apply(SPECIES.length());
3405         boolean[] mask = fm.apply(SPECIES.length());
3406         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3407         short ra = Short.MIN_VALUE;
3408 
3409         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3410             for (int i = 0; i < a.length; i += SPECIES.length()) {
3411                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3412                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3413             }
3414         }
3415 
3416         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3417             ra = Short.MIN_VALUE;
3418             for (int i = 0; i < a.length; i += SPECIES.length()) {
3419                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3420                 ra = (short)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3421             }
3422         }
3423 
3424         assertReductionArraysEqualsMasked(r, ra, a, mask,
3425                 Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked);
3426     }
3427 
3428     static boolean anyTrue(boolean[] a, int idx) {
3429         boolean res = false;
3430         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3431             res |= a[i];
3432         }
3433 
3434         return res;
3435     }
3436 
3437 
3438     @Test(dataProvider = "boolUnaryOpProvider")
3439     static void anyTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3440         boolean[] mask = fm.apply(SPECIES.length());
3441         boolean[] r = fmr.apply(SPECIES.length());
3442 
3443         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3444             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3445                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3446                 r[i] = vmask.anyTrue();
3447             }
3448         }
3449 
3450         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::anyTrue);
3451     }
3452 
3453 
3454     static boolean allTrue(boolean[] a, int idx) {
3455         boolean res = true;
3456         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3457             res &= a[i];
3458         }
3459 
3460         return res;
3461     }
3462 
3463 
3464     @Test(dataProvider = "boolUnaryOpProvider")
3465     static void allTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3466         boolean[] mask = fm.apply(SPECIES.length());
3467         boolean[] r = fmr.apply(SPECIES.length());
3468 
3469         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3470             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3471                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3472                 r[i] = vmask.allTrue();
3473             }
3474         }
3475 
3476         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue);
3477     }
3478 
3479 
3480     @Test(dataProvider = "shortUnaryOpProvider")
3481     static void withShort256VectorTests(IntFunction<short []> fa) {
3482         short[] a = fa.apply(SPECIES.length());
3483         short[] r = fr.apply(SPECIES.length());
3484 
3485         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3486             for (int i = 0; i < a.length; i += SPECIES.length()) {
3487                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3488                 av.withLane(0, (short)4).intoArray(r, i);
3489             }
3490         }
3491 
3492         assertInsertArraysEquals(r, a, (short)4, 0);
3493     }
3494     static boolean testIS_DEFAULT(short a) {
3495         return bits(a)==0;
3496     }
3497 
3498     @Test(dataProvider = "shortTestOpProvider")
3499     static void IS_DEFAULTShort256VectorTests(IntFunction<short[]> fa) {
3500         short[] a = fa.apply(SPECIES.length());
3501 
3502         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3503             for (int i = 0; i < a.length; i += SPECIES.length()) {
3504                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3505                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT);
3506 
3507                 // Check results as part of computation.
3508                 for (int j = 0; j < SPECIES.length(); j++) {
3509                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3510                 }
3511             }
3512         }
3513     }
3514 
3515     @Test(dataProvider = "shortTestOpMaskProvider")
3516     static void IS_DEFAULTMaskedShort256VectorTestsSmokeTest(IntFunction<short[]> fa,
3517                                           IntFunction<boolean[]> fm) {
3518         short[] a = fa.apply(SPECIES.length());
3519         boolean[] mask = fm.apply(SPECIES.length());
3520         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3521 
3522         for (int i = 0; i < a.length; i += SPECIES.length()) {
3523             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3524             VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3525 
3526             // Check results as part of computation.
3527             for (int j = 0; j < SPECIES.length(); j++) {
3528                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3529             }
3530         }
3531     }
3532     static boolean testIS_NEGATIVE(short a) {
3533         return bits(a)<0;
3534     }
3535 
3536     @Test(dataProvider = "shortTestOpProvider")
3537     static void IS_NEGATIVEShort256VectorTests(IntFunction<short[]> fa) {
3538         short[] a = fa.apply(SPECIES.length());
3539 
3540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3541             for (int i = 0; i < a.length; i += SPECIES.length()) {
3542                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3543                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE);
3544 
3545                 // Check results as part of computation.
3546                 for (int j = 0; j < SPECIES.length(); j++) {
3547                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3548                 }
3549             }
3550         }
3551     }
3552 
3553     @Test(dataProvider = "shortTestOpMaskProvider")
3554     static void IS_NEGATIVEMaskedShort256VectorTestsSmokeTest(IntFunction<short[]> fa,
3555                                           IntFunction<boolean[]> fm) {
3556         short[] a = fa.apply(SPECIES.length());
3557         boolean[] mask = fm.apply(SPECIES.length());
3558         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3559 
3560         for (int i = 0; i < a.length; i += SPECIES.length()) {
3561             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3562             VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3563 
3564             // Check results as part of computation.
3565             for (int j = 0; j < SPECIES.length(); j++) {
3566                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3567             }
3568         }
3569     }
3570 
3571 
3572 
3573 
3574     @Test(dataProvider = "shortCompareOpProvider")
3575     static void LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3576         short[] a = fa.apply(SPECIES.length());
3577         short[] b = fb.apply(SPECIES.length());
3578 
3579         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3580             for (int i = 0; i < a.length; i += SPECIES.length()) {
3581                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3582                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3583                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv);
3584 
3585                 // Check results as part of computation.
3586                 for (int j = 0; j < SPECIES.length(); j++) {
3587                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3588                 }
3589             }
3590         }
3591     }
3592 
3593 
3594     @Test(dataProvider = "shortCompareOpProvider")
3595     static void ltShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3596         short[] a = fa.apply(SPECIES.length());
3597         short[] b = fb.apply(SPECIES.length());
3598 
3599         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3600             for (int i = 0; i < a.length; i += SPECIES.length()) {
3601                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3602                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3603                 VectorMask<Short> mv = av.lt(bv);
3604 
3605                 // Check results as part of computation.
3606                 for (int j = 0; j < SPECIES.length(); j++) {
3607                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3608                 }
3609             }
3610         }
3611     }
3612 
3613     @Test(dataProvider = "shortCompareOpMaskProvider")
3614     static void LTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3615                                                 IntFunction<boolean[]> fm) {
3616         short[] a = fa.apply(SPECIES.length());
3617         short[] b = fb.apply(SPECIES.length());
3618         boolean[] mask = fm.apply(SPECIES.length());
3619 
3620         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3621 
3622         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3623             for (int i = 0; i < a.length; i += SPECIES.length()) {
3624                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3625                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3626                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask);
3627 
3628                 // Check results as part of computation.
3629                 for (int j = 0; j < SPECIES.length(); j++) {
3630                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3631                 }
3632             }
3633         }
3634     }
3635 
3636 
3637     @Test(dataProvider = "shortCompareOpProvider")
3638     static void GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3639         short[] a = fa.apply(SPECIES.length());
3640         short[] b = fb.apply(SPECIES.length());
3641 
3642         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3643             for (int i = 0; i < a.length; i += SPECIES.length()) {
3644                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3645                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3646                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv);
3647 
3648                 // Check results as part of computation.
3649                 for (int j = 0; j < SPECIES.length(); j++) {
3650                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3651                 }
3652             }
3653         }
3654     }
3655 
3656     @Test(dataProvider = "shortCompareOpMaskProvider")
3657     static void GTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3658                                                 IntFunction<boolean[]> fm) {
3659         short[] a = fa.apply(SPECIES.length());
3660         short[] b = fb.apply(SPECIES.length());
3661         boolean[] mask = fm.apply(SPECIES.length());
3662 
3663         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3664 
3665         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3666             for (int i = 0; i < a.length; i += SPECIES.length()) {
3667                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3668                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3669                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask);
3670 
3671                 // Check results as part of computation.
3672                 for (int j = 0; j < SPECIES.length(); j++) {
3673                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3674                 }
3675             }
3676         }
3677     }
3678 
3679 
3680     @Test(dataProvider = "shortCompareOpProvider")
3681     static void EQShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3682         short[] a = fa.apply(SPECIES.length());
3683         short[] b = fb.apply(SPECIES.length());
3684 
3685         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3686             for (int i = 0; i < a.length; i += SPECIES.length()) {
3687                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3688                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3689                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv);
3690 
3691                 // Check results as part of computation.
3692                 for (int j = 0; j < SPECIES.length(); j++) {
3693                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3694                 }
3695             }
3696         }
3697     }
3698 
3699 
3700     @Test(dataProvider = "shortCompareOpProvider")
3701     static void eqShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3702         short[] a = fa.apply(SPECIES.length());
3703         short[] b = fb.apply(SPECIES.length());
3704 
3705         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3706             for (int i = 0; i < a.length; i += SPECIES.length()) {
3707                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3708                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3709                 VectorMask<Short> mv = av.eq(bv);
3710 
3711                 // Check results as part of computation.
3712                 for (int j = 0; j < SPECIES.length(); j++) {
3713                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3714                 }
3715             }
3716         }
3717     }
3718 
3719     @Test(dataProvider = "shortCompareOpMaskProvider")
3720     static void EQShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3721                                                 IntFunction<boolean[]> fm) {
3722         short[] a = fa.apply(SPECIES.length());
3723         short[] b = fb.apply(SPECIES.length());
3724         boolean[] mask = fm.apply(SPECIES.length());
3725 
3726         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3727 
3728         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3729             for (int i = 0; i < a.length; i += SPECIES.length()) {
3730                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3731                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3732                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask);
3733 
3734                 // Check results as part of computation.
3735                 for (int j = 0; j < SPECIES.length(); j++) {
3736                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3737                 }
3738             }
3739         }
3740     }
3741 
3742 
3743     @Test(dataProvider = "shortCompareOpProvider")
3744     static void NEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3745         short[] a = fa.apply(SPECIES.length());
3746         short[] b = fb.apply(SPECIES.length());
3747 
3748         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3749             for (int i = 0; i < a.length; i += SPECIES.length()) {
3750                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3751                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3752                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv);
3753 
3754                 // Check results as part of computation.
3755                 for (int j = 0; j < SPECIES.length(); j++) {
3756                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3757                 }
3758             }
3759         }
3760     }
3761 
3762     @Test(dataProvider = "shortCompareOpMaskProvider")
3763     static void NEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3764                                                 IntFunction<boolean[]> fm) {
3765         short[] a = fa.apply(SPECIES.length());
3766         short[] b = fb.apply(SPECIES.length());
3767         boolean[] mask = fm.apply(SPECIES.length());
3768 
3769         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3770 
3771         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3772             for (int i = 0; i < a.length; i += SPECIES.length()) {
3773                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3774                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3775                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask);
3776 
3777                 // Check results as part of computation.
3778                 for (int j = 0; j < SPECIES.length(); j++) {
3779                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3780                 }
3781             }
3782         }
3783     }
3784 
3785 
3786     @Test(dataProvider = "shortCompareOpProvider")
3787     static void LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3788         short[] a = fa.apply(SPECIES.length());
3789         short[] b = fb.apply(SPECIES.length());
3790 
3791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3792             for (int i = 0; i < a.length; i += SPECIES.length()) {
3793                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3794                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3795                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv);
3796 
3797                 // Check results as part of computation.
3798                 for (int j = 0; j < SPECIES.length(); j++) {
3799                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3800                 }
3801             }
3802         }
3803     }
3804 
3805     @Test(dataProvider = "shortCompareOpMaskProvider")
3806     static void LEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3807                                                 IntFunction<boolean[]> fm) {
3808         short[] a = fa.apply(SPECIES.length());
3809         short[] b = fb.apply(SPECIES.length());
3810         boolean[] mask = fm.apply(SPECIES.length());
3811 
3812         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3813 
3814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3815             for (int i = 0; i < a.length; i += SPECIES.length()) {
3816                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3817                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3818                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask);
3819 
3820                 // Check results as part of computation.
3821                 for (int j = 0; j < SPECIES.length(); j++) {
3822                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3823                 }
3824             }
3825         }
3826     }
3827 
3828 
3829     @Test(dataProvider = "shortCompareOpProvider")
3830     static void GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3831         short[] a = fa.apply(SPECIES.length());
3832         short[] b = fb.apply(SPECIES.length());
3833 
3834         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3835             for (int i = 0; i < a.length; i += SPECIES.length()) {
3836                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3837                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3838                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv);
3839 
3840                 // Check results as part of computation.
3841                 for (int j = 0; j < SPECIES.length(); j++) {
3842                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3843                 }
3844             }
3845         }
3846     }
3847 
3848     @Test(dataProvider = "shortCompareOpMaskProvider")
3849     static void GEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3850                                                 IntFunction<boolean[]> fm) {
3851         short[] a = fa.apply(SPECIES.length());
3852         short[] b = fb.apply(SPECIES.length());
3853         boolean[] mask = fm.apply(SPECIES.length());
3854 
3855         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3856 
3857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3858             for (int i = 0; i < a.length; i += SPECIES.length()) {
3859                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3860                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3861                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask);
3862 
3863                 // Check results as part of computation.
3864                 for (int j = 0; j < SPECIES.length(); j++) {
3865                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3866                 }
3867             }
3868         }
3869     }
3870 
3871 
3872 
3873     @Test(dataProvider = "shortCompareOpProvider")
3874     static void UNSIGNED_LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3875         short[] a = fa.apply(SPECIES.length());
3876         short[] b = fb.apply(SPECIES.length());
3877 
3878         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3879             for (int i = 0; i < a.length; i += SPECIES.length()) {
3880                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3881                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3882                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
3883 
3884                 // Check results as part of computation.
3885                 for (int j = 0; j < SPECIES.length(); j++) {
3886                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
3887                 }
3888             }
3889         }
3890     }
3891 
3892 
3893 
3894     @Test(dataProvider = "shortCompareOpMaskProvider")
3895     static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3896                                                 IntFunction<boolean[]> fm) {
3897         short[] a = fa.apply(SPECIES.length());
3898         short[] b = fb.apply(SPECIES.length());
3899         boolean[] mask = fm.apply(SPECIES.length());
3900 
3901         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3902 
3903         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3904             for (int i = 0; i < a.length; i += SPECIES.length()) {
3905                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3906                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3907                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
3908 
3909                 // Check results as part of computation.
3910                 for (int j = 0; j < SPECIES.length(); j++) {
3911                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
3912                 }
3913             }
3914         }
3915     }
3916 
3917 
3918 
3919 
3920     @Test(dataProvider = "shortCompareOpProvider")
3921     static void UNSIGNED_GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3922         short[] a = fa.apply(SPECIES.length());
3923         short[] b = fb.apply(SPECIES.length());
3924 
3925         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3926             for (int i = 0; i < a.length; i += SPECIES.length()) {
3927                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3928                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3929                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
3930 
3931                 // Check results as part of computation.
3932                 for (int j = 0; j < SPECIES.length(); j++) {
3933                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
3934                 }
3935             }
3936         }
3937     }
3938 
3939 
3940 
3941     @Test(dataProvider = "shortCompareOpMaskProvider")
3942     static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3943                                                 IntFunction<boolean[]> fm) {
3944         short[] a = fa.apply(SPECIES.length());
3945         short[] b = fb.apply(SPECIES.length());
3946         boolean[] mask = fm.apply(SPECIES.length());
3947 
3948         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3949 
3950         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3951             for (int i = 0; i < a.length; i += SPECIES.length()) {
3952                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3953                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3954                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
3955 
3956                 // Check results as part of computation.
3957                 for (int j = 0; j < SPECIES.length(); j++) {
3958                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
3959                 }
3960             }
3961         }
3962     }
3963 
3964 
3965 
3966 
3967     @Test(dataProvider = "shortCompareOpProvider")
3968     static void UNSIGNED_LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3969         short[] a = fa.apply(SPECIES.length());
3970         short[] b = fb.apply(SPECIES.length());
3971 
3972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3973             for (int i = 0; i < a.length; i += SPECIES.length()) {
3974                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3975                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3976                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
3977 
3978                 // Check results as part of computation.
3979                 for (int j = 0; j < SPECIES.length(); j++) {
3980                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
3981                 }
3982             }
3983         }
3984     }
3985 
3986 
3987 
3988     @Test(dataProvider = "shortCompareOpMaskProvider")
3989     static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3990                                                 IntFunction<boolean[]> fm) {
3991         short[] a = fa.apply(SPECIES.length());
3992         short[] b = fb.apply(SPECIES.length());
3993         boolean[] mask = fm.apply(SPECIES.length());
3994 
3995         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3996 
3997         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3998             for (int i = 0; i < a.length; i += SPECIES.length()) {
3999                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4000                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4001                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4002 
4003                 // Check results as part of computation.
4004                 for (int j = 0; j < SPECIES.length(); j++) {
4005                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4006                 }
4007             }
4008         }
4009     }
4010 
4011 
4012 
4013 
4014     @Test(dataProvider = "shortCompareOpProvider")
4015     static void UNSIGNED_GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4016         short[] a = fa.apply(SPECIES.length());
4017         short[] b = fb.apply(SPECIES.length());
4018 
4019         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4020             for (int i = 0; i < a.length; i += SPECIES.length()) {
4021                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4022                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4023                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4024 
4025                 // Check results as part of computation.
4026                 for (int j = 0; j < SPECIES.length(); j++) {
4027                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4028                 }
4029             }
4030         }
4031     }
4032 
4033 
4034 
4035     @Test(dataProvider = "shortCompareOpMaskProvider")
4036     static void UNSIGNED_GEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4037                                                 IntFunction<boolean[]> fm) {
4038         short[] a = fa.apply(SPECIES.length());
4039         short[] b = fb.apply(SPECIES.length());
4040         boolean[] mask = fm.apply(SPECIES.length());
4041 
4042         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4043 
4044         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4045             for (int i = 0; i < a.length; i += SPECIES.length()) {
4046                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4047                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4048                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4049 
4050                 // Check results as part of computation.
4051                 for (int j = 0; j < SPECIES.length(); j++) {
4052                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4053                 }
4054             }
4055         }
4056     }
4057 
4058 
4059 
4060     @Test(dataProvider = "shortCompareOpProvider")
4061     static void LTShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4062         short[] a = fa.apply(SPECIES.length());
4063         short[] b = fb.apply(SPECIES.length());
4064 
4065         for (int i = 0; i < a.length; i += SPECIES.length()) {
4066             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4067             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]);
4068 
4069             // Check results as part of computation.
4070             for (int j = 0; j < SPECIES.length(); j++) {
4071                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4072             }
4073         }
4074     }
4075 
4076 
4077     @Test(dataProvider = "shortCompareOpMaskProvider")
4078     static void LTShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4079                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4080         short[] a = fa.apply(SPECIES.length());
4081         short[] b = fb.apply(SPECIES.length());
4082         boolean[] mask = fm.apply(SPECIES.length());
4083 
4084         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4085 
4086         for (int i = 0; i < a.length; i += SPECIES.length()) {
4087             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4088             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask);
4089 
4090             // Check results as part of computation.
4091             for (int j = 0; j < SPECIES.length(); j++) {
4092                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4093             }
4094         }
4095     }
4096 
4097     @Test(dataProvider = "shortCompareOpProvider")
4098     static void LTShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4099         short[] a = fa.apply(SPECIES.length());
4100         short[] b = fb.apply(SPECIES.length());
4101 
4102         for (int i = 0; i < a.length; i += SPECIES.length()) {
4103             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4104             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]);
4105 
4106             // Check results as part of computation.
4107             for (int j = 0; j < SPECIES.length(); j++) {
4108                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
4109             }
4110         }
4111     }
4112 
4113 
4114     @Test(dataProvider = "shortCompareOpMaskProvider")
4115     static void LTShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4116                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4117         short[] a = fa.apply(SPECIES.length());
4118         short[] b = fb.apply(SPECIES.length());
4119         boolean[] mask = fm.apply(SPECIES.length());
4120 
4121         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4122 
4123         for (int i = 0; i < a.length; i += SPECIES.length()) {
4124             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4125             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4126 
4127             // Check results as part of computation.
4128             for (int j = 0; j < SPECIES.length(); j++) {
4129                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i])));
4130             }
4131         }
4132     }
4133 
4134     @Test(dataProvider = "shortCompareOpProvider")
4135     static void EQShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4136         short[] a = fa.apply(SPECIES.length());
4137         short[] b = fb.apply(SPECIES.length());
4138 
4139         for (int i = 0; i < a.length; i += SPECIES.length()) {
4140             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4141             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]);
4142 
4143             // Check results as part of computation.
4144             for (int j = 0; j < SPECIES.length(); j++) {
4145                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4146             }
4147         }
4148     }
4149 
4150 
4151     @Test(dataProvider = "shortCompareOpMaskProvider")
4152     static void EQShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4153                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4154         short[] a = fa.apply(SPECIES.length());
4155         short[] b = fb.apply(SPECIES.length());
4156         boolean[] mask = fm.apply(SPECIES.length());
4157 
4158         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4159 
4160         for (int i = 0; i < a.length; i += SPECIES.length()) {
4161             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4162             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4163 
4164             // Check results as part of computation.
4165             for (int j = 0; j < SPECIES.length(); j++) {
4166                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4167             }
4168         }
4169     }
4170 
4171     @Test(dataProvider = "shortCompareOpProvider")
4172     static void EQShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4173         short[] a = fa.apply(SPECIES.length());
4174         short[] b = fb.apply(SPECIES.length());
4175 
4176         for (int i = 0; i < a.length; i += SPECIES.length()) {
4177             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4178             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4179 
4180             // Check results as part of computation.
4181             for (int j = 0; j < SPECIES.length(); j++) {
4182                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
4183             }
4184         }
4185     }
4186 
4187 
4188     @Test(dataProvider = "shortCompareOpMaskProvider")
4189     static void EQShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4190                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4191         short[] a = fa.apply(SPECIES.length());
4192         short[] b = fb.apply(SPECIES.length());
4193         boolean[] mask = fm.apply(SPECIES.length());
4194 
4195         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4196 
4197         for (int i = 0; i < a.length; i += SPECIES.length()) {
4198             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4199             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4200 
4201             // Check results as part of computation.
4202             for (int j = 0; j < SPECIES.length(); j++) {
4203                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i])));
4204             }
4205         }
4206     }
4207 
4208     static short blend(short a, short b, boolean mask) {
4209         return mask ? b : a;
4210     }
4211 
4212     @Test(dataProvider = "shortBinaryOpMaskProvider")
4213     static void blendShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
4214                                           IntFunction<boolean[]> fm) {
4215         short[] a = fa.apply(SPECIES.length());
4216         short[] b = fb.apply(SPECIES.length());
4217         short[] r = fr.apply(SPECIES.length());
4218         boolean[] mask = fm.apply(SPECIES.length());
4219         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4220 
4221         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4222             for (int i = 0; i < a.length; i += SPECIES.length()) {
4223                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4224                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4225                 av.blend(bv, vmask).intoArray(r, i);
4226             }
4227         }
4228 
4229         assertArraysEquals(r, a, b, mask, Short256VectorTests::blend);
4230     }
4231 
4232     @Test(dataProvider = "shortUnaryOpShuffleProvider")
4233     static void RearrangeShort256VectorTests(IntFunction<short[]> fa,
4234                                            BiFunction<Integer,Integer,int[]> fs) {
4235         short[] a = fa.apply(SPECIES.length());
4236         int[] order = fs.apply(a.length, SPECIES.length());
4237         short[] r = fr.apply(SPECIES.length());
4238 
4239         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4240             for (int i = 0; i < a.length; i += SPECIES.length()) {
4241                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4242                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
4243             }
4244         }
4245 
4246         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4247     }
4248 
4249     @Test(dataProvider = "shortUnaryOpShuffleMaskProvider")
4250     static void RearrangeShort256VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
4251                                                           BiFunction<Integer,Integer,int[]> fs,
4252                                                           IntFunction<boolean[]> fm) {
4253         short[] a = fa.apply(SPECIES.length());
4254         int[] order = fs.apply(a.length, SPECIES.length());
4255         short[] r = fr.apply(SPECIES.length());
4256         boolean[] mask = fm.apply(SPECIES.length());
4257         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4258 
4259         for (int i = 0; i < a.length; i += SPECIES.length()) {
4260             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4261             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4262         }
4263 
4264         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4265     }
4266 
4267     @Test(dataProvider = "shortUnaryOpMaskProvider")
4268     static void compressShort256VectorTests(IntFunction<short[]> fa,
4269                                                 IntFunction<boolean[]> fm) {
4270         short[] a = fa.apply(SPECIES.length());
4271         short[] r = fr.apply(SPECIES.length());
4272         boolean[] mask = fm.apply(SPECIES.length());
4273         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4274 
4275         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4276             for (int i = 0; i < a.length; i += SPECIES.length()) {
4277                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4278                 av.compress(vmask).intoArray(r, i);
4279             }
4280         }
4281 
4282         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4283     }
4284 
4285     @Test(dataProvider = "shortUnaryOpMaskProvider")
4286     static void expandShort256VectorTests(IntFunction<short[]> fa,
4287                                                 IntFunction<boolean[]> fm) {
4288         short[] a = fa.apply(SPECIES.length());
4289         short[] r = fr.apply(SPECIES.length());
4290         boolean[] mask = fm.apply(SPECIES.length());
4291         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4292 
4293         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4294             for (int i = 0; i < a.length; i += SPECIES.length()) {
4295                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4296                 av.expand(vmask).intoArray(r, i);
4297             }
4298         }
4299 
4300         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4301     }
4302     @Test(dataProvider = "shortUnaryOpProvider")
4303     static void getShort256VectorTests(IntFunction<short[]> fa) {
4304         short[] a = fa.apply(SPECIES.length());
4305         short[] r = fr.apply(SPECIES.length());
4306 
4307         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4308             for (int i = 0; i < a.length; i += SPECIES.length()) {
4309                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4310                 int num_lanes = SPECIES.length();
4311                 // Manually unroll because full unroll happens after intrinsification.
4312                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4313                 if (num_lanes == 1) {
4314                     r[i]=av.lane(0);
4315                 } else if (num_lanes == 2) {
4316                     r[i]=av.lane(0);
4317                     r[i+1]=av.lane(1);
4318                 } else if (num_lanes == 4) {
4319                     r[i]=av.lane(0);
4320                     r[i+1]=av.lane(1);
4321                     r[i+2]=av.lane(2);
4322                     r[i+3]=av.lane(3);
4323                 } else if (num_lanes == 8) {
4324                     r[i]=av.lane(0);
4325                     r[i+1]=av.lane(1);
4326                     r[i+2]=av.lane(2);
4327                     r[i+3]=av.lane(3);
4328                     r[i+4]=av.lane(4);
4329                     r[i+5]=av.lane(5);
4330                     r[i+6]=av.lane(6);
4331                     r[i+7]=av.lane(7);
4332                 } else if (num_lanes == 16) {
4333                     r[i]=av.lane(0);
4334                     r[i+1]=av.lane(1);
4335                     r[i+2]=av.lane(2);
4336                     r[i+3]=av.lane(3);
4337                     r[i+4]=av.lane(4);
4338                     r[i+5]=av.lane(5);
4339                     r[i+6]=av.lane(6);
4340                     r[i+7]=av.lane(7);
4341                     r[i+8]=av.lane(8);
4342                     r[i+9]=av.lane(9);
4343                     r[i+10]=av.lane(10);
4344                     r[i+11]=av.lane(11);
4345                     r[i+12]=av.lane(12);
4346                     r[i+13]=av.lane(13);
4347                     r[i+14]=av.lane(14);
4348                     r[i+15]=av.lane(15);
4349                 } else if (num_lanes == 32) {
4350                     r[i]=av.lane(0);
4351                     r[i+1]=av.lane(1);
4352                     r[i+2]=av.lane(2);
4353                     r[i+3]=av.lane(3);
4354                     r[i+4]=av.lane(4);
4355                     r[i+5]=av.lane(5);
4356                     r[i+6]=av.lane(6);
4357                     r[i+7]=av.lane(7);
4358                     r[i+8]=av.lane(8);
4359                     r[i+9]=av.lane(9);
4360                     r[i+10]=av.lane(10);
4361                     r[i+11]=av.lane(11);
4362                     r[i+12]=av.lane(12);
4363                     r[i+13]=av.lane(13);
4364                     r[i+14]=av.lane(14);
4365                     r[i+15]=av.lane(15);
4366                     r[i+16]=av.lane(16);
4367                     r[i+17]=av.lane(17);
4368                     r[i+18]=av.lane(18);
4369                     r[i+19]=av.lane(19);
4370                     r[i+20]=av.lane(20);
4371                     r[i+21]=av.lane(21);
4372                     r[i+22]=av.lane(22);
4373                     r[i+23]=av.lane(23);
4374                     r[i+24]=av.lane(24);
4375                     r[i+25]=av.lane(25);
4376                     r[i+26]=av.lane(26);
4377                     r[i+27]=av.lane(27);
4378                     r[i+28]=av.lane(28);
4379                     r[i+29]=av.lane(29);
4380                     r[i+30]=av.lane(30);
4381                     r[i+31]=av.lane(31);
4382                 } else if (num_lanes == 64) {
4383                     r[i]=av.lane(0);
4384                     r[i+1]=av.lane(1);
4385                     r[i+2]=av.lane(2);
4386                     r[i+3]=av.lane(3);
4387                     r[i+4]=av.lane(4);
4388                     r[i+5]=av.lane(5);
4389                     r[i+6]=av.lane(6);
4390                     r[i+7]=av.lane(7);
4391                     r[i+8]=av.lane(8);
4392                     r[i+9]=av.lane(9);
4393                     r[i+10]=av.lane(10);
4394                     r[i+11]=av.lane(11);
4395                     r[i+12]=av.lane(12);
4396                     r[i+13]=av.lane(13);
4397                     r[i+14]=av.lane(14);
4398                     r[i+15]=av.lane(15);
4399                     r[i+16]=av.lane(16);
4400                     r[i+17]=av.lane(17);
4401                     r[i+18]=av.lane(18);
4402                     r[i+19]=av.lane(19);
4403                     r[i+20]=av.lane(20);
4404                     r[i+21]=av.lane(21);
4405                     r[i+22]=av.lane(22);
4406                     r[i+23]=av.lane(23);
4407                     r[i+24]=av.lane(24);
4408                     r[i+25]=av.lane(25);
4409                     r[i+26]=av.lane(26);
4410                     r[i+27]=av.lane(27);
4411                     r[i+28]=av.lane(28);
4412                     r[i+29]=av.lane(29);
4413                     r[i+30]=av.lane(30);
4414                     r[i+31]=av.lane(31);
4415                     r[i+32]=av.lane(32);
4416                     r[i+33]=av.lane(33);
4417                     r[i+34]=av.lane(34);
4418                     r[i+35]=av.lane(35);
4419                     r[i+36]=av.lane(36);
4420                     r[i+37]=av.lane(37);
4421                     r[i+38]=av.lane(38);
4422                     r[i+39]=av.lane(39);
4423                     r[i+40]=av.lane(40);
4424                     r[i+41]=av.lane(41);
4425                     r[i+42]=av.lane(42);
4426                     r[i+43]=av.lane(43);
4427                     r[i+44]=av.lane(44);
4428                     r[i+45]=av.lane(45);
4429                     r[i+46]=av.lane(46);
4430                     r[i+47]=av.lane(47);
4431                     r[i+48]=av.lane(48);
4432                     r[i+49]=av.lane(49);
4433                     r[i+50]=av.lane(50);
4434                     r[i+51]=av.lane(51);
4435                     r[i+52]=av.lane(52);
4436                     r[i+53]=av.lane(53);
4437                     r[i+54]=av.lane(54);
4438                     r[i+55]=av.lane(55);
4439                     r[i+56]=av.lane(56);
4440                     r[i+57]=av.lane(57);
4441                     r[i+58]=av.lane(58);
4442                     r[i+59]=av.lane(59);
4443                     r[i+60]=av.lane(60);
4444                     r[i+61]=av.lane(61);
4445                     r[i+62]=av.lane(62);
4446                     r[i+63]=av.lane(63);
4447                 } else {
4448                     for (int j = 0; j < SPECIES.length(); j++) {
4449                         r[i+j]=av.lane(j);
4450                     }
4451                 }
4452             }
4453         }
4454 
4455         assertArraysEquals(r, a, Short256VectorTests::get);
4456     }
4457 
4458     @Test(dataProvider = "shortUnaryOpProvider")
4459     static void BroadcastShort256VectorTests(IntFunction<short[]> fa) {
4460         short[] a = fa.apply(SPECIES.length());
4461         short[] r = new short[a.length];
4462 
4463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4464             for (int i = 0; i < a.length; i += SPECIES.length()) {
4465                 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4466             }
4467         }
4468 
4469         assertBroadcastArraysEquals(r, a);
4470     }
4471 
4472 
4473 
4474 
4475 
4476     @Test(dataProvider = "shortUnaryOpProvider")
4477     static void ZeroShort256VectorTests(IntFunction<short[]> fa) {
4478         short[] a = fa.apply(SPECIES.length());
4479         short[] r = new short[a.length];
4480 
4481         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4482             for (int i = 0; i < a.length; i += SPECIES.length()) {
4483                 ShortVector.zero(SPECIES).intoArray(a, i);
4484             }
4485         }
4486 
4487         Assert.assertEquals(a, r);
4488     }
4489 
4490 
4491 
4492 
4493     static short[] sliceUnary(short[] a, int origin, int idx) {
4494         short[] res = new short[SPECIES.length()];
4495         for (int i = 0; i < SPECIES.length(); i++){
4496             if(i+origin < SPECIES.length())
4497                 res[i] = a[idx+i+origin];
4498             else
4499                 res[i] = (short)0;
4500         }
4501         return res;
4502     }
4503 
4504     @Test(dataProvider = "shortUnaryOpProvider")
4505     static void sliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4506         short[] a = fa.apply(SPECIES.length());
4507         short[] r = new short[a.length];
4508         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4509         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4510             for (int i = 0; i < a.length; i += SPECIES.length()) {
4511                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4512                 av.slice(origin).intoArray(r, i);
4513             }
4514         }
4515 
4516         assertArraysEquals(r, a, origin, Short256VectorTests::sliceUnary);
4517     }
4518     static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
4519         short[] res = new short[SPECIES.length()];
4520         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4521             if(i+origin < SPECIES.length())
4522                 res[i] = a[idx+i+origin];
4523             else {
4524                 res[i] = b[idx+j];
4525                 j++;
4526             }
4527         }
4528         return res;
4529     }
4530 
4531     @Test(dataProvider = "shortBinaryOpProvider")
4532     static void sliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4533         short[] a = fa.apply(SPECIES.length());
4534         short[] b = fb.apply(SPECIES.length());
4535         short[] r = new short[a.length];
4536         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4537         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4538             for (int i = 0; i < a.length; i += SPECIES.length()) {
4539                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4540                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4541                 av.slice(origin, bv).intoArray(r, i);
4542             }
4543         }
4544 
4545         assertArraysEquals(r, a, b, origin, Short256VectorTests::sliceBinary);
4546     }
4547     static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
4548         short[] res = new short[SPECIES.length()];
4549         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4550             if(i+origin < SPECIES.length())
4551                 res[i] = mask[i] ? a[idx+i+origin] : (short)0;
4552             else {
4553                 res[i] = mask[i] ? b[idx+j] : (short)0;
4554                 j++;
4555             }
4556         }
4557         return res;
4558     }
4559 
4560     @Test(dataProvider = "shortBinaryOpMaskProvider")
4561     static void sliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4562     IntFunction<boolean[]> fm) {
4563         short[] a = fa.apply(SPECIES.length());
4564         short[] b = fb.apply(SPECIES.length());
4565         boolean[] mask = fm.apply(SPECIES.length());
4566         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4567 
4568         short[] r = new short[a.length];
4569         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4570         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4571             for (int i = 0; i < a.length; i += SPECIES.length()) {
4572                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4573                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4574                 av.slice(origin, bv, vmask).intoArray(r, i);
4575             }
4576         }
4577 
4578         assertArraysEquals(r, a, b, origin, mask, Short256VectorTests::slice);
4579     }
4580     static short[] unsliceUnary(short[] a, int origin, int idx) {
4581         short[] res = new short[SPECIES.length()];
4582         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4583             if(i < origin)
4584                 res[i] = (short)0;
4585             else {
4586                 res[i] = a[idx+j];
4587                 j++;
4588             }
4589         }
4590         return res;
4591     }
4592 
4593     @Test(dataProvider = "shortUnaryOpProvider")
4594     static void unsliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4595         short[] a = fa.apply(SPECIES.length());
4596         short[] r = new short[a.length];
4597         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4598         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4599             for (int i = 0; i < a.length; i += SPECIES.length()) {
4600                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4601                 av.unslice(origin).intoArray(r, i);
4602             }
4603         }
4604 
4605         assertArraysEquals(r, a, origin, Short256VectorTests::unsliceUnary);
4606     }
4607     static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
4608         short[] res = new short[SPECIES.length()];
4609         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4610             if (part == 0) {
4611                 if (i < origin)
4612                     res[i] = b[idx+i];
4613                 else {
4614                     res[i] = a[idx+j];
4615                     j++;
4616                 }
4617             } else if (part == 1) {
4618                 if (i < origin)
4619                     res[i] = a[idx+SPECIES.length()-origin+i];
4620                 else {
4621                     res[i] = b[idx+origin+j];
4622                     j++;
4623                 }
4624             }
4625         }
4626         return res;
4627     }
4628 
4629     @Test(dataProvider = "shortBinaryOpProvider")
4630     static void unsliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4631         short[] a = fa.apply(SPECIES.length());
4632         short[] b = fb.apply(SPECIES.length());
4633         short[] r = new short[a.length];
4634         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4635         int part = (new java.util.Random()).nextInt(2);
4636         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4637             for (int i = 0; i < a.length; i += SPECIES.length()) {
4638                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4639                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4640                 av.unslice(origin, bv, part).intoArray(r, i);
4641             }
4642         }
4643 
4644         assertArraysEquals(r, a, b, origin, part, Short256VectorTests::unsliceBinary);
4645     }
4646     static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
4647         short[] res = new short[SPECIES.length()];
4648         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4649             if(i+origin < SPECIES.length())
4650                 res[i] = b[idx+i+origin];
4651             else {
4652                 res[i] = b[idx+j];
4653                 j++;
4654             }
4655         }
4656         for (int i = 0; i < SPECIES.length(); i++){
4657             res[i] = mask[i] ? a[idx+i] : res[i];
4658         }
4659         short[] res1 = new short[SPECIES.length()];
4660         if (part == 0) {
4661             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4662                 if (i < origin)
4663                     res1[i] = b[idx+i];
4664                 else {
4665                    res1[i] = res[j];
4666                    j++;
4667                 }
4668             }
4669         } else if (part == 1) {
4670             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4671                 if (i < origin)
4672                     res1[i] = res[SPECIES.length()-origin+i];
4673                 else {
4674                     res1[i] = b[idx+origin+j];
4675                     j++;
4676                 }
4677             }
4678         }
4679         return res1;
4680     }
4681 
4682     @Test(dataProvider = "shortBinaryOpMaskProvider")
4683     static void unsliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4684     IntFunction<boolean[]> fm) {
4685         short[] a = fa.apply(SPECIES.length());
4686         short[] b = fb.apply(SPECIES.length());
4687         boolean[] mask = fm.apply(SPECIES.length());
4688         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4689         short[] r = new short[a.length];
4690         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4691         int part = (new java.util.Random()).nextInt(2);
4692         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4693             for (int i = 0; i < a.length; i += SPECIES.length()) {
4694                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4695                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4696                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4697             }
4698         }
4699 
4700         assertArraysEquals(r, a, b, origin, part, mask, Short256VectorTests::unslice);
4701     }
4702 
4703 
4704 
4705 
4706 
4707 
4708 
4709 
4710 
4711 
4712 
4713 
4714 
4715 
4716 
4717 
4718 
4719 
4720 
4721 
4722 
4723 
4724 
4725     static short BITWISE_BLEND(short a, short b, short c) {
4726         return (short)((a&~(c))|(b&c));
4727     }
4728     static short bitwiseBlend(short a, short b, short c) {
4729         return (short)((a&~(c))|(b&c));
4730     }
4731 
4732 
4733     @Test(dataProvider = "shortTernaryOpProvider")
4734     static void BITWISE_BLENDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4735         short[] a = fa.apply(SPECIES.length());
4736         short[] b = fb.apply(SPECIES.length());
4737         short[] c = fc.apply(SPECIES.length());
4738         short[] r = fr.apply(SPECIES.length());
4739 
4740         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4741             for (int i = 0; i < a.length; i += SPECIES.length()) {
4742                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4743                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4744                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4745                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4746             }
4747         }
4748 
4749         assertArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
4750     }
4751     @Test(dataProvider = "shortTernaryOpProvider")
4752     static void bitwiseBlendShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4753         short[] a = fa.apply(SPECIES.length());
4754         short[] b = fb.apply(SPECIES.length());
4755         short[] c = fc.apply(SPECIES.length());
4756         short[] r = fr.apply(SPECIES.length());
4757 
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             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4762             av.bitwiseBlend(bv, cv).intoArray(r, i);
4763         }
4764 
4765         assertArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
4766     }
4767 
4768 
4769     @Test(dataProvider = "shortTernaryOpMaskProvider")
4770     static void BITWISE_BLENDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4771                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
4772         short[] a = fa.apply(SPECIES.length());
4773         short[] b = fb.apply(SPECIES.length());
4774         short[] c = fc.apply(SPECIES.length());
4775         short[] r = fr.apply(SPECIES.length());
4776         boolean[] mask = fm.apply(SPECIES.length());
4777         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4778 
4779         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4780             for (int i = 0; i < a.length; i += SPECIES.length()) {
4781                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4782                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4783                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4784                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4785             }
4786         }
4787 
4788         assertArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
4789     }
4790 
4791 
4792 
4793 
4794     @Test(dataProvider = "shortTernaryOpProvider")
4795     static void BITWISE_BLENDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4796         short[] a = fa.apply(SPECIES.length());
4797         short[] b = fb.apply(SPECIES.length());
4798         short[] c = fc.apply(SPECIES.length());
4799         short[] r = fr.apply(SPECIES.length());
4800 
4801         for (int i = 0; i < a.length; i += SPECIES.length()) {
4802             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4803             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4804             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
4805         }
4806         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
4807     }
4808 
4809     @Test(dataProvider = "shortTernaryOpProvider")
4810     static void BITWISE_BLENDShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4811         short[] a = fa.apply(SPECIES.length());
4812         short[] b = fb.apply(SPECIES.length());
4813         short[] c = fc.apply(SPECIES.length());
4814         short[] r = fr.apply(SPECIES.length());
4815 
4816         for (int i = 0; i < a.length; i += SPECIES.length()) {
4817             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4818             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4819             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
4820         }
4821         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
4822     }
4823     @Test(dataProvider = "shortTernaryOpProvider")
4824     static void bitwiseBlendShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4825         short[] a = fa.apply(SPECIES.length());
4826         short[] b = fb.apply(SPECIES.length());
4827         short[] c = fc.apply(SPECIES.length());
4828         short[] r = fr.apply(SPECIES.length());
4829 
4830         for (int i = 0; i < a.length; i += SPECIES.length()) {
4831             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4832             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4833             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
4834         }
4835         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
4836     }
4837 
4838     @Test(dataProvider = "shortTernaryOpProvider")
4839     static void bitwiseBlendShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4840         short[] a = fa.apply(SPECIES.length());
4841         short[] b = fb.apply(SPECIES.length());
4842         short[] c = fc.apply(SPECIES.length());
4843         short[] r = fr.apply(SPECIES.length());
4844 
4845         for (int i = 0; i < a.length; i += SPECIES.length()) {
4846             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4847             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4848             av.bitwiseBlend(b[i], cv).intoArray(r, i);
4849         }
4850         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
4851     }
4852 
4853 
4854     @Test(dataProvider = "shortTernaryOpMaskProvider")
4855     static void BITWISE_BLENDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
4856                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
4857         short[] a = fa.apply(SPECIES.length());
4858         short[] b = fb.apply(SPECIES.length());
4859         short[] c = fc.apply(SPECIES.length());
4860         short[] r = fr.apply(SPECIES.length());
4861         boolean[] mask = fm.apply(SPECIES.length());
4862         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4863 
4864         for (int i = 0; i < a.length; i += SPECIES.length()) {
4865             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4866             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4867             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
4868         }
4869 
4870         assertBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
4871     }
4872 
4873     @Test(dataProvider = "shortTernaryOpMaskProvider")
4874     static void BITWISE_BLENDShort256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
4875                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
4876         short[] a = fa.apply(SPECIES.length());
4877         short[] b = fb.apply(SPECIES.length());
4878         short[] c = fc.apply(SPECIES.length());
4879         short[] r = fr.apply(SPECIES.length());
4880         boolean[] mask = fm.apply(SPECIES.length());
4881         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4882 
4883         for (int i = 0; i < a.length; i += SPECIES.length()) {
4884             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4885             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4886             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
4887         }
4888 
4889         assertAltBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
4890     }
4891 
4892 
4893 
4894 
4895     @Test(dataProvider = "shortTernaryOpProvider")
4896     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4897         short[] a = fa.apply(SPECIES.length());
4898         short[] b = fb.apply(SPECIES.length());
4899         short[] c = fc.apply(SPECIES.length());
4900         short[] r = fr.apply(SPECIES.length());
4901 
4902         for (int i = 0; i < a.length; i += SPECIES.length()) {
4903             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4904             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
4905         }
4906 
4907         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
4908     }
4909     @Test(dataProvider = "shortTernaryOpProvider")
4910     static void bitwiseBlendShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4911         short[] a = fa.apply(SPECIES.length());
4912         short[] b = fb.apply(SPECIES.length());
4913         short[] c = fc.apply(SPECIES.length());
4914         short[] r = fr.apply(SPECIES.length());
4915 
4916         for (int i = 0; i < a.length; i += SPECIES.length()) {
4917             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4918             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
4919         }
4920 
4921         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
4922     }
4923 
4924 
4925     @Test(dataProvider = "shortTernaryOpMaskProvider")
4926     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
4927                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
4928         short[] a = fa.apply(SPECIES.length());
4929         short[] b = fb.apply(SPECIES.length());
4930         short[] c = fc.apply(SPECIES.length());
4931         short[] r = fr.apply(SPECIES.length());
4932         boolean[] mask = fm.apply(SPECIES.length());
4933         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4934 
4935         for (int i = 0; i < a.length; i += SPECIES.length()) {
4936             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4937             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
4938         }
4939 
4940         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
4941     }
4942 
4943 
4944     static short NEG(short a) {
4945         return (short)(-((short)a));
4946     }
4947 
4948     static short neg(short a) {
4949         return (short)(-((short)a));
4950     }
4951 
4952     @Test(dataProvider = "shortUnaryOpProvider")
4953     static void NEGShort256VectorTests(IntFunction<short[]> fa) {
4954         short[] a = fa.apply(SPECIES.length());
4955         short[] r = fr.apply(SPECIES.length());
4956 
4957         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4958             for (int i = 0; i < a.length; i += SPECIES.length()) {
4959                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4960                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4961             }
4962         }
4963 
4964         assertArraysEquals(r, a, Short256VectorTests::NEG);
4965     }
4966 
4967     @Test(dataProvider = "shortUnaryOpProvider")
4968     static void negShort256VectorTests(IntFunction<short[]> fa) {
4969         short[] a = fa.apply(SPECIES.length());
4970         short[] r = fr.apply(SPECIES.length());
4971 
4972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4973             for (int i = 0; i < a.length; i += SPECIES.length()) {
4974                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4975                 av.neg().intoArray(r, i);
4976             }
4977         }
4978 
4979         assertArraysEquals(r, a, Short256VectorTests::neg);
4980     }
4981 
4982     @Test(dataProvider = "shortUnaryOpMaskProvider")
4983     static void NEGMaskedShort256VectorTests(IntFunction<short[]> fa,
4984                                                 IntFunction<boolean[]> fm) {
4985         short[] a = fa.apply(SPECIES.length());
4986         short[] r = fr.apply(SPECIES.length());
4987         boolean[] mask = fm.apply(SPECIES.length());
4988         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4989 
4990         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4991             for (int i = 0; i < a.length; i += SPECIES.length()) {
4992                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4993                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4994             }
4995         }
4996 
4997         assertArraysEquals(r, a, mask, Short256VectorTests::NEG);
4998     }
4999 
5000     static short ABS(short a) {
5001         return (short)(Math.abs((short)a));
5002     }
5003 
5004     static short abs(short a) {
5005         return (short)(Math.abs((short)a));
5006     }
5007 
5008     @Test(dataProvider = "shortUnaryOpProvider")
5009     static void ABSShort256VectorTests(IntFunction<short[]> fa) {
5010         short[] a = fa.apply(SPECIES.length());
5011         short[] r = fr.apply(SPECIES.length());
5012 
5013         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5014             for (int i = 0; i < a.length; i += SPECIES.length()) {
5015                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5016                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
5017             }
5018         }
5019 
5020         assertArraysEquals(r, a, Short256VectorTests::ABS);
5021     }
5022 
5023     @Test(dataProvider = "shortUnaryOpProvider")
5024     static void absShort256VectorTests(IntFunction<short[]> fa) {
5025         short[] a = fa.apply(SPECIES.length());
5026         short[] r = fr.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                 av.abs().intoArray(r, i);
5032             }
5033         }
5034 
5035         assertArraysEquals(r, a, Short256VectorTests::abs);
5036     }
5037 
5038     @Test(dataProvider = "shortUnaryOpMaskProvider")
5039     static void ABSMaskedShort256VectorTests(IntFunction<short[]> fa,
5040                                                 IntFunction<boolean[]> fm) {
5041         short[] a = fa.apply(SPECIES.length());
5042         short[] r = fr.apply(SPECIES.length());
5043         boolean[] mask = fm.apply(SPECIES.length());
5044         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5045 
5046         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5047             for (int i = 0; i < a.length; i += SPECIES.length()) {
5048                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5049                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5050             }
5051         }
5052 
5053         assertArraysEquals(r, a, mask, Short256VectorTests::ABS);
5054     }
5055 
5056 
5057     static short NOT(short a) {
5058         return (short)(~((short)a));
5059     }
5060 
5061     static short not(short a) {
5062         return (short)(~((short)a));
5063     }
5064 
5065 
5066 
5067     @Test(dataProvider = "shortUnaryOpProvider")
5068     static void NOTShort256VectorTests(IntFunction<short[]> fa) {
5069         short[] a = fa.apply(SPECIES.length());
5070         short[] r = fr.apply(SPECIES.length());
5071 
5072         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5073             for (int i = 0; i < a.length; i += SPECIES.length()) {
5074                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5075                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5076             }
5077         }
5078 
5079         assertArraysEquals(r, a, Short256VectorTests::NOT);
5080     }
5081 
5082     @Test(dataProvider = "shortUnaryOpProvider")
5083     static void notShort256VectorTests(IntFunction<short[]> fa) {
5084         short[] a = fa.apply(SPECIES.length());
5085         short[] r = fr.apply(SPECIES.length());
5086 
5087         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5088             for (int i = 0; i < a.length; i += SPECIES.length()) {
5089                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5090                 av.not().intoArray(r, i);
5091             }
5092         }
5093 
5094         assertArraysEquals(r, a, Short256VectorTests::not);
5095     }
5096 
5097 
5098 
5099     @Test(dataProvider = "shortUnaryOpMaskProvider")
5100     static void NOTMaskedShort256VectorTests(IntFunction<short[]> fa,
5101                                                 IntFunction<boolean[]> fm) {
5102         short[] a = fa.apply(SPECIES.length());
5103         short[] r = fr.apply(SPECIES.length());
5104         boolean[] mask = fm.apply(SPECIES.length());
5105         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5106 
5107         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5108             for (int i = 0; i < a.length; i += SPECIES.length()) {
5109                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5110                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5111             }
5112         }
5113 
5114         assertArraysEquals(r, a, mask, Short256VectorTests::NOT);
5115     }
5116 
5117 
5118 
5119     static short ZOMO(short a) {
5120         return (short)((a==0?0:-1));
5121     }
5122 
5123 
5124 
5125     @Test(dataProvider = "shortUnaryOpProvider")
5126     static void ZOMOShort256VectorTests(IntFunction<short[]> fa) {
5127         short[] a = fa.apply(SPECIES.length());
5128         short[] r = fr.apply(SPECIES.length());
5129 
5130         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5131             for (int i = 0; i < a.length; i += SPECIES.length()) {
5132                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5133                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5134             }
5135         }
5136 
5137         assertArraysEquals(r, a, Short256VectorTests::ZOMO);
5138     }
5139 
5140 
5141 
5142     @Test(dataProvider = "shortUnaryOpMaskProvider")
5143     static void ZOMOMaskedShort256VectorTests(IntFunction<short[]> fa,
5144                                                 IntFunction<boolean[]> fm) {
5145         short[] a = fa.apply(SPECIES.length());
5146         short[] r = fr.apply(SPECIES.length());
5147         boolean[] mask = fm.apply(SPECIES.length());
5148         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5149 
5150         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5151             for (int i = 0; i < a.length; i += SPECIES.length()) {
5152                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5153                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5154             }
5155         }
5156 
5157         assertArraysEquals(r, a, mask, Short256VectorTests::ZOMO);
5158     }
5159 
5160 
5161 
5162 
5163 
5164     @Test(dataProvider = "shortCompareOpProvider")
5165     static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5166         short[] a = fa.apply(SPECIES.length());
5167         short[] b = fb.apply(SPECIES.length());
5168 
5169         for (int i = 0; i < a.length; i += SPECIES.length()) {
5170             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5171             VectorMask<Short> mv = av.lt(b[i]);
5172 
5173             // Check results as part of computation.
5174             for (int j = 0; j < SPECIES.length(); j++) {
5175                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5176             }
5177         }
5178     }
5179 
5180     @Test(dataProvider = "shortCompareOpProvider")
5181     static void eqShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5182         short[] a = fa.apply(SPECIES.length());
5183         short[] b = fb.apply(SPECIES.length());
5184 
5185         for (int i = 0; i < a.length; i += SPECIES.length()) {
5186             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5187             VectorMask<Short> mv = av.eq(b[i]);
5188 
5189             // Check results as part of computation.
5190             for (int j = 0; j < SPECIES.length(); j++) {
5191                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5192             }
5193         }
5194     }
5195 
5196     @Test(dataProvider = "shortUnaryOpProvider")
5197     static void toIntArrayShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5198         short[] a = fa.apply(SPECIES.length());
5199 
5200         for (int i = 0; i < a.length; i += SPECIES.length()) {
5201             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5202             int[] r = av.toIntArray();
5203             assertArraysEquals(r, a, i);
5204         }
5205     }
5206 
5207     @Test(dataProvider = "shortUnaryOpProvider")
5208     static void toLongArrayShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5209         short[] a = fa.apply(SPECIES.length());
5210 
5211         for (int i = 0; i < a.length; i += SPECIES.length()) {
5212             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5213             long[] r = av.toLongArray();
5214             assertArraysEquals(r, a, i);
5215         }
5216     }
5217 
5218     @Test(dataProvider = "shortUnaryOpProvider")
5219     static void toDoubleArrayShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5220         short[] a = fa.apply(SPECIES.length());
5221 
5222         for (int i = 0; i < a.length; i += SPECIES.length()) {
5223             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5224             double[] r = av.toDoubleArray();
5225             assertArraysEquals(r, a, i);
5226         }
5227     }
5228 
5229     @Test(dataProvider = "shortUnaryOpProvider")
5230     static void toStringShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5231         short[] a = fa.apply(SPECIES.length());
5232 
5233         for (int i = 0; i < a.length; i += SPECIES.length()) {
5234             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5235             String str = av.toString();
5236 
5237             short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5238             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5239         }
5240     }
5241 
5242     @Test(dataProvider = "shortUnaryOpProvider")
5243     static void hashCodeShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5244         short[] a = fa.apply(SPECIES.length());
5245 
5246         for (int i = 0; i < a.length; i += SPECIES.length()) {
5247             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5248             int hash = av.hashCode();
5249 
5250             short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5251             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5252             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5253         }
5254     }
5255 
5256 
5257     static long ADDReduceLong(short[] a, int idx) {
5258         short res = 0;
5259         for (int i = idx; i < (idx + SPECIES.length()); i++) {
5260             res += a[i];
5261         }
5262 
5263         return (long)res;
5264     }
5265 
5266     static long ADDReduceAllLong(short[] a) {
5267         long res = 0;
5268         for (int i = 0; i < a.length; i += SPECIES.length()) {
5269             res += ADDReduceLong(a, i);
5270         }
5271 
5272         return res;
5273     }
5274 
5275     @Test(dataProvider = "shortUnaryOpProvider")
5276     static void ADDReduceLongShort256VectorTests(IntFunction<short[]> fa) {
5277         short[] a = fa.apply(SPECIES.length());
5278         long[] r = lfr.apply(SPECIES.length());
5279         long ra = 0;
5280 
5281         for (int i = 0; i < a.length; i += SPECIES.length()) {
5282             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5283             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5284         }
5285 
5286         ra = 0;
5287         for (int i = 0; i < a.length; i ++) {
5288             ra += r[i];
5289         }
5290 
5291         assertReductionLongArraysEquals(r, ra, a,
5292                 Short256VectorTests::ADDReduceLong, Short256VectorTests::ADDReduceAllLong);
5293     }
5294 
5295     static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) {
5296         short res = 0;
5297         for (int i = idx; i < (idx + SPECIES.length()); i++) {
5298             if(mask[i % SPECIES.length()])
5299                 res += a[i];
5300         }
5301 
5302         return (long)res;
5303     }
5304 
5305     static long ADDReduceAllLongMasked(short[] a, boolean[] mask) {
5306         long res = 0;
5307         for (int i = 0; i < a.length; i += SPECIES.length()) {
5308             res += ADDReduceLongMasked(a, i, mask);
5309         }
5310 
5311         return res;
5312     }
5313 
5314     @Test(dataProvider = "shortUnaryOpMaskProvider")
5315     static void ADDReduceLongShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
5316         short[] a = fa.apply(SPECIES.length());
5317         long[] r = lfr.apply(SPECIES.length());
5318         boolean[] mask = fm.apply(SPECIES.length());
5319         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5320         long ra = 0;
5321 
5322         for (int i = 0; i < a.length; i += SPECIES.length()) {
5323             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5324             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5325         }
5326 
5327         ra = 0;
5328         for (int i = 0; i < a.length; i ++) {
5329             ra += r[i];
5330         }
5331 
5332         assertReductionLongArraysEqualsMasked(r, ra, a, mask,
5333                 Short256VectorTests::ADDReduceLongMasked, Short256VectorTests::ADDReduceAllLongMasked);
5334     }
5335 
5336     @Test(dataProvider = "shortUnaryOpProvider")
5337     static void BroadcastLongShort256VectorTestsSmokeTest(IntFunction<short[]> fa) {
5338         short[] a = fa.apply(SPECIES.length());
5339         short[] r = new short[a.length];
5340 
5341         for (int i = 0; i < a.length; i += SPECIES.length()) {
5342             ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
5343         }
5344         assertBroadcastArraysEquals(r, a);
5345     }
5346 
5347     @Test(dataProvider = "shortBinaryOpMaskProvider")
5348     static void blendShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5349                                           IntFunction<boolean[]> fm) {
5350         short[] a = fa.apply(SPECIES.length());
5351         short[] b = fb.apply(SPECIES.length());
5352         short[] r = fr.apply(SPECIES.length());
5353         boolean[] mask = fm.apply(SPECIES.length());
5354         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5355 
5356         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5357             for (int i = 0; i < a.length; i += SPECIES.length()) {
5358                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5359                 av.blend((long)b[i], vmask).intoArray(r, i);
5360             }
5361         }
5362         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::blend);
5363     }
5364 
5365 
5366     @Test(dataProvider = "shortUnaryOpSelectFromProvider")
5367     static void SelectFromShort256VectorTests(IntFunction<short[]> fa,
5368                                            BiFunction<Integer,Integer,short[]> fs) {
5369         short[] a = fa.apply(SPECIES.length());
5370         short[] order = fs.apply(a.length, SPECIES.length());
5371         short[] r = fr.apply(SPECIES.length());
5372 
5373         for (int i = 0; i < a.length; i += SPECIES.length()) {
5374             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5375             ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
5376             bv.selectFrom(av).intoArray(r, i);
5377         }
5378 
5379         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5380     }
5381 
5382     @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider")
5383     static void SelectFromShort256VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
5384                                                            BiFunction<Integer,Integer,short[]> fs,
5385                                                            IntFunction<boolean[]> fm) {
5386         short[] a = fa.apply(SPECIES.length());
5387         short[] order = fs.apply(a.length, SPECIES.length());
5388         short[] r = fr.apply(SPECIES.length());
5389         boolean[] mask = fm.apply(SPECIES.length());
5390         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5391 
5392         for (int i = 0; i < a.length; i += SPECIES.length()) {
5393             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5394             ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
5395             bv.selectFrom(av, vmask).intoArray(r, i);
5396         }
5397 
5398         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5399     }
5400 
5401     @Test(dataProvider = "shuffleProvider")
5402     static void shuffleMiscellaneousShort256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5403         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5404 
5405         for (int i = 0; i < a.length; i += SPECIES.length()) {
5406             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5407             int hash = shuffle.hashCode();
5408             int length = shuffle.length();
5409 
5410             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5411             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5412             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5413             Assert.assertEquals(length, SPECIES.length());
5414         }
5415     }
5416 
5417     @Test(dataProvider = "shuffleProvider")
5418     static void shuffleToStringShort256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5419         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5420 
5421         for (int i = 0; i < a.length; i += SPECIES.length()) {
5422             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5423             String str = shuffle.toString();
5424 
5425             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5426             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5427                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5428         }
5429     }
5430 
5431     @Test(dataProvider = "shuffleCompareOpProvider")
5432     static void shuffleEqualsShort256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5433         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5434         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5435 
5436         for (int i = 0; i < a.length; i += SPECIES.length()) {
5437             var av = VectorShuffle.fromArray(SPECIES, a, i);
5438             var bv = VectorShuffle.fromArray(SPECIES, b, i);
5439             boolean eq = av.equals(bv);
5440             int to = i + SPECIES.length();
5441             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5442         }
5443     }
5444 
5445     @Test(dataProvider = "maskCompareOpProvider")
5446     static void maskEqualsShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5447         boolean[] a = fa.apply(SPECIES.length());
5448         boolean[] b = fb.apply(SPECIES.length());
5449 
5450         for (int i = 0; i < a.length; i += SPECIES.length()) {
5451             var av = SPECIES.loadMask(a, i);
5452             var bv = SPECIES.loadMask(b, i);
5453             boolean equals = av.equals(bv);
5454             int to = i + SPECIES.length();
5455             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5456         }
5457     }
5458 
5459     static boolean beq(boolean a, boolean b) {
5460         return (a == b);
5461     }
5462 
5463     @Test(dataProvider = "maskCompareOpProvider")
5464     static void maskEqShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5465         boolean[] a = fa.apply(SPECIES.length());
5466         boolean[] b = fb.apply(SPECIES.length());
5467         boolean[] r = new boolean[a.length];
5468 
5469         for (int i = 0; i < a.length; i += SPECIES.length()) {
5470             var av = SPECIES.loadMask(a, i);
5471             var bv = SPECIES.loadMask(b, i);
5472             var cv = av.eq(bv);
5473             cv.intoArray(r, i);
5474         }
5475         assertArraysEquals(r, a, b, Short256VectorTests::beq);
5476     }
5477 
5478     @Test(dataProvider = "maskProvider")
5479     static void maskHashCodeShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5480         boolean[] a = fa.apply(SPECIES.length());
5481 
5482         for (int i = 0; i < a.length; i += SPECIES.length()) {
5483             var vmask = SPECIES.loadMask(a, i);
5484             int hash = vmask.hashCode();
5485 
5486             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5487             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5488             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5489         }
5490     }
5491 
5492     static int maskTrueCount(boolean[] a, int idx) {
5493         int trueCount = 0;
5494         for (int i = idx; i < idx + SPECIES.length(); i++) {
5495             trueCount += a[i] ? 1 : 0;
5496         }
5497         return trueCount;
5498     }
5499 
5500     @Test(dataProvider = "maskProvider")
5501     static void maskTrueCountShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5502         boolean[] a = fa.apply(SPECIES.length());
5503         int[] r = new int[a.length];
5504 
5505         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5506             for (int i = 0; i < a.length; i += SPECIES.length()) {
5507                 var vmask = SPECIES.loadMask(a, i);
5508                 r[i] = vmask.trueCount();
5509             }
5510         }
5511 
5512         assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskTrueCount);
5513     }
5514 
5515     static int maskLastTrue(boolean[] a, int idx) {
5516         int i = idx + SPECIES.length() - 1;
5517         for (; i >= idx; i--) {
5518             if (a[i]) {
5519                 break;
5520             }
5521         }
5522         return i - idx;
5523     }
5524 
5525     @Test(dataProvider = "maskProvider")
5526     static void maskLastTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5527         boolean[] a = fa.apply(SPECIES.length());
5528         int[] r = new int[a.length];
5529 
5530         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5531             for (int i = 0; i < a.length; i += SPECIES.length()) {
5532                 var vmask = SPECIES.loadMask(a, i);
5533                 r[i] = vmask.lastTrue();
5534             }
5535         }
5536 
5537         assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskLastTrue);
5538     }
5539 
5540     static int maskFirstTrue(boolean[] a, int idx) {
5541         int i = idx;
5542         for (; i < idx + SPECIES.length(); i++) {
5543             if (a[i]) {
5544                 break;
5545             }
5546         }
5547         return i - idx;
5548     }
5549 
5550     @Test(dataProvider = "maskProvider")
5551     static void maskFirstTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5552         boolean[] a = fa.apply(SPECIES.length());
5553         int[] r = new int[a.length];
5554 
5555         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5556             for (int i = 0; i < a.length; i += SPECIES.length()) {
5557                 var vmask = SPECIES.loadMask(a, i);
5558                 r[i] = vmask.firstTrue();
5559             }
5560         }
5561 
5562         assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskFirstTrue);
5563     }
5564 
5565     @Test(dataProvider = "maskProvider")
5566     static void maskCompressShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5567         int trueCount = 0;
5568         boolean[] a = fa.apply(SPECIES.length());
5569 
5570         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5571             for (int i = 0; i < a.length; i += SPECIES.length()) {
5572                 var vmask = SPECIES.loadMask(a, i);
5573                 trueCount = vmask.trueCount();
5574                 var rmask = vmask.compress();
5575                 for (int j = 0; j < SPECIES.length(); j++)  {
5576                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5577                 }
5578             }
5579         }
5580     }
5581 
5582     @DataProvider
5583     public static Object[][] longMaskProvider() {
5584         return new Object[][]{
5585                 {0xFFFFFFFFFFFFFFFFL},
5586                 {0x0000000000000000L},
5587                 {0x5555555555555555L},
5588                 {0x0123456789abcdefL},
5589         };
5590     }
5591 
5592     @Test(dataProvider = "longMaskProvider")
5593     static void maskFromToLongShort256VectorTestsSmokeTest(long inputLong) {
5594         var vmask = VectorMask.fromLong(SPECIES, inputLong);
5595         long outputLong = vmask.toLong();
5596         Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));
5597     }
5598 
5599     @DataProvider
5600     public static Object[][] offsetProvider() {
5601         return new Object[][]{
5602                 {0},
5603                 {-1},
5604                 {+1},
5605                 {+2},
5606                 {-2},
5607         };
5608     }
5609 
5610     @Test(dataProvider = "offsetProvider")
5611     static void indexInRangeShort256VectorTestsSmokeTest(int offset) {
5612         int limit = SPECIES.length() * BUFFER_REPS;
5613         for (int i = 0; i < limit; i += SPECIES.length()) {
5614             var actualMask = SPECIES.indexInRange(i + offset, limit);
5615             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5616             assert(actualMask.equals(expectedMask));
5617             for (int j = 0; j < SPECIES.length(); j++)  {
5618                 int index = i + j + offset;
5619                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5620             }
5621         }
5622     }
5623 
5624     @DataProvider
5625     public static Object[][] lengthProvider() {
5626         return new Object[][]{
5627                 {0},
5628                 {1},
5629                 {32},
5630                 {37},
5631                 {1024},
5632                 {1024+1},
5633                 {1024+5},
5634         };
5635     }
5636 
5637     @Test(dataProvider = "lengthProvider")
5638     static void loopBoundShort256VectorTestsSmokeTest(int length) {
5639         int actualLoopBound = SPECIES.loopBound(length);
5640         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5641         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5642     }
5643 
5644     @Test
5645     static void ElementSizeShort256VectorTestsSmokeTest() {
5646         ShortVector av = ShortVector.zero(SPECIES);
5647         int elsize = av.elementSize();
5648         Assert.assertEquals(elsize, Short.SIZE);
5649     }
5650 
5651     @Test
5652     static void VectorShapeShort256VectorTestsSmokeTest() {
5653         ShortVector av = ShortVector.zero(SPECIES);
5654         VectorShape vsh = av.shape();
5655         assert(vsh.equals(VectorShape.S_256_BIT));
5656     }
5657 
5658     @Test
5659     static void ShapeWithLanesShort256VectorTestsSmokeTest() {
5660         ShortVector av = ShortVector.zero(SPECIES);
5661         VectorShape vsh = av.shape();
5662         VectorSpecies species = vsh.withLanes(short.class);
5663         assert(species.equals(SPECIES));
5664     }
5665 
5666     @Test
5667     static void ElementTypeShort256VectorTestsSmokeTest() {
5668         ShortVector av = ShortVector.zero(SPECIES);
5669         assert(av.species().elementType() == short.class);
5670     }
5671 
5672     @Test
5673     static void SpeciesElementSizeShort256VectorTestsSmokeTest() {
5674         ShortVector av = ShortVector.zero(SPECIES);
5675         assert(av.species().elementSize() == Short.SIZE);
5676     }
5677 
5678     @Test
5679     static void VectorTypeShort256VectorTestsSmokeTest() {
5680         ShortVector av = ShortVector.zero(SPECIES);
5681         assert(av.species().vectorType() == av.getClass());
5682     }
5683 
5684     @Test
5685     static void WithLanesShort256VectorTestsSmokeTest() {
5686         ShortVector av = ShortVector.zero(SPECIES);
5687         VectorSpecies species = av.species().withLanes(short.class);
5688         assert(species.equals(SPECIES));
5689     }
5690 
5691     @Test
5692     static void WithShapeShort256VectorTestsSmokeTest() {
5693         ShortVector av = ShortVector.zero(SPECIES);
5694         VectorShape vsh = av.shape();
5695         VectorSpecies species = av.species().withShape(vsh);
5696         assert(species.equals(SPECIES));
5697     }
5698 }
5699