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 Int128VectorTests
  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.IntVector;
  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 Int128VectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Integer> SPECIES =
  58                 IntVector.SPECIES_128;
  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 / 128);
  64 
  65     interface FUnOp {
  66         int apply(int a);
  67     }
  68 
  69     static void assertArraysEquals(int[] r, int[] 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         int[] apply(int a);
  82     }
  83 
  84     static void assertArraysEquals(int[] r, int[] 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             int[] ref = f.apply(a[i]);
  93             int[] 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(int[] r, int[] 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         int apply(int[] a, int idx);
 113     }
 114 
 115     interface FReductionAllOp {
 116         int apply(int[] a);
 117     }
 118 
 119     static void assertReductionArraysEquals(int[] r, int rc, int[] 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         int apply(int[] a, int idx, boolean[] mask);
 135     }
 136 
 137     interface FReductionAllMaskedOp {
 138         int apply(int[] a, boolean[] mask);
 139     }
 140 
 141     static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] 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(int[] a, int idx);
 157     }
 158 
 159     interface FReductionAllOpLong {
 160         long apply(int[] a);
 161     }
 162 
 163     static void assertReductionLongArraysEquals(long[] r, long rc, int[] 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(int[] a, int idx, boolean[] mask);
 179     }
 180 
 181     interface FReductionAllMaskedOpLong {
 182         long apply(int[] a, boolean[] mask);
 183     }
 184 
 185     static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] 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(int[] r, int[] a, int 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(int[] r, int[] 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(int[] r, int[] 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], (int)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], (int)0, "at index #" + idx);
 283             }
 284         }
 285     }
 286 
 287     static void assertexpandArraysEquals(int[] r, int[] 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], (int)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], (int)0, "at index #" + idx);
 307             }
 308         }
 309     }
 310 
 311     static void assertSelectFromArraysEquals(int[] r, int[] a, int[] 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(int[] r, int[] 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], (int)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], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 342         }
 343     }
 344 
 345     static void assertSelectFromArraysEquals(int[] r, int[] a, int[] 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], (int)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], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 362         }
 363     }
 364 
 365     static void assertBroadcastArraysEquals(int[] r, int[] 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         int apply(int a, int b);
 384     }
 385 
 386     interface FBinMaskOp {
 387         int apply(int a, int 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(int[] r, int[] a, int[] 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(int[] r, int[] a, int[] 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(int[] r, int[] a, int[] b, FBinOp f) {
 418         int i = 0;
 419         try {
 420             for (; i < a.length; i++) {
 421                 Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 422             }
 423         } catch (AssertionError e) {
 424             Assert.assertEquals(r[i], f.apply(a[i], (int)((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(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) {
 430         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 431     }
 432 
 433     static void assertArraysEquals(int[] r, int[] a, int[] 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(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) {
 445         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 446     }
 447 
 448     static void assertBroadcastArraysEquals(int[] r, int[] a, int[] 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(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) {
 463         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 464     }
 465 
 466     static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] 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], (int)((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], (int)((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(int[] r, int[] a, int[] 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(int[] r, int[] a, int[] b, boolean[] mask, FBinOp f) {
 495         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 496     }
 497 
 498     static void assertShiftArraysEquals(int[] r, int[] a, int[] 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         int apply(int a, int b, int c);
 514     }
 515 
 516     interface FTernMaskOp {
 517         int apply(int a, int b, int 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(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] c, boolean[] mask, FTernOp f) {
 536         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 537     }
 538 
 539     static void assertArraysEquals(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] c, boolean[] mask,
 578                                             FTernOp f) {
 579         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 580     }
 581 
 582     static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] c, boolean[] mask,
 599                                             FTernOp f) {
 600         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 601     }
 602 
 603     static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] 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(int[] r, int[] a, int[] b, int[] c, boolean[] mask,
 635                                                   FTernOp f) {
 636         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 637     }
 638 
 639     static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] 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         int apply(int[] a, int b);
 660     }
 661 
 662     static void assertArraysEquals(int[] r, int[] 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         int[] apply(int[] a, int ix, int[] b, int iy);
 675     }
 676 
 677     static void assertArraysEquals(int[] r, int[] 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             int[] ref = f.apply(a, i, b, i);
 686             int[] 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         int[] apply(int[] a, int ix, boolean[] mask, int[] b, int iy);
 698     }
 699 
 700     interface FScatterMaskedOp {
 701         int[] apply(int[] r, int[] a, int ix, boolean[] mask, int[] b, int iy);
 702     }
 703 
 704     static void assertArraysEquals(int[] r, int[] 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             int[] ref = f.apply(a, i, mask, b, i);
 713             int[] 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(int[] r, int[] 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             int[] ref = f.apply(r, a, i, mask, b, i);
 734             int[] 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         int[] apply(int[] a, int origin, int idx);
 750     }
 751 
 752     static void assertArraysEquals(int[] r, int[] 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             int[] ref = f.apply(a, origin, i);
 761             int[] 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         int[] apply(int[] a, int[] b, int origin, int idx);
 770     }
 771 
 772     static void assertArraysEquals(int[] r, int[] a, int[] 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             int[] ref = f.apply(a, b, origin, i);
 781             int[] 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         int[] apply(int[] a, int[] b, int origin, boolean[] mask, int idx);
 791     }
 792 
 793     static void assertArraysEquals(int[] r, int[] a, int[] 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             int[] ref = f.apply(a, b, origin, mask, i);
 802             int[] 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         int[] apply(int[] a, int[] b, int origin, int part, int idx);
 812     }
 813 
 814     static void assertArraysEquals(int[] r, int[] a, int[] 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             int[] ref = f.apply(a, b, origin, part, i);
 823             int[] 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         int[] apply(int[] a, int[] b, int origin, int part, boolean[] mask, int idx);
 834     }
 835 
 836     static void assertArraysEquals(int[] r, int[] a, int[] 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             int[] ref = f.apply(a, b, origin, part, mask, i);
 845             int[] 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, int[] 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, int[] 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, int[] 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 int bits(int e) {
 892         return  e;
 893     }
 894 
 895     static final List<IntFunction<int[]>> INT_GENERATORS = List.of(
 896             withToString("int[-i * 5]", (int s) -> {
 897                 return fill(s * BUFFER_REPS,
 898                             i -> (int)(-i * 5));
 899             }),
 900             withToString("int[i * 5]", (int s) -> {
 901                 return fill(s * BUFFER_REPS,
 902                             i -> (int)(i * 5));
 903             }),
 904             withToString("int[i + 1]", (int s) -> {
 905                 return fill(s * BUFFER_REPS,
 906                             i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1)));
 907             }),
 908             withToString("int[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<int[]>>> INT_GENERATOR_PAIRS =
 917         Stream.of(INT_GENERATORS.get(0)).
 918                 flatMap(fa -> INT_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<int[]>>> INT_GENERATOR_TRIPLES =
 929         INT_GENERATOR_PAIRS.stream().
 930                 flatMap(pair -> INT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
 931                 collect(Collectors.toList());
 932 
 933     @DataProvider
 934     public Object[][] intBinaryOpProvider() {
 935         return INT_GENERATOR_PAIRS.stream().map(List::toArray).
 936                 toArray(Object[][]::new);
 937     }
 938 
 939     @DataProvider
 940     public Object[][] intIndexedOpProvider() {
 941         return INT_GENERATOR_PAIRS.stream().map(List::toArray).
 942                 toArray(Object[][]::new);
 943     }
 944 
 945     @DataProvider
 946     public Object[][] intBinaryOpMaskProvider() {
 947         return BOOLEAN_MASK_GENERATORS.stream().
 948                 flatMap(fm -> INT_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[][] intTernaryOpProvider() {
 956         return INT_GENERATOR_TRIPLES.stream().map(List::toArray).
 957                 toArray(Object[][]::new);
 958     }
 959 
 960     @DataProvider
 961     public Object[][] intTernaryOpMaskProvider() {
 962         return BOOLEAN_MASK_GENERATORS.stream().
 963                 flatMap(fm -> INT_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[][] intUnaryOpProvider() {
 971         return INT_GENERATORS.stream().
 972                 map(f -> new Object[]{f}).
 973                 toArray(Object[][]::new);
 974     }
 975 
 976     @DataProvider
 977     public Object[][] intUnaryOpMaskProvider() {
 978         return BOOLEAN_MASK_GENERATORS.stream().
 979                 flatMap(fm -> INT_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[][] intUnaryOpShuffleProvider() {
1015         return INT_SHUFFLE_GENERATORS.stream().
1016                 flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1017                     return new Object[] {fa, fs};
1018                 })).
1019                 toArray(Object[][]::new);
1020     }
1021 
1022     @DataProvider
1023     public Object[][] intUnaryOpShuffleMaskProvider() {
1024         return BOOLEAN_MASK_GENERATORS.stream().
1025                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1026                     flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1027                         return new Object[] {fa, fs, fm};
1028                 }))).
1029                 toArray(Object[][]::new);
1030     }
1031 
1032 
1033     static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
1034             withToString("int[i]", (int s) -> {
1035                 return fill(s * BUFFER_REPS,
1036                             i -> (int)i);
1037             }),
1038             withToString("int[i - length / 2]", (int s) -> {
1039                 return fill(s * BUFFER_REPS,
1040                             i -> (int)(i - (s * BUFFER_REPS / 2)));
1041             }),
1042             withToString("int[i + 1]", (int s) -> {
1043                 return fill(s * BUFFER_REPS,
1044                             i -> (int)(i + 1));
1045             }),
1046             withToString("int[i - 2]", (int s) -> {
1047                 return fill(s * BUFFER_REPS,
1048                             i -> (int)(i - 2));
1049             }),
1050             withToString("int[zigZag(i)]", (int s) -> {
1051                 return fill(s * BUFFER_REPS,
1052                             i -> i%3 == 0 ? (int)i : (i%3 == 1 ? (int)(i + 1) : (int)(i - 2)));
1053             }),
1054             withToString("int[cornerCaseValue(i)]", (int s) -> {
1055                 return fill(s * BUFFER_REPS,
1056                             i -> cornerCaseValue(i));
1057             })
1058     );
1059 
1060     static final List<List<IntFunction<int[]>>> INT_TEST_GENERATOR_ARGS =
1061         INT_COMPARE_GENERATORS.stream().
1062                 map(fa -> List.of(fa)).
1063                 collect(Collectors.toList());
1064 
1065     @DataProvider
1066     public Object[][] intTestOpProvider() {
1067         return INT_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1068                 toArray(Object[][]::new);
1069     }
1070 
1071     @DataProvider
1072     public Object[][] intTestOpMaskProvider() {
1073         return BOOLEAN_MASK_GENERATORS.stream().
1074                 flatMap(fm -> INT_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1075                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1076                 })).
1077                 toArray(Object[][]::new);
1078     }
1079 
1080     static final List<List<IntFunction<int[]>>> INT_COMPARE_GENERATOR_PAIRS =
1081         INT_COMPARE_GENERATORS.stream().
1082                 flatMap(fa -> INT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1083                 collect(Collectors.toList());
1084 
1085     @DataProvider
1086     public Object[][] intCompareOpProvider() {
1087         return INT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1088                 toArray(Object[][]::new);
1089     }
1090 
1091     @DataProvider
1092     public Object[][] intCompareOpMaskProvider() {
1093         return BOOLEAN_MASK_GENERATORS.stream().
1094                 flatMap(fm -> INT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1095                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1096                 })).
1097                 toArray(Object[][]::new);
1098     }
1099 
1100     interface ToIntF {
1101         int apply(int i);
1102     }
1103 
1104     static int[] fill(int s , ToIntF f) {
1105         return fill(new int[s], f);
1106     }
1107 
1108     static int[] fill(int[] a, ToIntF f) {
1109         for (int i = 0; i < a.length; i++) {
1110             a[i] = f.apply(i);
1111         }
1112         return a;
1113     }
1114 
1115     static int cornerCaseValue(int i) {
1116         switch(i % 5) {
1117             case 0:
1118                 return Integer.MAX_VALUE;
1119             case 1:
1120                 return Integer.MIN_VALUE;
1121             case 2:
1122                 return Integer.MIN_VALUE;
1123             case 3:
1124                 return Integer.MAX_VALUE;
1125             default:
1126                 return (int)0;
1127         }
1128     }
1129 
1130     static int get(int[] a, int i) {
1131         return (int) a[i];
1132     }
1133 
1134     static final IntFunction<int[]> fr = (vl) -> {
1135         int length = BUFFER_REPS * vl;
1136         return new int[length];
1137     };
1138 
1139     static final IntFunction<boolean[]> fmr = (vl) -> {
1140         int length = BUFFER_REPS * vl;
1141         return new boolean[length];
1142     };
1143 
1144     static final IntFunction<long[]> lfr = (vl) -> {
1145         int length = BUFFER_REPS * vl;
1146         return new long[length];
1147     };
1148 
1149     static void replaceZero(int[] a, int v) {
1150         for (int i = 0; i < a.length; i++) {
1151             if (a[i] == 0) {
1152                 a[i] = v;
1153             }
1154         }
1155     }
1156 
1157     static void replaceZero(int[] a, boolean[] mask, int v) {
1158         for (int i = 0; i < a.length; i++) {
1159             if (mask[i % mask.length] && a[i] == 0) {
1160                 a[i] = v;
1161             }
1162         }
1163     }
1164 
1165     static int ROL_scalar(int a, int b) {
1166         return Integer.rotateLeft(a, ((int)b));
1167     }
1168 
1169     static int ROR_scalar(int a, int b) {
1170         return Integer.rotateRight(a, ((int)b));
1171     }
1172 
1173     static boolean eq(int a, int b) {
1174         return a == b;
1175     }
1176 
1177     static boolean neq(int a, int b) {
1178         return a != b;
1179     }
1180 
1181     static boolean lt(int a, int b) {
1182         return a < b;
1183     }
1184 
1185     static boolean le(int a, int b) {
1186         return a <= b;
1187     }
1188 
1189     static boolean gt(int a, int b) {
1190         return a > b;
1191     }
1192 
1193     static boolean ge(int a, int b) {
1194         return a >= b;
1195     }
1196 
1197     static boolean ult(int a, int b) {
1198         return Integer.compareUnsigned(a, b) < 0;
1199     }
1200 
1201     static boolean ule(int a, int b) {
1202         return Integer.compareUnsigned(a, b) <= 0;
1203     }
1204 
1205     static boolean ugt(int a, int b) {
1206         return Integer.compareUnsigned(a, b) > 0;
1207     }
1208 
1209     static boolean uge(int a, int b) {
1210         return Integer.compareUnsigned(a, b) >= 0;
1211     }
1212 
1213     @Test
1214     static void smokeTest1() {
1215         IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
1216         IntVector three2 = (IntVector) SPECIES.broadcast(-3);
1217         assert(three.eq(three2).allTrue());
1218         IntVector three3 = three2.broadcast(1).broadcast(-3);
1219         assert(three.eq(three3).allTrue());
1220         int scale = 2;
1221         Class<?> ETYPE = int.class;
1222         if (ETYPE == double.class || ETYPE == long.class)
1223             scale = 1000000;
1224         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1225             scale = 1;
1226         IntVector higher = three.addIndex(scale);
1227         VectorMask<Integer> m = three.compare(VectorOperators.LE, higher);
1228         assert(m.allTrue());
1229         m = higher.min((int)-1).test(VectorOperators.IS_NEGATIVE);
1230         assert(m.allTrue());
1231         int max = higher.reduceLanes(VectorOperators.MAX);
1232         assert(max == -3 + scale * (SPECIES.length()-1));
1233     }
1234 
1235     private static int[]
1236     bothToArray(IntVector a, IntVector b) {
1237         int[] r = new int[a.length() + b.length()];
1238         a.intoArray(r, 0);
1239         b.intoArray(r, a.length());
1240         return r;
1241     }
1242 
1243     @Test
1244     static void smokeTest2() {
1245         // Do some zipping and shuffling.
1246         IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1);
1247         IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1248         Assert.assertEquals(io, io2);
1249         IntVector a = io.add((int)1); //[1,2]
1250         IntVector b = a.neg();  //[-1,-2]
1251         int[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1252         VectorShuffle<Integer> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1253         VectorShuffle<Integer> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1254         IntVector zab0 = a.rearrange(zip0,b); //[1,-1]
1255         IntVector zab1 = a.rearrange(zip1,b); //[2,-2]
1256         int[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1257         // manually zip
1258         int[] manual = new int[zabValues.length];
1259         for (int i = 0; i < manual.length; i += 2) {
1260             manual[i+0] = abValues[i/2];
1261             manual[i+1] = abValues[a.length() + i/2];
1262         }
1263         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1264         VectorShuffle<Integer> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1265         VectorShuffle<Integer> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1266         IntVector uab0 = zab0.rearrange(unz0,zab1);
1267         IntVector uab1 = zab0.rearrange(unz1,zab1);
1268         int[] abValues1 = bothToArray(uab0, uab1);
1269         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1270     }
1271 
1272     static void iotaShuffle() {
1273         IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1);
1274         IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1275         Assert.assertEquals(io, io2);
1276     }
1277 
1278     @Test
1279     // Test all shuffle related operations.
1280     static void shuffleTest() {
1281         // To test backend instructions, make sure that C2 is used.
1282         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1283             iotaShuffle();
1284         }
1285     }
1286 
1287     @Test
1288     void viewAsIntegeralLanesTest() {
1289         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1290         Assert.assertEquals(asIntegral.species(), SPECIES);
1291     }
1292 
1293     @Test
1294     void viewAsFloatingLanesTest() {
1295         Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();
1296         VectorSpecies<?> asFloatingSpecies = asFloating.species();
1297         Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType());
1298         Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape());
1299         Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length());
1300         Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES);
1301     }
1302 
1303     @Test
1304     // Test div by 0.
1305     static void bitwiseDivByZeroSmokeTest() {
1306         try {
1307             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1308             IntVector b = (IntVector) SPECIES.broadcast(0);
1309             a.div(b);
1310             Assert.fail();
1311         } catch (ArithmeticException e) {
1312         }
1313 
1314         try {
1315             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1316             IntVector b = (IntVector) SPECIES.broadcast(0);
1317             VectorMask<Integer> m = a.lt((int) 1);
1318             a.div(b, m);
1319             Assert.fail();
1320         } catch (ArithmeticException e) {
1321         }
1322     }
1323     static int ADD(int a, int b) {
1324         return (int)(a + b);
1325     }
1326 
1327     @Test(dataProvider = "intBinaryOpProvider")
1328     static void ADDInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1329         int[] a = fa.apply(SPECIES.length());
1330         int[] b = fb.apply(SPECIES.length());
1331         int[] r = fr.apply(SPECIES.length());
1332 
1333         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1334             for (int i = 0; i < a.length; i += SPECIES.length()) {
1335                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1336                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1337                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1338             }
1339         }
1340 
1341         assertArraysEquals(r, a, b, Int128VectorTests::ADD);
1342     }
1343     static int add(int a, int b) {
1344         return (int)(a + b);
1345     }
1346 
1347     @Test(dataProvider = "intBinaryOpProvider")
1348     static void addInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1349         int[] a = fa.apply(SPECIES.length());
1350         int[] b = fb.apply(SPECIES.length());
1351         int[] r = fr.apply(SPECIES.length());
1352 
1353         for (int i = 0; i < a.length; i += SPECIES.length()) {
1354             IntVector av = IntVector.fromArray(SPECIES, a, i);
1355             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1356             av.add(bv).intoArray(r, i);
1357         }
1358 
1359         assertArraysEquals(r, a, b, Int128VectorTests::add);
1360     }
1361 
1362     @Test(dataProvider = "intBinaryOpMaskProvider")
1363     static void ADDInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1364                                           IntFunction<boolean[]> fm) {
1365         int[] a = fa.apply(SPECIES.length());
1366         int[] b = fb.apply(SPECIES.length());
1367         int[] r = fr.apply(SPECIES.length());
1368         boolean[] mask = fm.apply(SPECIES.length());
1369         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1370 
1371         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1372             for (int i = 0; i < a.length; i += SPECIES.length()) {
1373                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1374                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1375                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1376             }
1377         }
1378 
1379         assertArraysEquals(r, a, b, mask, Int128VectorTests::ADD);
1380     }
1381 
1382     @Test(dataProvider = "intBinaryOpMaskProvider")
1383     static void addInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1384                                           IntFunction<boolean[]> fm) {
1385         int[] a = fa.apply(SPECIES.length());
1386         int[] b = fb.apply(SPECIES.length());
1387         int[] r = fr.apply(SPECIES.length());
1388         boolean[] mask = fm.apply(SPECIES.length());
1389         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1390 
1391         for (int i = 0; i < a.length; i += SPECIES.length()) {
1392             IntVector av = IntVector.fromArray(SPECIES, a, i);
1393             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1394             av.add(bv, vmask).intoArray(r, i);
1395         }
1396 
1397         assertArraysEquals(r, a, b, mask, Int128VectorTests::add);
1398     }
1399     static int SUB(int a, int b) {
1400         return (int)(a - b);
1401     }
1402 
1403     @Test(dataProvider = "intBinaryOpProvider")
1404     static void SUBInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1405         int[] a = fa.apply(SPECIES.length());
1406         int[] b = fb.apply(SPECIES.length());
1407         int[] r = fr.apply(SPECIES.length());
1408 
1409         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1410             for (int i = 0; i < a.length; i += SPECIES.length()) {
1411                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1412                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1413                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1414             }
1415         }
1416 
1417         assertArraysEquals(r, a, b, Int128VectorTests::SUB);
1418     }
1419     static int sub(int a, int b) {
1420         return (int)(a - b);
1421     }
1422 
1423     @Test(dataProvider = "intBinaryOpProvider")
1424     static void subInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1425         int[] a = fa.apply(SPECIES.length());
1426         int[] b = fb.apply(SPECIES.length());
1427         int[] r = fr.apply(SPECIES.length());
1428 
1429         for (int i = 0; i < a.length; i += SPECIES.length()) {
1430             IntVector av = IntVector.fromArray(SPECIES, a, i);
1431             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1432             av.sub(bv).intoArray(r, i);
1433         }
1434 
1435         assertArraysEquals(r, a, b, Int128VectorTests::sub);
1436     }
1437 
1438     @Test(dataProvider = "intBinaryOpMaskProvider")
1439     static void SUBInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1440                                           IntFunction<boolean[]> fm) {
1441         int[] a = fa.apply(SPECIES.length());
1442         int[] b = fb.apply(SPECIES.length());
1443         int[] r = fr.apply(SPECIES.length());
1444         boolean[] mask = fm.apply(SPECIES.length());
1445         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1446 
1447         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1448             for (int i = 0; i < a.length; i += SPECIES.length()) {
1449                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1450                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1451                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1452             }
1453         }
1454 
1455         assertArraysEquals(r, a, b, mask, Int128VectorTests::SUB);
1456     }
1457 
1458     @Test(dataProvider = "intBinaryOpMaskProvider")
1459     static void subInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1460                                           IntFunction<boolean[]> fm) {
1461         int[] a = fa.apply(SPECIES.length());
1462         int[] b = fb.apply(SPECIES.length());
1463         int[] r = fr.apply(SPECIES.length());
1464         boolean[] mask = fm.apply(SPECIES.length());
1465         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1466 
1467         for (int i = 0; i < a.length; i += SPECIES.length()) {
1468             IntVector av = IntVector.fromArray(SPECIES, a, i);
1469             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1470             av.sub(bv, vmask).intoArray(r, i);
1471         }
1472 
1473         assertArraysEquals(r, a, b, mask, Int128VectorTests::sub);
1474     }
1475     static int MUL(int a, int b) {
1476         return (int)(a * b);
1477     }
1478 
1479     @Test(dataProvider = "intBinaryOpProvider")
1480     static void MULInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1481         int[] a = fa.apply(SPECIES.length());
1482         int[] b = fb.apply(SPECIES.length());
1483         int[] r = fr.apply(SPECIES.length());
1484 
1485         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1486             for (int i = 0; i < a.length; i += SPECIES.length()) {
1487                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1488                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1489                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1490             }
1491         }
1492 
1493         assertArraysEquals(r, a, b, Int128VectorTests::MUL);
1494     }
1495     static int mul(int a, int b) {
1496         return (int)(a * b);
1497     }
1498 
1499     @Test(dataProvider = "intBinaryOpProvider")
1500     static void mulInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1501         int[] a = fa.apply(SPECIES.length());
1502         int[] b = fb.apply(SPECIES.length());
1503         int[] r = fr.apply(SPECIES.length());
1504 
1505         for (int i = 0; i < a.length; i += SPECIES.length()) {
1506             IntVector av = IntVector.fromArray(SPECIES, a, i);
1507             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1508             av.mul(bv).intoArray(r, i);
1509         }
1510 
1511         assertArraysEquals(r, a, b, Int128VectorTests::mul);
1512     }
1513 
1514     @Test(dataProvider = "intBinaryOpMaskProvider")
1515     static void MULInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1516                                           IntFunction<boolean[]> fm) {
1517         int[] a = fa.apply(SPECIES.length());
1518         int[] b = fb.apply(SPECIES.length());
1519         int[] r = fr.apply(SPECIES.length());
1520         boolean[] mask = fm.apply(SPECIES.length());
1521         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1522 
1523         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1524             for (int i = 0; i < a.length; i += SPECIES.length()) {
1525                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1526                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1527                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1528             }
1529         }
1530 
1531         assertArraysEquals(r, a, b, mask, Int128VectorTests::MUL);
1532     }
1533 
1534     @Test(dataProvider = "intBinaryOpMaskProvider")
1535     static void mulInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1536                                           IntFunction<boolean[]> fm) {
1537         int[] a = fa.apply(SPECIES.length());
1538         int[] b = fb.apply(SPECIES.length());
1539         int[] r = fr.apply(SPECIES.length());
1540         boolean[] mask = fm.apply(SPECIES.length());
1541         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1542 
1543         for (int i = 0; i < a.length; i += SPECIES.length()) {
1544             IntVector av = IntVector.fromArray(SPECIES, a, i);
1545             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1546             av.mul(bv, vmask).intoArray(r, i);
1547         }
1548 
1549         assertArraysEquals(r, a, b, mask, Int128VectorTests::mul);
1550     }
1551 
1552 
1553 
1554     static int DIV(int a, int b) {
1555         return (int)(a / b);
1556     }
1557 
1558     @Test(dataProvider = "intBinaryOpProvider")
1559     static void DIVInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1560         int[] a = fa.apply(SPECIES.length());
1561         int[] b = fb.apply(SPECIES.length());
1562         int[] r = fr.apply(SPECIES.length());
1563 
1564         replaceZero(b, (int) 1);
1565 
1566         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1567             for (int i = 0; i < a.length; i += SPECIES.length()) {
1568                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1569                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1570                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1571             }
1572         }
1573 
1574         assertArraysEquals(r, a, b, Int128VectorTests::DIV);
1575     }
1576     static int div(int a, int b) {
1577         return (int)(a / b);
1578     }
1579 
1580     @Test(dataProvider = "intBinaryOpProvider")
1581     static void divInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1582         int[] a = fa.apply(SPECIES.length());
1583         int[] b = fb.apply(SPECIES.length());
1584         int[] r = fr.apply(SPECIES.length());
1585 
1586         replaceZero(b, (int) 1);
1587 
1588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1589             for (int i = 0; i < a.length; i += SPECIES.length()) {
1590                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1591                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1592                 av.div(bv).intoArray(r, i);
1593             }
1594         }
1595 
1596         assertArraysEquals(r, a, b, Int128VectorTests::div);
1597     }
1598 
1599 
1600 
1601     @Test(dataProvider = "intBinaryOpMaskProvider")
1602     static void DIVInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1603                                           IntFunction<boolean[]> fm) {
1604         int[] a = fa.apply(SPECIES.length());
1605         int[] b = fb.apply(SPECIES.length());
1606         int[] r = fr.apply(SPECIES.length());
1607         boolean[] mask = fm.apply(SPECIES.length());
1608         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1609 
1610         replaceZero(b, mask, (int) 1);
1611 
1612         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1613             for (int i = 0; i < a.length; i += SPECIES.length()) {
1614                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1615                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1616                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1617             }
1618         }
1619 
1620         assertArraysEquals(r, a, b, mask, Int128VectorTests::DIV);
1621     }
1622 
1623     @Test(dataProvider = "intBinaryOpMaskProvider")
1624     static void divInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1625                                           IntFunction<boolean[]> fm) {
1626         int[] a = fa.apply(SPECIES.length());
1627         int[] b = fb.apply(SPECIES.length());
1628         int[] r = fr.apply(SPECIES.length());
1629         boolean[] mask = fm.apply(SPECIES.length());
1630         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1631 
1632         replaceZero(b, mask, (int) 1);
1633 
1634         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1635             for (int i = 0; i < a.length; i += SPECIES.length()) {
1636                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1637                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1638                 av.div(bv, vmask).intoArray(r, i);
1639             }
1640         }
1641 
1642         assertArraysEquals(r, a, b, mask, Int128VectorTests::div);
1643     }
1644 
1645     static int FIRST_NONZERO(int a, int b) {
1646         return (int)((a)!=0?a:b);
1647     }
1648 
1649     @Test(dataProvider = "intBinaryOpProvider")
1650     static void FIRST_NONZEROInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1651         int[] a = fa.apply(SPECIES.length());
1652         int[] b = fb.apply(SPECIES.length());
1653         int[] r = fr.apply(SPECIES.length());
1654 
1655         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1656             for (int i = 0; i < a.length; i += SPECIES.length()) {
1657                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1658                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1659                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1660             }
1661         }
1662 
1663         assertArraysEquals(r, a, b, Int128VectorTests::FIRST_NONZERO);
1664     }
1665 
1666     @Test(dataProvider = "intBinaryOpMaskProvider")
1667     static void FIRST_NONZEROInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1668                                           IntFunction<boolean[]> fm) {
1669         int[] a = fa.apply(SPECIES.length());
1670         int[] b = fb.apply(SPECIES.length());
1671         int[] r = fr.apply(SPECIES.length());
1672         boolean[] mask = fm.apply(SPECIES.length());
1673         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1674 
1675         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1676             for (int i = 0; i < a.length; i += SPECIES.length()) {
1677                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1678                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1679                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1680             }
1681         }
1682 
1683         assertArraysEquals(r, a, b, mask, Int128VectorTests::FIRST_NONZERO);
1684     }
1685 
1686     static int AND(int a, int b) {
1687         return (int)(a & b);
1688     }
1689 
1690     @Test(dataProvider = "intBinaryOpProvider")
1691     static void ANDInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1692         int[] a = fa.apply(SPECIES.length());
1693         int[] b = fb.apply(SPECIES.length());
1694         int[] r = fr.apply(SPECIES.length());
1695 
1696         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1697             for (int i = 0; i < a.length; i += SPECIES.length()) {
1698                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1699                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1700                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1701             }
1702         }
1703 
1704         assertArraysEquals(r, a, b, Int128VectorTests::AND);
1705     }
1706     static int and(int a, int b) {
1707         return (int)(a & b);
1708     }
1709 
1710     @Test(dataProvider = "intBinaryOpProvider")
1711     static void andInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1712         int[] a = fa.apply(SPECIES.length());
1713         int[] b = fb.apply(SPECIES.length());
1714         int[] r = fr.apply(SPECIES.length());
1715 
1716         for (int i = 0; i < a.length; i += SPECIES.length()) {
1717             IntVector av = IntVector.fromArray(SPECIES, a, i);
1718             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1719             av.and(bv).intoArray(r, i);
1720         }
1721 
1722         assertArraysEquals(r, a, b, Int128VectorTests::and);
1723     }
1724 
1725 
1726 
1727     @Test(dataProvider = "intBinaryOpMaskProvider")
1728     static void ANDInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1729                                           IntFunction<boolean[]> fm) {
1730         int[] a = fa.apply(SPECIES.length());
1731         int[] b = fb.apply(SPECIES.length());
1732         int[] r = fr.apply(SPECIES.length());
1733         boolean[] mask = fm.apply(SPECIES.length());
1734         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1735 
1736         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1737             for (int i = 0; i < a.length; i += SPECIES.length()) {
1738                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1739                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1740                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1741             }
1742         }
1743 
1744         assertArraysEquals(r, a, b, mask, Int128VectorTests::AND);
1745     }
1746 
1747 
1748     static int AND_NOT(int a, int b) {
1749         return (int)(a & ~b);
1750     }
1751 
1752     @Test(dataProvider = "intBinaryOpProvider")
1753     static void AND_NOTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1754         int[] a = fa.apply(SPECIES.length());
1755         int[] b = fb.apply(SPECIES.length());
1756         int[] r = fr.apply(SPECIES.length());
1757 
1758         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1759             for (int i = 0; i < a.length; i += SPECIES.length()) {
1760                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1761                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1762                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1763             }
1764         }
1765 
1766         assertArraysEquals(r, a, b, Int128VectorTests::AND_NOT);
1767     }
1768 
1769 
1770 
1771     @Test(dataProvider = "intBinaryOpMaskProvider")
1772     static void AND_NOTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1773                                           IntFunction<boolean[]> fm) {
1774         int[] a = fa.apply(SPECIES.length());
1775         int[] b = fb.apply(SPECIES.length());
1776         int[] r = fr.apply(SPECIES.length());
1777         boolean[] mask = fm.apply(SPECIES.length());
1778         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1779 
1780         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1781             for (int i = 0; i < a.length; i += SPECIES.length()) {
1782                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1783                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1784                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1785             }
1786         }
1787 
1788         assertArraysEquals(r, a, b, mask, Int128VectorTests::AND_NOT);
1789     }
1790 
1791 
1792     static int OR(int a, int b) {
1793         return (int)(a | b);
1794     }
1795 
1796     @Test(dataProvider = "intBinaryOpProvider")
1797     static void ORInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1798         int[] a = fa.apply(SPECIES.length());
1799         int[] b = fb.apply(SPECIES.length());
1800         int[] r = fr.apply(SPECIES.length());
1801 
1802         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1803             for (int i = 0; i < a.length; i += SPECIES.length()) {
1804                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1805                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1806                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1807             }
1808         }
1809 
1810         assertArraysEquals(r, a, b, Int128VectorTests::OR);
1811     }
1812     static int or(int a, int b) {
1813         return (int)(a | b);
1814     }
1815 
1816     @Test(dataProvider = "intBinaryOpProvider")
1817     static void orInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1818         int[] a = fa.apply(SPECIES.length());
1819         int[] b = fb.apply(SPECIES.length());
1820         int[] r = fr.apply(SPECIES.length());
1821 
1822         for (int i = 0; i < a.length; i += SPECIES.length()) {
1823             IntVector av = IntVector.fromArray(SPECIES, a, i);
1824             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1825             av.or(bv).intoArray(r, i);
1826         }
1827 
1828         assertArraysEquals(r, a, b, Int128VectorTests::or);
1829     }
1830 
1831 
1832 
1833     @Test(dataProvider = "intBinaryOpMaskProvider")
1834     static void ORInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1835                                           IntFunction<boolean[]> fm) {
1836         int[] a = fa.apply(SPECIES.length());
1837         int[] b = fb.apply(SPECIES.length());
1838         int[] r = fr.apply(SPECIES.length());
1839         boolean[] mask = fm.apply(SPECIES.length());
1840         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1841 
1842         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1843             for (int i = 0; i < a.length; i += SPECIES.length()) {
1844                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1845                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1846                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1847             }
1848         }
1849 
1850         assertArraysEquals(r, a, b, mask, Int128VectorTests::OR);
1851     }
1852 
1853 
1854     static int XOR(int a, int b) {
1855         return (int)(a ^ b);
1856     }
1857 
1858     @Test(dataProvider = "intBinaryOpProvider")
1859     static void XORInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1860         int[] a = fa.apply(SPECIES.length());
1861         int[] b = fb.apply(SPECIES.length());
1862         int[] r = fr.apply(SPECIES.length());
1863 
1864         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1865             for (int i = 0; i < a.length; i += SPECIES.length()) {
1866                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1867                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1868                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1869             }
1870         }
1871 
1872         assertArraysEquals(r, a, b, Int128VectorTests::XOR);
1873     }
1874 
1875 
1876 
1877     @Test(dataProvider = "intBinaryOpMaskProvider")
1878     static void XORInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1879                                           IntFunction<boolean[]> fm) {
1880         int[] a = fa.apply(SPECIES.length());
1881         int[] b = fb.apply(SPECIES.length());
1882         int[] r = fr.apply(SPECIES.length());
1883         boolean[] mask = fm.apply(SPECIES.length());
1884         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1885 
1886         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1887             for (int i = 0; i < a.length; i += SPECIES.length()) {
1888                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1889                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1890                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1891             }
1892         }
1893 
1894         assertArraysEquals(r, a, b, mask, Int128VectorTests::XOR);
1895     }
1896 
1897 
1898     @Test(dataProvider = "intBinaryOpProvider")
1899     static void addInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1900         int[] a = fa.apply(SPECIES.length());
1901         int[] b = fb.apply(SPECIES.length());
1902         int[] r = fr.apply(SPECIES.length());
1903 
1904         for (int i = 0; i < a.length; i += SPECIES.length()) {
1905             IntVector av = IntVector.fromArray(SPECIES, a, i);
1906             av.add(b[i]).intoArray(r, i);
1907         }
1908 
1909         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::add);
1910     }
1911 
1912     @Test(dataProvider = "intBinaryOpMaskProvider")
1913     static void addInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
1914                                           IntFunction<boolean[]> fm) {
1915         int[] a = fa.apply(SPECIES.length());
1916         int[] b = fb.apply(SPECIES.length());
1917         int[] r = fr.apply(SPECIES.length());
1918         boolean[] mask = fm.apply(SPECIES.length());
1919         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1920 
1921         for (int i = 0; i < a.length; i += SPECIES.length()) {
1922             IntVector av = IntVector.fromArray(SPECIES, a, i);
1923             av.add(b[i], vmask).intoArray(r, i);
1924         }
1925 
1926         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::add);
1927     }
1928 
1929     @Test(dataProvider = "intBinaryOpProvider")
1930     static void subInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1931         int[] a = fa.apply(SPECIES.length());
1932         int[] b = fb.apply(SPECIES.length());
1933         int[] r = fr.apply(SPECIES.length());
1934 
1935         for (int i = 0; i < a.length; i += SPECIES.length()) {
1936             IntVector av = IntVector.fromArray(SPECIES, a, i);
1937             av.sub(b[i]).intoArray(r, i);
1938         }
1939 
1940         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::sub);
1941     }
1942 
1943     @Test(dataProvider = "intBinaryOpMaskProvider")
1944     static void subInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
1945                                           IntFunction<boolean[]> fm) {
1946         int[] a = fa.apply(SPECIES.length());
1947         int[] b = fb.apply(SPECIES.length());
1948         int[] r = fr.apply(SPECIES.length());
1949         boolean[] mask = fm.apply(SPECIES.length());
1950         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1951 
1952         for (int i = 0; i < a.length; i += SPECIES.length()) {
1953             IntVector av = IntVector.fromArray(SPECIES, a, i);
1954             av.sub(b[i], vmask).intoArray(r, i);
1955         }
1956 
1957         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::sub);
1958     }
1959 
1960     @Test(dataProvider = "intBinaryOpProvider")
1961     static void mulInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1962         int[] a = fa.apply(SPECIES.length());
1963         int[] b = fb.apply(SPECIES.length());
1964         int[] r = fr.apply(SPECIES.length());
1965 
1966         for (int i = 0; i < a.length; i += SPECIES.length()) {
1967             IntVector av = IntVector.fromArray(SPECIES, a, i);
1968             av.mul(b[i]).intoArray(r, i);
1969         }
1970 
1971         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::mul);
1972     }
1973 
1974     @Test(dataProvider = "intBinaryOpMaskProvider")
1975     static void mulInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
1976                                           IntFunction<boolean[]> fm) {
1977         int[] a = fa.apply(SPECIES.length());
1978         int[] b = fb.apply(SPECIES.length());
1979         int[] r = fr.apply(SPECIES.length());
1980         boolean[] mask = fm.apply(SPECIES.length());
1981         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1982 
1983         for (int i = 0; i < a.length; i += SPECIES.length()) {
1984             IntVector av = IntVector.fromArray(SPECIES, a, i);
1985             av.mul(b[i], vmask).intoArray(r, i);
1986         }
1987 
1988         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::mul);
1989     }
1990 
1991 
1992 
1993 
1994     @Test(dataProvider = "intBinaryOpProvider")
1995     static void divInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1996         int[] a = fa.apply(SPECIES.length());
1997         int[] b = fb.apply(SPECIES.length());
1998         int[] r = fr.apply(SPECIES.length());
1999 
2000         replaceZero(b, (int) 1);
2001 
2002         for (int i = 0; i < a.length; i += SPECIES.length()) {
2003             IntVector av = IntVector.fromArray(SPECIES, a, i);
2004             av.div(b[i]).intoArray(r, i);
2005         }
2006 
2007         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::div);
2008     }
2009 
2010 
2011 
2012     @Test(dataProvider = "intBinaryOpMaskProvider")
2013     static void divInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2014                                           IntFunction<boolean[]> fm) {
2015         int[] a = fa.apply(SPECIES.length());
2016         int[] b = fb.apply(SPECIES.length());
2017         int[] r = fr.apply(SPECIES.length());
2018         boolean[] mask = fm.apply(SPECIES.length());
2019         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2020 
2021         replaceZero(b, (int) 1);
2022 
2023         for (int i = 0; i < a.length; i += SPECIES.length()) {
2024             IntVector av = IntVector.fromArray(SPECIES, a, i);
2025             av.div(b[i], vmask).intoArray(r, i);
2026         }
2027 
2028         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::div);
2029     }
2030 
2031 
2032 
2033     @Test(dataProvider = "intBinaryOpProvider")
2034     static void ORInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2035         int[] a = fa.apply(SPECIES.length());
2036         int[] b = fb.apply(SPECIES.length());
2037         int[] r = fr.apply(SPECIES.length());
2038 
2039         for (int i = 0; i < a.length; i += SPECIES.length()) {
2040             IntVector av = IntVector.fromArray(SPECIES, a, i);
2041             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2042         }
2043 
2044         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::OR);
2045     }
2046 
2047     @Test(dataProvider = "intBinaryOpProvider")
2048     static void orInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2049         int[] a = fa.apply(SPECIES.length());
2050         int[] b = fb.apply(SPECIES.length());
2051         int[] r = fr.apply(SPECIES.length());
2052 
2053         for (int i = 0; i < a.length; i += SPECIES.length()) {
2054             IntVector av = IntVector.fromArray(SPECIES, a, i);
2055             av.or(b[i]).intoArray(r, i);
2056         }
2057 
2058         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::or);
2059     }
2060 
2061 
2062 
2063     @Test(dataProvider = "intBinaryOpMaskProvider")
2064     static void ORInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2065                                           IntFunction<boolean[]> fm) {
2066         int[] a = fa.apply(SPECIES.length());
2067         int[] b = fb.apply(SPECIES.length());
2068         int[] r = fr.apply(SPECIES.length());
2069         boolean[] mask = fm.apply(SPECIES.length());
2070         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2071 
2072         for (int i = 0; i < a.length; i += SPECIES.length()) {
2073             IntVector av = IntVector.fromArray(SPECIES, a, i);
2074             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2075         }
2076 
2077         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::OR);
2078     }
2079 
2080 
2081 
2082     @Test(dataProvider = "intBinaryOpProvider")
2083     static void ANDInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2084         int[] a = fa.apply(SPECIES.length());
2085         int[] b = fb.apply(SPECIES.length());
2086         int[] r = fr.apply(SPECIES.length());
2087 
2088         for (int i = 0; i < a.length; i += SPECIES.length()) {
2089             IntVector av = IntVector.fromArray(SPECIES, a, i);
2090             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2091         }
2092 
2093         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::AND);
2094     }
2095 
2096     @Test(dataProvider = "intBinaryOpProvider")
2097     static void andInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2098         int[] a = fa.apply(SPECIES.length());
2099         int[] b = fb.apply(SPECIES.length());
2100         int[] r = fr.apply(SPECIES.length());
2101 
2102         for (int i = 0; i < a.length; i += SPECIES.length()) {
2103             IntVector av = IntVector.fromArray(SPECIES, a, i);
2104             av.and(b[i]).intoArray(r, i);
2105         }
2106 
2107         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::and);
2108     }
2109 
2110 
2111 
2112     @Test(dataProvider = "intBinaryOpMaskProvider")
2113     static void ANDInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2114                                           IntFunction<boolean[]> fm) {
2115         int[] a = fa.apply(SPECIES.length());
2116         int[] b = fb.apply(SPECIES.length());
2117         int[] r = fr.apply(SPECIES.length());
2118         boolean[] mask = fm.apply(SPECIES.length());
2119         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2120 
2121         for (int i = 0; i < a.length; i += SPECIES.length()) {
2122             IntVector av = IntVector.fromArray(SPECIES, a, i);
2123             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2124         }
2125 
2126         assertBroadcastArraysEquals(r, a, b, mask, Int128VectorTests::AND);
2127     }
2128 
2129 
2130 
2131     @Test(dataProvider = "intBinaryOpProvider")
2132     static void ORInt128VectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2133         int[] a = fa.apply(SPECIES.length());
2134         int[] b = fb.apply(SPECIES.length());
2135         int[] r = fr.apply(SPECIES.length());
2136 
2137         for (int i = 0; i < a.length; i += SPECIES.length()) {
2138             IntVector av = IntVector.fromArray(SPECIES, a, i);
2139             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2140         }
2141 
2142         assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::OR);
2143     }
2144 
2145 
2146 
2147     @Test(dataProvider = "intBinaryOpMaskProvider")
2148     static void ORInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2149                                           IntFunction<boolean[]> fm) {
2150         int[] a = fa.apply(SPECIES.length());
2151         int[] b = fb.apply(SPECIES.length());
2152         int[] r = fr.apply(SPECIES.length());
2153         boolean[] mask = fm.apply(SPECIES.length());
2154         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2155 
2156         for (int i = 0; i < a.length; i += SPECIES.length()) {
2157             IntVector av = IntVector.fromArray(SPECIES, a, i);
2158             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2159         }
2160 
2161         assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::OR);
2162     }
2163 
2164 
2165     @Test(dataProvider = "intBinaryOpProvider")
2166     static void ADDInt128VectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2167         int[] a = fa.apply(SPECIES.length());
2168         int[] b = fb.apply(SPECIES.length());
2169         int[] r = fr.apply(SPECIES.length());
2170 
2171         for (int i = 0; i < a.length; i += SPECIES.length()) {
2172             IntVector av = IntVector.fromArray(SPECIES, a, i);
2173             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2174         }
2175 
2176         assertBroadcastLongArraysEquals(r, a, b, Int128VectorTests::ADD);
2177     }
2178 
2179     @Test(dataProvider = "intBinaryOpMaskProvider")
2180     static void ADDInt128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2181                                           IntFunction<boolean[]> fm) {
2182         int[] a = fa.apply(SPECIES.length());
2183         int[] b = fb.apply(SPECIES.length());
2184         int[] r = fr.apply(SPECIES.length());
2185         boolean[] mask = fm.apply(SPECIES.length());
2186         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2187 
2188         for (int i = 0; i < a.length; i += SPECIES.length()) {
2189             IntVector av = IntVector.fromArray(SPECIES, a, i);
2190             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2191         }
2192 
2193         assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::ADD);
2194     }
2195 
2196     static int LSHL(int a, int b) {
2197         return (int)((a << b));
2198     }
2199 
2200     @Test(dataProvider = "intBinaryOpProvider")
2201     static void LSHLInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2202         int[] a = fa.apply(SPECIES.length());
2203         int[] b = fb.apply(SPECIES.length());
2204         int[] r = fr.apply(SPECIES.length());
2205 
2206         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2207             for (int i = 0; i < a.length; i += SPECIES.length()) {
2208                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2209                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2210                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2211             }
2212         }
2213 
2214         assertArraysEquals(r, a, b, Int128VectorTests::LSHL);
2215     }
2216 
2217 
2218 
2219     @Test(dataProvider = "intBinaryOpMaskProvider")
2220     static void LSHLInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2221                                           IntFunction<boolean[]> fm) {
2222         int[] a = fa.apply(SPECIES.length());
2223         int[] b = fb.apply(SPECIES.length());
2224         int[] r = fr.apply(SPECIES.length());
2225         boolean[] mask = fm.apply(SPECIES.length());
2226         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2227 
2228         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2229             for (int i = 0; i < a.length; i += SPECIES.length()) {
2230                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2231                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2232                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2233             }
2234         }
2235 
2236         assertArraysEquals(r, a, b, mask, Int128VectorTests::LSHL);
2237     }
2238 
2239 
2240 
2241 
2242 
2243 
2244     static int ASHR(int a, int b) {
2245         return (int)((a >> b));
2246     }
2247 
2248     @Test(dataProvider = "intBinaryOpProvider")
2249     static void ASHRInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2250         int[] a = fa.apply(SPECIES.length());
2251         int[] b = fb.apply(SPECIES.length());
2252         int[] r = fr.apply(SPECIES.length());
2253 
2254         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2255             for (int i = 0; i < a.length; i += SPECIES.length()) {
2256                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2257                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2258                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2259             }
2260         }
2261 
2262         assertArraysEquals(r, a, b, Int128VectorTests::ASHR);
2263     }
2264 
2265 
2266 
2267     @Test(dataProvider = "intBinaryOpMaskProvider")
2268     static void ASHRInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2269                                           IntFunction<boolean[]> fm) {
2270         int[] a = fa.apply(SPECIES.length());
2271         int[] b = fb.apply(SPECIES.length());
2272         int[] r = fr.apply(SPECIES.length());
2273         boolean[] mask = fm.apply(SPECIES.length());
2274         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2275 
2276         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2277             for (int i = 0; i < a.length; i += SPECIES.length()) {
2278                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2279                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2280                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2281             }
2282         }
2283 
2284         assertArraysEquals(r, a, b, mask, Int128VectorTests::ASHR);
2285     }
2286 
2287 
2288 
2289 
2290 
2291 
2292     static int LSHR(int a, int b) {
2293         return (int)((a >>> b));
2294     }
2295 
2296     @Test(dataProvider = "intBinaryOpProvider")
2297     static void LSHRInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2298         int[] a = fa.apply(SPECIES.length());
2299         int[] b = fb.apply(SPECIES.length());
2300         int[] r = fr.apply(SPECIES.length());
2301 
2302         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2303             for (int i = 0; i < a.length; i += SPECIES.length()) {
2304                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2305                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2306                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2307             }
2308         }
2309 
2310         assertArraysEquals(r, a, b, Int128VectorTests::LSHR);
2311     }
2312 
2313 
2314 
2315     @Test(dataProvider = "intBinaryOpMaskProvider")
2316     static void LSHRInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2317                                           IntFunction<boolean[]> fm) {
2318         int[] a = fa.apply(SPECIES.length());
2319         int[] b = fb.apply(SPECIES.length());
2320         int[] r = fr.apply(SPECIES.length());
2321         boolean[] mask = fm.apply(SPECIES.length());
2322         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2323 
2324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2325             for (int i = 0; i < a.length; i += SPECIES.length()) {
2326                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2327                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2328                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2329             }
2330         }
2331 
2332         assertArraysEquals(r, a, b, mask, Int128VectorTests::LSHR);
2333     }
2334 
2335 
2336 
2337 
2338 
2339 
2340     static int LSHL_unary(int a, int b) {
2341         return (int)((a << b));
2342     }
2343 
2344     @Test(dataProvider = "intBinaryOpProvider")
2345     static void LSHLInt128VectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2346         int[] a = fa.apply(SPECIES.length());
2347         int[] b = fb.apply(SPECIES.length());
2348         int[] r = fr.apply(SPECIES.length());
2349 
2350         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2351             for (int i = 0; i < a.length; i += SPECIES.length()) {
2352                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2353                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2354             }
2355         }
2356 
2357         assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHL_unary);
2358     }
2359 
2360 
2361 
2362     @Test(dataProvider = "intBinaryOpMaskProvider")
2363     static void LSHLInt128VectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2364                                           IntFunction<boolean[]> fm) {
2365         int[] a = fa.apply(SPECIES.length());
2366         int[] b = fb.apply(SPECIES.length());
2367         int[] r = fr.apply(SPECIES.length());
2368         boolean[] mask = fm.apply(SPECIES.length());
2369         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2370 
2371         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2372             for (int i = 0; i < a.length; i += SPECIES.length()) {
2373                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2374                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2375             }
2376         }
2377 
2378         assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHL_unary);
2379     }
2380 
2381 
2382 
2383 
2384 
2385 
2386     static int LSHR_unary(int a, int b) {
2387         return (int)((a >>> b));
2388     }
2389 
2390     @Test(dataProvider = "intBinaryOpProvider")
2391     static void LSHRInt128VectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2392         int[] a = fa.apply(SPECIES.length());
2393         int[] b = fb.apply(SPECIES.length());
2394         int[] r = fr.apply(SPECIES.length());
2395 
2396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2397             for (int i = 0; i < a.length; i += SPECIES.length()) {
2398                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2399                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2400             }
2401         }
2402 
2403         assertShiftArraysEquals(r, a, b, Int128VectorTests::LSHR_unary);
2404     }
2405 
2406 
2407 
2408     @Test(dataProvider = "intBinaryOpMaskProvider")
2409     static void LSHRInt128VectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2410                                           IntFunction<boolean[]> fm) {
2411         int[] a = fa.apply(SPECIES.length());
2412         int[] b = fb.apply(SPECIES.length());
2413         int[] r = fr.apply(SPECIES.length());
2414         boolean[] mask = fm.apply(SPECIES.length());
2415         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2416 
2417         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2418             for (int i = 0; i < a.length; i += SPECIES.length()) {
2419                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2420                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2421             }
2422         }
2423 
2424         assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::LSHR_unary);
2425     }
2426 
2427 
2428 
2429 
2430 
2431 
2432     static int ASHR_unary(int a, int b) {
2433         return (int)((a >> b));
2434     }
2435 
2436     @Test(dataProvider = "intBinaryOpProvider")
2437     static void ASHRInt128VectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2438         int[] a = fa.apply(SPECIES.length());
2439         int[] b = fb.apply(SPECIES.length());
2440         int[] r = fr.apply(SPECIES.length());
2441 
2442         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2443             for (int i = 0; i < a.length; i += SPECIES.length()) {
2444                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2445                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2446             }
2447         }
2448 
2449         assertShiftArraysEquals(r, a, b, Int128VectorTests::ASHR_unary);
2450     }
2451 
2452 
2453 
2454     @Test(dataProvider = "intBinaryOpMaskProvider")
2455     static void ASHRInt128VectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2456                                           IntFunction<boolean[]> fm) {
2457         int[] a = fa.apply(SPECIES.length());
2458         int[] b = fb.apply(SPECIES.length());
2459         int[] r = fr.apply(SPECIES.length());
2460         boolean[] mask = fm.apply(SPECIES.length());
2461         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2462 
2463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2464             for (int i = 0; i < a.length; i += SPECIES.length()) {
2465                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2466                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2467             }
2468         }
2469 
2470         assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ASHR_unary);
2471     }
2472 
2473 
2474 
2475 
2476 
2477 
2478     static int ROR(int a, int b) {
2479         return (int)(ROR_scalar(a,b));
2480     }
2481 
2482     @Test(dataProvider = "intBinaryOpProvider")
2483     static void RORInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2484         int[] a = fa.apply(SPECIES.length());
2485         int[] b = fb.apply(SPECIES.length());
2486         int[] r = fr.apply(SPECIES.length());
2487 
2488         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2489             for (int i = 0; i < a.length; i += SPECIES.length()) {
2490                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2491                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2492                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2493             }
2494         }
2495 
2496         assertArraysEquals(r, a, b, Int128VectorTests::ROR);
2497     }
2498 
2499 
2500 
2501     @Test(dataProvider = "intBinaryOpMaskProvider")
2502     static void RORInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2503                                           IntFunction<boolean[]> fm) {
2504         int[] a = fa.apply(SPECIES.length());
2505         int[] b = fb.apply(SPECIES.length());
2506         int[] r = fr.apply(SPECIES.length());
2507         boolean[] mask = fm.apply(SPECIES.length());
2508         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2509 
2510         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2511             for (int i = 0; i < a.length; i += SPECIES.length()) {
2512                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2513                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2514                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2515             }
2516         }
2517 
2518         assertArraysEquals(r, a, b, mask, Int128VectorTests::ROR);
2519     }
2520 
2521 
2522     static int ROL(int a, int b) {
2523         return (int)(ROL_scalar(a,b));
2524     }
2525 
2526     @Test(dataProvider = "intBinaryOpProvider")
2527     static void ROLInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2528         int[] a = fa.apply(SPECIES.length());
2529         int[] b = fb.apply(SPECIES.length());
2530         int[] r = fr.apply(SPECIES.length());
2531 
2532         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2533             for (int i = 0; i < a.length; i += SPECIES.length()) {
2534                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2535                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2536                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2537             }
2538         }
2539 
2540         assertArraysEquals(r, a, b, Int128VectorTests::ROL);
2541     }
2542 
2543 
2544 
2545     @Test(dataProvider = "intBinaryOpMaskProvider")
2546     static void ROLInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2547                                           IntFunction<boolean[]> fm) {
2548         int[] a = fa.apply(SPECIES.length());
2549         int[] b = fb.apply(SPECIES.length());
2550         int[] r = fr.apply(SPECIES.length());
2551         boolean[] mask = fm.apply(SPECIES.length());
2552         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2553 
2554         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2555             for (int i = 0; i < a.length; i += SPECIES.length()) {
2556                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2557                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2558                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2559             }
2560         }
2561 
2562         assertArraysEquals(r, a, b, mask, Int128VectorTests::ROL);
2563     }
2564 
2565 
2566     static int ROR_unary(int a, int b) {
2567         return (int)(ROR_scalar(a,b));
2568     }
2569 
2570     @Test(dataProvider = "intBinaryOpProvider")
2571     static void RORInt128VectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2572         int[] a = fa.apply(SPECIES.length());
2573         int[] b = fb.apply(SPECIES.length());
2574         int[] r = fr.apply(SPECIES.length());
2575 
2576         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2577             for (int i = 0; i < a.length; i += SPECIES.length()) {
2578                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2579                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2580             }
2581         }
2582 
2583         assertShiftArraysEquals(r, a, b, Int128VectorTests::ROR_unary);
2584     }
2585 
2586 
2587 
2588     @Test(dataProvider = "intBinaryOpMaskProvider")
2589     static void RORInt128VectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2590                                           IntFunction<boolean[]> fm) {
2591         int[] a = fa.apply(SPECIES.length());
2592         int[] b = fb.apply(SPECIES.length());
2593         int[] r = fr.apply(SPECIES.length());
2594         boolean[] mask = fm.apply(SPECIES.length());
2595         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2596 
2597         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2598             for (int i = 0; i < a.length; i += SPECIES.length()) {
2599                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2600                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2601             }
2602         }
2603 
2604         assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ROR_unary);
2605     }
2606 
2607 
2608     static int ROL_unary(int a, int b) {
2609         return (int)(ROL_scalar(a,b));
2610     }
2611 
2612     @Test(dataProvider = "intBinaryOpProvider")
2613     static void ROLInt128VectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2614         int[] a = fa.apply(SPECIES.length());
2615         int[] b = fb.apply(SPECIES.length());
2616         int[] r = fr.apply(SPECIES.length());
2617 
2618         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2619             for (int i = 0; i < a.length; i += SPECIES.length()) {
2620                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2621                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2622             }
2623         }
2624 
2625         assertShiftArraysEquals(r, a, b, Int128VectorTests::ROL_unary);
2626     }
2627 
2628 
2629 
2630     @Test(dataProvider = "intBinaryOpMaskProvider")
2631     static void ROLInt128VectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2632                                           IntFunction<boolean[]> fm) {
2633         int[] a = fa.apply(SPECIES.length());
2634         int[] b = fb.apply(SPECIES.length());
2635         int[] r = fr.apply(SPECIES.length());
2636         boolean[] mask = fm.apply(SPECIES.length());
2637         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2638 
2639         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2640             for (int i = 0; i < a.length; i += SPECIES.length()) {
2641                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2642                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2643             }
2644         }
2645 
2646         assertShiftArraysEquals(r, a, b, mask, Int128VectorTests::ROL_unary);
2647     }
2648 
2649     static int MIN(int a, int b) {
2650         return (int)(Math.min(a, b));
2651     }
2652 
2653     @Test(dataProvider = "intBinaryOpProvider")
2654     static void MINInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2655         int[] a = fa.apply(SPECIES.length());
2656         int[] b = fb.apply(SPECIES.length());
2657         int[] r = fr.apply(SPECIES.length());
2658 
2659         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2660             for (int i = 0; i < a.length; i += SPECIES.length()) {
2661                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2662                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2663                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2664             }
2665         }
2666 
2667         assertArraysEquals(r, a, b, Int128VectorTests::MIN);
2668     }
2669     static int min(int a, int b) {
2670         return (int)(Math.min(a, b));
2671     }
2672 
2673     @Test(dataProvider = "intBinaryOpProvider")
2674     static void minInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2675         int[] a = fa.apply(SPECIES.length());
2676         int[] b = fb.apply(SPECIES.length());
2677         int[] r = fr.apply(SPECIES.length());
2678 
2679         for (int i = 0; i < a.length; i += SPECIES.length()) {
2680             IntVector av = IntVector.fromArray(SPECIES, a, i);
2681             IntVector bv = IntVector.fromArray(SPECIES, b, i);
2682             av.min(bv).intoArray(r, i);
2683         }
2684 
2685         assertArraysEquals(r, a, b, Int128VectorTests::min);
2686     }
2687     static int MAX(int a, int b) {
2688         return (int)(Math.max(a, b));
2689     }
2690 
2691     @Test(dataProvider = "intBinaryOpProvider")
2692     static void MAXInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2693         int[] a = fa.apply(SPECIES.length());
2694         int[] b = fb.apply(SPECIES.length());
2695         int[] r = fr.apply(SPECIES.length());
2696 
2697         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2698             for (int i = 0; i < a.length; i += SPECIES.length()) {
2699                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2700                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2701                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2702             }
2703         }
2704 
2705         assertArraysEquals(r, a, b, Int128VectorTests::MAX);
2706     }
2707     static int max(int a, int b) {
2708         return (int)(Math.max(a, b));
2709     }
2710 
2711     @Test(dataProvider = "intBinaryOpProvider")
2712     static void maxInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2713         int[] a = fa.apply(SPECIES.length());
2714         int[] b = fb.apply(SPECIES.length());
2715         int[] r = fr.apply(SPECIES.length());
2716 
2717         for (int i = 0; i < a.length; i += SPECIES.length()) {
2718             IntVector av = IntVector.fromArray(SPECIES, a, i);
2719             IntVector bv = IntVector.fromArray(SPECIES, b, i);
2720             av.max(bv).intoArray(r, i);
2721         }
2722 
2723         assertArraysEquals(r, a, b, Int128VectorTests::max);
2724     }
2725 
2726     @Test(dataProvider = "intBinaryOpProvider")
2727     static void MINInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2728         int[] a = fa.apply(SPECIES.length());
2729         int[] b = fb.apply(SPECIES.length());
2730         int[] r = fr.apply(SPECIES.length());
2731 
2732         for (int i = 0; i < a.length; i += SPECIES.length()) {
2733             IntVector av = IntVector.fromArray(SPECIES, a, i);
2734             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
2735         }
2736 
2737         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MIN);
2738     }
2739 
2740     @Test(dataProvider = "intBinaryOpProvider")
2741     static void minInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2742         int[] a = fa.apply(SPECIES.length());
2743         int[] b = fb.apply(SPECIES.length());
2744         int[] r = fr.apply(SPECIES.length());
2745 
2746         for (int i = 0; i < a.length; i += SPECIES.length()) {
2747             IntVector av = IntVector.fromArray(SPECIES, a, i);
2748             av.min(b[i]).intoArray(r, i);
2749         }
2750 
2751         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::min);
2752     }
2753 
2754     @Test(dataProvider = "intBinaryOpProvider")
2755     static void MAXInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2756         int[] a = fa.apply(SPECIES.length());
2757         int[] b = fb.apply(SPECIES.length());
2758         int[] r = fr.apply(SPECIES.length());
2759 
2760         for (int i = 0; i < a.length; i += SPECIES.length()) {
2761             IntVector av = IntVector.fromArray(SPECIES, a, i);
2762             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
2763         }
2764 
2765         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::MAX);
2766     }
2767 
2768     @Test(dataProvider = "intBinaryOpProvider")
2769     static void maxInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2770         int[] a = fa.apply(SPECIES.length());
2771         int[] b = fb.apply(SPECIES.length());
2772         int[] r = fr.apply(SPECIES.length());
2773 
2774         for (int i = 0; i < a.length; i += SPECIES.length()) {
2775             IntVector av = IntVector.fromArray(SPECIES, a, i);
2776             av.max(b[i]).intoArray(r, i);
2777         }
2778 
2779         assertBroadcastArraysEquals(r, a, b, Int128VectorTests::max);
2780     }
2781 
2782     static int ANDReduce(int[] a, int idx) {
2783         int res = -1;
2784         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2785             res &= a[i];
2786         }
2787 
2788         return res;
2789     }
2790 
2791     static int ANDReduceAll(int[] a) {
2792         int res = -1;
2793         for (int i = 0; i < a.length; i += SPECIES.length()) {
2794             res &= ANDReduce(a, i);
2795         }
2796 
2797         return res;
2798     }
2799 
2800 
2801     @Test(dataProvider = "intUnaryOpProvider")
2802     static void ANDReduceInt128VectorTests(IntFunction<int[]> fa) {
2803         int[] a = fa.apply(SPECIES.length());
2804         int[] r = fr.apply(SPECIES.length());
2805         int ra = -1;
2806 
2807         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2808             for (int i = 0; i < a.length; i += SPECIES.length()) {
2809                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2810                 r[i] = av.reduceLanes(VectorOperators.AND);
2811             }
2812         }
2813 
2814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2815             ra = -1;
2816             for (int i = 0; i < a.length; i += SPECIES.length()) {
2817                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2818                 ra &= av.reduceLanes(VectorOperators.AND);
2819             }
2820         }
2821 
2822         assertReductionArraysEquals(r, ra, a,
2823                 Int128VectorTests::ANDReduce, Int128VectorTests::ANDReduceAll);
2824     }
2825 
2826 
2827     static int ANDReduceMasked(int[] a, int idx, boolean[] mask) {
2828         int res = -1;
2829         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2830             if (mask[i % SPECIES.length()])
2831                 res &= a[i];
2832         }
2833 
2834         return res;
2835     }
2836 
2837     static int ANDReduceAllMasked(int[] a, boolean[] mask) {
2838         int res = -1;
2839         for (int i = 0; i < a.length; i += SPECIES.length()) {
2840             res &= ANDReduceMasked(a, i, mask);
2841         }
2842 
2843         return res;
2844     }
2845 
2846 
2847     @Test(dataProvider = "intUnaryOpMaskProvider")
2848     static void ANDReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
2849         int[] a = fa.apply(SPECIES.length());
2850         int[] r = fr.apply(SPECIES.length());
2851         boolean[] mask = fm.apply(SPECIES.length());
2852         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2853         int ra = -1;
2854 
2855         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2856             for (int i = 0; i < a.length; i += SPECIES.length()) {
2857                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2858                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
2859             }
2860         }
2861 
2862         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2863             ra = -1;
2864             for (int i = 0; i < a.length; i += SPECIES.length()) {
2865                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2866                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
2867             }
2868         }
2869 
2870         assertReductionArraysEqualsMasked(r, ra, a, mask,
2871                 Int128VectorTests::ANDReduceMasked, Int128VectorTests::ANDReduceAllMasked);
2872     }
2873 
2874 
2875     static int ORReduce(int[] a, int idx) {
2876         int res = 0;
2877         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2878             res |= a[i];
2879         }
2880 
2881         return res;
2882     }
2883 
2884     static int ORReduceAll(int[] a) {
2885         int res = 0;
2886         for (int i = 0; i < a.length; i += SPECIES.length()) {
2887             res |= ORReduce(a, i);
2888         }
2889 
2890         return res;
2891     }
2892 
2893 
2894     @Test(dataProvider = "intUnaryOpProvider")
2895     static void ORReduceInt128VectorTests(IntFunction<int[]> fa) {
2896         int[] a = fa.apply(SPECIES.length());
2897         int[] r = fr.apply(SPECIES.length());
2898         int ra = 0;
2899 
2900         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2901             for (int i = 0; i < a.length; i += SPECIES.length()) {
2902                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2903                 r[i] = av.reduceLanes(VectorOperators.OR);
2904             }
2905         }
2906 
2907         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2908             ra = 0;
2909             for (int i = 0; i < a.length; i += SPECIES.length()) {
2910                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2911                 ra |= av.reduceLanes(VectorOperators.OR);
2912             }
2913         }
2914 
2915         assertReductionArraysEquals(r, ra, a,
2916                 Int128VectorTests::ORReduce, Int128VectorTests::ORReduceAll);
2917     }
2918 
2919 
2920     static int ORReduceMasked(int[] a, int idx, boolean[] mask) {
2921         int res = 0;
2922         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2923             if (mask[i % SPECIES.length()])
2924                 res |= a[i];
2925         }
2926 
2927         return res;
2928     }
2929 
2930     static int ORReduceAllMasked(int[] a, boolean[] mask) {
2931         int res = 0;
2932         for (int i = 0; i < a.length; i += SPECIES.length()) {
2933             res |= ORReduceMasked(a, i, mask);
2934         }
2935 
2936         return res;
2937     }
2938 
2939 
2940     @Test(dataProvider = "intUnaryOpMaskProvider")
2941     static void ORReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
2942         int[] a = fa.apply(SPECIES.length());
2943         int[] r = fr.apply(SPECIES.length());
2944         boolean[] mask = fm.apply(SPECIES.length());
2945         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2946         int ra = 0;
2947 
2948         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2949             for (int i = 0; i < a.length; i += SPECIES.length()) {
2950                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2951                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
2952             }
2953         }
2954 
2955         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2956             ra = 0;
2957             for (int i = 0; i < a.length; i += SPECIES.length()) {
2958                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2959                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
2960             }
2961         }
2962 
2963         assertReductionArraysEqualsMasked(r, ra, a, mask,
2964                 Int128VectorTests::ORReduceMasked, Int128VectorTests::ORReduceAllMasked);
2965     }
2966 
2967 
2968     static int XORReduce(int[] a, int idx) {
2969         int res = 0;
2970         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2971             res ^= a[i];
2972         }
2973 
2974         return res;
2975     }
2976 
2977     static int XORReduceAll(int[] a) {
2978         int res = 0;
2979         for (int i = 0; i < a.length; i += SPECIES.length()) {
2980             res ^= XORReduce(a, i);
2981         }
2982 
2983         return res;
2984     }
2985 
2986 
2987     @Test(dataProvider = "intUnaryOpProvider")
2988     static void XORReduceInt128VectorTests(IntFunction<int[]> fa) {
2989         int[] a = fa.apply(SPECIES.length());
2990         int[] r = fr.apply(SPECIES.length());
2991         int ra = 0;
2992 
2993         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2994             for (int i = 0; i < a.length; i += SPECIES.length()) {
2995                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2996                 r[i] = av.reduceLanes(VectorOperators.XOR);
2997             }
2998         }
2999 
3000         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3001             ra = 0;
3002             for (int i = 0; i < a.length; i += SPECIES.length()) {
3003                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3004                 ra ^= av.reduceLanes(VectorOperators.XOR);
3005             }
3006         }
3007 
3008         assertReductionArraysEquals(r, ra, a,
3009                 Int128VectorTests::XORReduce, Int128VectorTests::XORReduceAll);
3010     }
3011 
3012 
3013     static int XORReduceMasked(int[] a, int idx, boolean[] mask) {
3014         int res = 0;
3015         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3016             if (mask[i % SPECIES.length()])
3017                 res ^= a[i];
3018         }
3019 
3020         return res;
3021     }
3022 
3023     static int XORReduceAllMasked(int[] a, boolean[] mask) {
3024         int res = 0;
3025         for (int i = 0; i < a.length; i += SPECIES.length()) {
3026             res ^= XORReduceMasked(a, i, mask);
3027         }
3028 
3029         return res;
3030     }
3031 
3032 
3033     @Test(dataProvider = "intUnaryOpMaskProvider")
3034     static void XORReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3035         int[] a = fa.apply(SPECIES.length());
3036         int[] r = fr.apply(SPECIES.length());
3037         boolean[] mask = fm.apply(SPECIES.length());
3038         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3039         int ra = 0;
3040 
3041         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3042             for (int i = 0; i < a.length; i += SPECIES.length()) {
3043                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3044                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3045             }
3046         }
3047 
3048         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3049             ra = 0;
3050             for (int i = 0; i < a.length; i += SPECIES.length()) {
3051                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3052                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3053             }
3054         }
3055 
3056         assertReductionArraysEqualsMasked(r, ra, a, mask,
3057                 Int128VectorTests::XORReduceMasked, Int128VectorTests::XORReduceAllMasked);
3058     }
3059 
3060     static int ADDReduce(int[] a, int idx) {
3061         int res = 0;
3062         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3063             res += a[i];
3064         }
3065 
3066         return res;
3067     }
3068 
3069     static int ADDReduceAll(int[] a) {
3070         int res = 0;
3071         for (int i = 0; i < a.length; i += SPECIES.length()) {
3072             res += ADDReduce(a, i);
3073         }
3074 
3075         return res;
3076     }
3077     @Test(dataProvider = "intUnaryOpProvider")
3078     static void ADDReduceInt128VectorTests(IntFunction<int[]> fa) {
3079         int[] a = fa.apply(SPECIES.length());
3080         int[] r = fr.apply(SPECIES.length());
3081         int ra = 0;
3082 
3083         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3084             for (int i = 0; i < a.length; i += SPECIES.length()) {
3085                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3086                 r[i] = av.reduceLanes(VectorOperators.ADD);
3087             }
3088         }
3089 
3090         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3091             ra = 0;
3092             for (int i = 0; i < a.length; i += SPECIES.length()) {
3093                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3094                 ra += av.reduceLanes(VectorOperators.ADD);
3095             }
3096         }
3097 
3098         assertReductionArraysEquals(r, ra, a,
3099                 Int128VectorTests::ADDReduce, Int128VectorTests::ADDReduceAll);
3100     }
3101     static int ADDReduceMasked(int[] a, int idx, boolean[] mask) {
3102         int res = 0;
3103         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3104             if (mask[i % SPECIES.length()])
3105                 res += a[i];
3106         }
3107 
3108         return res;
3109     }
3110 
3111     static int ADDReduceAllMasked(int[] a, boolean[] mask) {
3112         int res = 0;
3113         for (int i = 0; i < a.length; i += SPECIES.length()) {
3114             res += ADDReduceMasked(a, i, mask);
3115         }
3116 
3117         return res;
3118     }
3119     @Test(dataProvider = "intUnaryOpMaskProvider")
3120     static void ADDReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3121         int[] a = fa.apply(SPECIES.length());
3122         int[] r = fr.apply(SPECIES.length());
3123         boolean[] mask = fm.apply(SPECIES.length());
3124         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3125         int ra = 0;
3126 
3127         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3128             for (int i = 0; i < a.length; i += SPECIES.length()) {
3129                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3130                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3131             }
3132         }
3133 
3134         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3135             ra = 0;
3136             for (int i = 0; i < a.length; i += SPECIES.length()) {
3137                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3138                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3139             }
3140         }
3141 
3142         assertReductionArraysEqualsMasked(r, ra, a, mask,
3143                 Int128VectorTests::ADDReduceMasked, Int128VectorTests::ADDReduceAllMasked);
3144     }
3145     static int MULReduce(int[] a, int idx) {
3146         int res = 1;
3147         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3148             res *= a[i];
3149         }
3150 
3151         return res;
3152     }
3153 
3154     static int MULReduceAll(int[] a) {
3155         int res = 1;
3156         for (int i = 0; i < a.length; i += SPECIES.length()) {
3157             res *= MULReduce(a, i);
3158         }
3159 
3160         return res;
3161     }
3162     @Test(dataProvider = "intUnaryOpProvider")
3163     static void MULReduceInt128VectorTests(IntFunction<int[]> fa) {
3164         int[] a = fa.apply(SPECIES.length());
3165         int[] r = fr.apply(SPECIES.length());
3166         int ra = 1;
3167 
3168         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3169             for (int i = 0; i < a.length; i += SPECIES.length()) {
3170                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3171                 r[i] = av.reduceLanes(VectorOperators.MUL);
3172             }
3173         }
3174 
3175         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3176             ra = 1;
3177             for (int i = 0; i < a.length; i += SPECIES.length()) {
3178                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3179                 ra *= av.reduceLanes(VectorOperators.MUL);
3180             }
3181         }
3182 
3183         assertReductionArraysEquals(r, ra, a,
3184                 Int128VectorTests::MULReduce, Int128VectorTests::MULReduceAll);
3185     }
3186     static int MULReduceMasked(int[] a, int idx, boolean[] mask) {
3187         int res = 1;
3188         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3189             if (mask[i % SPECIES.length()])
3190                 res *= a[i];
3191         }
3192 
3193         return res;
3194     }
3195 
3196     static int MULReduceAllMasked(int[] a, boolean[] mask) {
3197         int res = 1;
3198         for (int i = 0; i < a.length; i += SPECIES.length()) {
3199             res *= MULReduceMasked(a, i, mask);
3200         }
3201 
3202         return res;
3203     }
3204     @Test(dataProvider = "intUnaryOpMaskProvider")
3205     static void MULReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3206         int[] a = fa.apply(SPECIES.length());
3207         int[] r = fr.apply(SPECIES.length());
3208         boolean[] mask = fm.apply(SPECIES.length());
3209         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3210         int ra = 1;
3211 
3212         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3213             for (int i = 0; i < a.length; i += SPECIES.length()) {
3214                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3215                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3216             }
3217         }
3218 
3219         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3220             ra = 1;
3221             for (int i = 0; i < a.length; i += SPECIES.length()) {
3222                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3223                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3224             }
3225         }
3226 
3227         assertReductionArraysEqualsMasked(r, ra, a, mask,
3228                 Int128VectorTests::MULReduceMasked, Int128VectorTests::MULReduceAllMasked);
3229     }
3230     static int MINReduce(int[] a, int idx) {
3231         int res = Integer.MAX_VALUE;
3232         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3233             res = (int)Math.min(res, a[i]);
3234         }
3235 
3236         return res;
3237     }
3238 
3239     static int MINReduceAll(int[] a) {
3240         int res = Integer.MAX_VALUE;
3241         for (int i = 0; i < a.length; i++) {
3242             res = (int)Math.min(res, a[i]);
3243         }
3244 
3245         return res;
3246     }
3247     @Test(dataProvider = "intUnaryOpProvider")
3248     static void MINReduceInt128VectorTests(IntFunction<int[]> fa) {
3249         int[] a = fa.apply(SPECIES.length());
3250         int[] r = fr.apply(SPECIES.length());
3251         int ra = Integer.MAX_VALUE;
3252 
3253         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3254             for (int i = 0; i < a.length; i += SPECIES.length()) {
3255                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3256                 r[i] = av.reduceLanes(VectorOperators.MIN);
3257             }
3258         }
3259 
3260         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3261             ra = Integer.MAX_VALUE;
3262             for (int i = 0; i < a.length; i += SPECIES.length()) {
3263                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3264                 ra = (int)Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3265             }
3266         }
3267 
3268         assertReductionArraysEquals(r, ra, a,
3269                 Int128VectorTests::MINReduce, Int128VectorTests::MINReduceAll);
3270     }
3271     static int MINReduceMasked(int[] a, int idx, boolean[] mask) {
3272         int res = Integer.MAX_VALUE;
3273         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3274             if(mask[i % SPECIES.length()])
3275                 res = (int)Math.min(res, a[i]);
3276         }
3277 
3278         return res;
3279     }
3280 
3281     static int MINReduceAllMasked(int[] a, boolean[] mask) {
3282         int res = Integer.MAX_VALUE;
3283         for (int i = 0; i < a.length; i++) {
3284             if(mask[i % SPECIES.length()])
3285                 res = (int)Math.min(res, a[i]);
3286         }
3287 
3288         return res;
3289     }
3290     @Test(dataProvider = "intUnaryOpMaskProvider")
3291     static void MINReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3292         int[] a = fa.apply(SPECIES.length());
3293         int[] r = fr.apply(SPECIES.length());
3294         boolean[] mask = fm.apply(SPECIES.length());
3295         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3296         int ra = Integer.MAX_VALUE;
3297 
3298         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3299             for (int i = 0; i < a.length; i += SPECIES.length()) {
3300                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3301                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3302             }
3303         }
3304 
3305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3306             ra = Integer.MAX_VALUE;
3307             for (int i = 0; i < a.length; i += SPECIES.length()) {
3308                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3309                 ra = (int)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3310             }
3311         }
3312 
3313         assertReductionArraysEqualsMasked(r, ra, a, mask,
3314                 Int128VectorTests::MINReduceMasked, Int128VectorTests::MINReduceAllMasked);
3315     }
3316     static int MAXReduce(int[] a, int idx) {
3317         int res = Integer.MIN_VALUE;
3318         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3319             res = (int)Math.max(res, a[i]);
3320         }
3321 
3322         return res;
3323     }
3324 
3325     static int MAXReduceAll(int[] a) {
3326         int res = Integer.MIN_VALUE;
3327         for (int i = 0; i < a.length; i++) {
3328             res = (int)Math.max(res, a[i]);
3329         }
3330 
3331         return res;
3332     }
3333     @Test(dataProvider = "intUnaryOpProvider")
3334     static void MAXReduceInt128VectorTests(IntFunction<int[]> fa) {
3335         int[] a = fa.apply(SPECIES.length());
3336         int[] r = fr.apply(SPECIES.length());
3337         int ra = Integer.MIN_VALUE;
3338 
3339         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3340             for (int i = 0; i < a.length; i += SPECIES.length()) {
3341                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3342                 r[i] = av.reduceLanes(VectorOperators.MAX);
3343             }
3344         }
3345 
3346         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3347             ra = Integer.MIN_VALUE;
3348             for (int i = 0; i < a.length; i += SPECIES.length()) {
3349                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3350                 ra = (int)Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3351             }
3352         }
3353 
3354         assertReductionArraysEquals(r, ra, a,
3355                 Int128VectorTests::MAXReduce, Int128VectorTests::MAXReduceAll);
3356     }
3357     static int MAXReduceMasked(int[] a, int idx, boolean[] mask) {
3358         int res = Integer.MIN_VALUE;
3359         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3360             if(mask[i % SPECIES.length()])
3361                 res = (int)Math.max(res, a[i]);
3362         }
3363 
3364         return res;
3365     }
3366 
3367     static int MAXReduceAllMasked(int[] a, boolean[] mask) {
3368         int res = Integer.MIN_VALUE;
3369         for (int i = 0; i < a.length; i++) {
3370             if(mask[i % SPECIES.length()])
3371                 res = (int)Math.max(res, a[i]);
3372         }
3373 
3374         return res;
3375     }
3376     @Test(dataProvider = "intUnaryOpMaskProvider")
3377     static void MAXReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3378         int[] a = fa.apply(SPECIES.length());
3379         int[] r = fr.apply(SPECIES.length());
3380         boolean[] mask = fm.apply(SPECIES.length());
3381         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3382         int ra = Integer.MIN_VALUE;
3383 
3384         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3385             for (int i = 0; i < a.length; i += SPECIES.length()) {
3386                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3387                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3388             }
3389         }
3390 
3391         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3392             ra = Integer.MIN_VALUE;
3393             for (int i = 0; i < a.length; i += SPECIES.length()) {
3394                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3395                 ra = (int)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3396             }
3397         }
3398 
3399         assertReductionArraysEqualsMasked(r, ra, a, mask,
3400                 Int128VectorTests::MAXReduceMasked, Int128VectorTests::MAXReduceAllMasked);
3401     }
3402 
3403     static boolean anyTrue(boolean[] a, int idx) {
3404         boolean res = false;
3405         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3406             res |= a[i];
3407         }
3408 
3409         return res;
3410     }
3411 
3412 
3413     @Test(dataProvider = "boolUnaryOpProvider")
3414     static void anyTrueInt128VectorTests(IntFunction<boolean[]> fm) {
3415         boolean[] mask = fm.apply(SPECIES.length());
3416         boolean[] r = fmr.apply(SPECIES.length());
3417 
3418         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3419             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3420                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3421                 r[i] = vmask.anyTrue();
3422             }
3423         }
3424 
3425         assertReductionBoolArraysEquals(r, mask, Int128VectorTests::anyTrue);
3426     }
3427 
3428 
3429     static boolean allTrue(boolean[] a, int idx) {
3430         boolean res = true;
3431         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3432             res &= a[i];
3433         }
3434 
3435         return res;
3436     }
3437 
3438 
3439     @Test(dataProvider = "boolUnaryOpProvider")
3440     static void allTrueInt128VectorTests(IntFunction<boolean[]> fm) {
3441         boolean[] mask = fm.apply(SPECIES.length());
3442         boolean[] r = fmr.apply(SPECIES.length());
3443 
3444         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3445             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3446                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3447                 r[i] = vmask.allTrue();
3448             }
3449         }
3450 
3451         assertReductionBoolArraysEquals(r, mask, Int128VectorTests::allTrue);
3452     }
3453 
3454 
3455     @Test(dataProvider = "intUnaryOpProvider")
3456     static void withInt128VectorTests(IntFunction<int []> fa) {
3457         int[] a = fa.apply(SPECIES.length());
3458         int[] r = fr.apply(SPECIES.length());
3459 
3460         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3461             for (int i = 0; i < a.length; i += SPECIES.length()) {
3462                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3463                 av.withLane(0, (int)4).intoArray(r, i);
3464             }
3465         }
3466 
3467         assertInsertArraysEquals(r, a, (int)4, 0);
3468     }
3469     static boolean testIS_DEFAULT(int a) {
3470         return bits(a)==0;
3471     }
3472 
3473     @Test(dataProvider = "intTestOpProvider")
3474     static void IS_DEFAULTInt128VectorTests(IntFunction<int[]> fa) {
3475         int[] a = fa.apply(SPECIES.length());
3476 
3477         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3478             for (int i = 0; i < a.length; i += SPECIES.length()) {
3479                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3480                 VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT);
3481 
3482                 // Check results as part of computation.
3483                 for (int j = 0; j < SPECIES.length(); j++) {
3484                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3485                 }
3486             }
3487         }
3488     }
3489 
3490     @Test(dataProvider = "intTestOpMaskProvider")
3491     static void IS_DEFAULTMaskedInt128VectorTestsSmokeTest(IntFunction<int[]> fa,
3492                                           IntFunction<boolean[]> fm) {
3493         int[] a = fa.apply(SPECIES.length());
3494         boolean[] mask = fm.apply(SPECIES.length());
3495         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3496 
3497         for (int i = 0; i < a.length; i += SPECIES.length()) {
3498             IntVector av = IntVector.fromArray(SPECIES, a, i);
3499             VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3500 
3501             // Check results as part of computation.
3502             for (int j = 0; j < SPECIES.length(); j++) {
3503                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3504             }
3505         }
3506     }
3507     static boolean testIS_NEGATIVE(int a) {
3508         return bits(a)<0;
3509     }
3510 
3511     @Test(dataProvider = "intTestOpProvider")
3512     static void IS_NEGATIVEInt128VectorTests(IntFunction<int[]> fa) {
3513         int[] a = fa.apply(SPECIES.length());
3514 
3515         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3516             for (int i = 0; i < a.length; i += SPECIES.length()) {
3517                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3518                 VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE);
3519 
3520                 // Check results as part of computation.
3521                 for (int j = 0; j < SPECIES.length(); j++) {
3522                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3523                 }
3524             }
3525         }
3526     }
3527 
3528     @Test(dataProvider = "intTestOpMaskProvider")
3529     static void IS_NEGATIVEMaskedInt128VectorTestsSmokeTest(IntFunction<int[]> fa,
3530                                           IntFunction<boolean[]> fm) {
3531         int[] a = fa.apply(SPECIES.length());
3532         boolean[] mask = fm.apply(SPECIES.length());
3533         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3534 
3535         for (int i = 0; i < a.length; i += SPECIES.length()) {
3536             IntVector av = IntVector.fromArray(SPECIES, a, i);
3537             VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3538 
3539             // Check results as part of computation.
3540             for (int j = 0; j < SPECIES.length(); j++) {
3541                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3542             }
3543         }
3544     }
3545 
3546 
3547 
3548 
3549     @Test(dataProvider = "intCompareOpProvider")
3550     static void LTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3551         int[] a = fa.apply(SPECIES.length());
3552         int[] b = fb.apply(SPECIES.length());
3553 
3554         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3555             for (int i = 0; i < a.length; i += SPECIES.length()) {
3556                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3557                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3558                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv);
3559 
3560                 // Check results as part of computation.
3561                 for (int j = 0; j < SPECIES.length(); j++) {
3562                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3563                 }
3564             }
3565         }
3566     }
3567 
3568 
3569     @Test(dataProvider = "intCompareOpProvider")
3570     static void ltInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3571         int[] a = fa.apply(SPECIES.length());
3572         int[] b = fb.apply(SPECIES.length());
3573 
3574         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3575             for (int i = 0; i < a.length; i += SPECIES.length()) {
3576                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3577                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3578                 VectorMask<Integer> mv = av.lt(bv);
3579 
3580                 // Check results as part of computation.
3581                 for (int j = 0; j < SPECIES.length(); j++) {
3582                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3583                 }
3584             }
3585         }
3586     }
3587 
3588     @Test(dataProvider = "intCompareOpMaskProvider")
3589     static void LTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3590                                                 IntFunction<boolean[]> fm) {
3591         int[] a = fa.apply(SPECIES.length());
3592         int[] b = fb.apply(SPECIES.length());
3593         boolean[] mask = fm.apply(SPECIES.length());
3594 
3595         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3596 
3597         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3598             for (int i = 0; i < a.length; i += SPECIES.length()) {
3599                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3600                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3601                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv, vmask);
3602 
3603                 // Check results as part of computation.
3604                 for (int j = 0; j < SPECIES.length(); j++) {
3605                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3606                 }
3607             }
3608         }
3609     }
3610 
3611 
3612     @Test(dataProvider = "intCompareOpProvider")
3613     static void GTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3614         int[] a = fa.apply(SPECIES.length());
3615         int[] b = fb.apply(SPECIES.length());
3616 
3617         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3618             for (int i = 0; i < a.length; i += SPECIES.length()) {
3619                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3620                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3621                 VectorMask<Integer> mv = av.compare(VectorOperators.GT, bv);
3622 
3623                 // Check results as part of computation.
3624                 for (int j = 0; j < SPECIES.length(); j++) {
3625                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3626                 }
3627             }
3628         }
3629     }
3630 
3631     @Test(dataProvider = "intCompareOpMaskProvider")
3632     static void GTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3633                                                 IntFunction<boolean[]> fm) {
3634         int[] a = fa.apply(SPECIES.length());
3635         int[] b = fb.apply(SPECIES.length());
3636         boolean[] mask = fm.apply(SPECIES.length());
3637 
3638         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3639 
3640         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3641             for (int i = 0; i < a.length; i += SPECIES.length()) {
3642                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3643                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3644                 VectorMask<Integer> mv = av.compare(VectorOperators.GT, bv, vmask);
3645 
3646                 // Check results as part of computation.
3647                 for (int j = 0; j < SPECIES.length(); j++) {
3648                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3649                 }
3650             }
3651         }
3652     }
3653 
3654 
3655     @Test(dataProvider = "intCompareOpProvider")
3656     static void EQInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3657         int[] a = fa.apply(SPECIES.length());
3658         int[] b = fb.apply(SPECIES.length());
3659 
3660         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3661             for (int i = 0; i < a.length; i += SPECIES.length()) {
3662                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3663                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3664                 VectorMask<Integer> mv = av.compare(VectorOperators.EQ, bv);
3665 
3666                 // Check results as part of computation.
3667                 for (int j = 0; j < SPECIES.length(); j++) {
3668                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3669                 }
3670             }
3671         }
3672     }
3673 
3674 
3675     @Test(dataProvider = "intCompareOpProvider")
3676     static void eqInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3677         int[] a = fa.apply(SPECIES.length());
3678         int[] b = fb.apply(SPECIES.length());
3679 
3680         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3681             for (int i = 0; i < a.length; i += SPECIES.length()) {
3682                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3683                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3684                 VectorMask<Integer> mv = av.eq(bv);
3685 
3686                 // Check results as part of computation.
3687                 for (int j = 0; j < SPECIES.length(); j++) {
3688                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3689                 }
3690             }
3691         }
3692     }
3693 
3694     @Test(dataProvider = "intCompareOpMaskProvider")
3695     static void EQInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3696                                                 IntFunction<boolean[]> fm) {
3697         int[] a = fa.apply(SPECIES.length());
3698         int[] b = fb.apply(SPECIES.length());
3699         boolean[] mask = fm.apply(SPECIES.length());
3700 
3701         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3702 
3703         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3704             for (int i = 0; i < a.length; i += SPECIES.length()) {
3705                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3706                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3707                 VectorMask<Integer> mv = av.compare(VectorOperators.EQ, bv, vmask);
3708 
3709                 // Check results as part of computation.
3710                 for (int j = 0; j < SPECIES.length(); j++) {
3711                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3712                 }
3713             }
3714         }
3715     }
3716 
3717 
3718     @Test(dataProvider = "intCompareOpProvider")
3719     static void NEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3720         int[] a = fa.apply(SPECIES.length());
3721         int[] b = fb.apply(SPECIES.length());
3722 
3723         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3724             for (int i = 0; i < a.length; i += SPECIES.length()) {
3725                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3726                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3727                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv);
3728 
3729                 // Check results as part of computation.
3730                 for (int j = 0; j < SPECIES.length(); j++) {
3731                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3732                 }
3733             }
3734         }
3735     }
3736 
3737     @Test(dataProvider = "intCompareOpMaskProvider")
3738     static void NEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3739                                                 IntFunction<boolean[]> fm) {
3740         int[] a = fa.apply(SPECIES.length());
3741         int[] b = fb.apply(SPECIES.length());
3742         boolean[] mask = fm.apply(SPECIES.length());
3743 
3744         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3745 
3746         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3747             for (int i = 0; i < a.length; i += SPECIES.length()) {
3748                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3749                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3750                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv, vmask);
3751 
3752                 // Check results as part of computation.
3753                 for (int j = 0; j < SPECIES.length(); j++) {
3754                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3755                 }
3756             }
3757         }
3758     }
3759 
3760 
3761     @Test(dataProvider = "intCompareOpProvider")
3762     static void LEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3763         int[] a = fa.apply(SPECIES.length());
3764         int[] b = fb.apply(SPECIES.length());
3765 
3766         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3767             for (int i = 0; i < a.length; i += SPECIES.length()) {
3768                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3769                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3770                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv);
3771 
3772                 // Check results as part of computation.
3773                 for (int j = 0; j < SPECIES.length(); j++) {
3774                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3775                 }
3776             }
3777         }
3778     }
3779 
3780     @Test(dataProvider = "intCompareOpMaskProvider")
3781     static void LEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3782                                                 IntFunction<boolean[]> fm) {
3783         int[] a = fa.apply(SPECIES.length());
3784         int[] b = fb.apply(SPECIES.length());
3785         boolean[] mask = fm.apply(SPECIES.length());
3786 
3787         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3788 
3789         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3790             for (int i = 0; i < a.length; i += SPECIES.length()) {
3791                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3792                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3793                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv, vmask);
3794 
3795                 // Check results as part of computation.
3796                 for (int j = 0; j < SPECIES.length(); j++) {
3797                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3798                 }
3799             }
3800         }
3801     }
3802 
3803 
3804     @Test(dataProvider = "intCompareOpProvider")
3805     static void GEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3806         int[] a = fa.apply(SPECIES.length());
3807         int[] b = fb.apply(SPECIES.length());
3808 
3809         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3810             for (int i = 0; i < a.length; i += SPECIES.length()) {
3811                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3812                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3813                 VectorMask<Integer> mv = av.compare(VectorOperators.GE, bv);
3814 
3815                 // Check results as part of computation.
3816                 for (int j = 0; j < SPECIES.length(); j++) {
3817                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3818                 }
3819             }
3820         }
3821     }
3822 
3823     @Test(dataProvider = "intCompareOpMaskProvider")
3824     static void GEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3825                                                 IntFunction<boolean[]> fm) {
3826         int[] a = fa.apply(SPECIES.length());
3827         int[] b = fb.apply(SPECIES.length());
3828         boolean[] mask = fm.apply(SPECIES.length());
3829 
3830         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3831 
3832         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3833             for (int i = 0; i < a.length; i += SPECIES.length()) {
3834                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3835                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3836                 VectorMask<Integer> mv = av.compare(VectorOperators.GE, bv, vmask);
3837 
3838                 // Check results as part of computation.
3839                 for (int j = 0; j < SPECIES.length(); j++) {
3840                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3841                 }
3842             }
3843         }
3844     }
3845 
3846 
3847 
3848     @Test(dataProvider = "intCompareOpProvider")
3849     static void UNSIGNED_LTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3850         int[] a = fa.apply(SPECIES.length());
3851         int[] b = fb.apply(SPECIES.length());
3852 
3853         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3854             for (int i = 0; i < a.length; i += SPECIES.length()) {
3855                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3856                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3857                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
3858 
3859                 // Check results as part of computation.
3860                 for (int j = 0; j < SPECIES.length(); j++) {
3861                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
3862                 }
3863             }
3864         }
3865     }
3866 
3867 
3868 
3869     @Test(dataProvider = "intCompareOpMaskProvider")
3870     static void UNSIGNED_LTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3871                                                 IntFunction<boolean[]> fm) {
3872         int[] a = fa.apply(SPECIES.length());
3873         int[] b = fb.apply(SPECIES.length());
3874         boolean[] mask = fm.apply(SPECIES.length());
3875 
3876         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3877 
3878         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3879             for (int i = 0; i < a.length; i += SPECIES.length()) {
3880                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3881                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3882                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
3883 
3884                 // Check results as part of computation.
3885                 for (int j = 0; j < SPECIES.length(); j++) {
3886                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
3887                 }
3888             }
3889         }
3890     }
3891 
3892 
3893 
3894 
3895     @Test(dataProvider = "intCompareOpProvider")
3896     static void UNSIGNED_GTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3897         int[] a = fa.apply(SPECIES.length());
3898         int[] b = fb.apply(SPECIES.length());
3899 
3900         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3901             for (int i = 0; i < a.length; i += SPECIES.length()) {
3902                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3903                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3904                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
3905 
3906                 // Check results as part of computation.
3907                 for (int j = 0; j < SPECIES.length(); j++) {
3908                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
3909                 }
3910             }
3911         }
3912     }
3913 
3914 
3915 
3916     @Test(dataProvider = "intCompareOpMaskProvider")
3917     static void UNSIGNED_GTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3918                                                 IntFunction<boolean[]> fm) {
3919         int[] a = fa.apply(SPECIES.length());
3920         int[] b = fb.apply(SPECIES.length());
3921         boolean[] mask = fm.apply(SPECIES.length());
3922 
3923         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3924 
3925         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3926             for (int i = 0; i < a.length; i += SPECIES.length()) {
3927                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3928                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3929                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
3930 
3931                 // Check results as part of computation.
3932                 for (int j = 0; j < SPECIES.length(); j++) {
3933                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
3934                 }
3935             }
3936         }
3937     }
3938 
3939 
3940 
3941 
3942     @Test(dataProvider = "intCompareOpProvider")
3943     static void UNSIGNED_LEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3944         int[] a = fa.apply(SPECIES.length());
3945         int[] b = fb.apply(SPECIES.length());
3946 
3947         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3948             for (int i = 0; i < a.length; i += SPECIES.length()) {
3949                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3950                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3951                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
3952 
3953                 // Check results as part of computation.
3954                 for (int j = 0; j < SPECIES.length(); j++) {
3955                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
3956                 }
3957             }
3958         }
3959     }
3960 
3961 
3962 
3963     @Test(dataProvider = "intCompareOpMaskProvider")
3964     static void UNSIGNED_LEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
3965                                                 IntFunction<boolean[]> fm) {
3966         int[] a = fa.apply(SPECIES.length());
3967         int[] b = fb.apply(SPECIES.length());
3968         boolean[] mask = fm.apply(SPECIES.length());
3969 
3970         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3971 
3972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3973             for (int i = 0; i < a.length; i += SPECIES.length()) {
3974                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3975                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3976                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
3977 
3978                 // Check results as part of computation.
3979                 for (int j = 0; j < SPECIES.length(); j++) {
3980                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
3981                 }
3982             }
3983         }
3984     }
3985 
3986 
3987 
3988 
3989     @Test(dataProvider = "intCompareOpProvider")
3990     static void UNSIGNED_GEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3991         int[] a = fa.apply(SPECIES.length());
3992         int[] b = fb.apply(SPECIES.length());
3993 
3994         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3995             for (int i = 0; i < a.length; i += SPECIES.length()) {
3996                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3997                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3998                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
3999 
4000                 // Check results as part of computation.
4001                 for (int j = 0; j < SPECIES.length(); j++) {
4002                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4003                 }
4004             }
4005         }
4006     }
4007 
4008 
4009 
4010     @Test(dataProvider = "intCompareOpMaskProvider")
4011     static void UNSIGNED_GEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4012                                                 IntFunction<boolean[]> fm) {
4013         int[] a = fa.apply(SPECIES.length());
4014         int[] b = fb.apply(SPECIES.length());
4015         boolean[] mask = fm.apply(SPECIES.length());
4016 
4017         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4018 
4019         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4020             for (int i = 0; i < a.length; i += SPECIES.length()) {
4021                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4022                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4023                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4024 
4025                 // Check results as part of computation.
4026                 for (int j = 0; j < SPECIES.length(); j++) {
4027                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4028                 }
4029             }
4030         }
4031     }
4032 
4033 
4034 
4035     @Test(dataProvider = "intCompareOpProvider")
4036     static void LTInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4037         int[] a = fa.apply(SPECIES.length());
4038         int[] b = fb.apply(SPECIES.length());
4039 
4040         for (int i = 0; i < a.length; i += SPECIES.length()) {
4041             IntVector av = IntVector.fromArray(SPECIES, a, i);
4042             VectorMask<Integer> mv = av.compare(VectorOperators.LT, b[i]);
4043 
4044             // Check results as part of computation.
4045             for (int j = 0; j < SPECIES.length(); j++) {
4046                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4047             }
4048         }
4049     }
4050 
4051 
4052     @Test(dataProvider = "intCompareOpMaskProvider")
4053     static void LTInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa,
4054                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4055         int[] a = fa.apply(SPECIES.length());
4056         int[] b = fb.apply(SPECIES.length());
4057         boolean[] mask = fm.apply(SPECIES.length());
4058 
4059         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4060 
4061         for (int i = 0; i < a.length; i += SPECIES.length()) {
4062             IntVector av = IntVector.fromArray(SPECIES, a, i);
4063             VectorMask<Integer> mv = av.compare(VectorOperators.LT, b[i], vmask);
4064 
4065             // Check results as part of computation.
4066             for (int j = 0; j < SPECIES.length(); j++) {
4067                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4068             }
4069         }
4070     }
4071 
4072     @Test(dataProvider = "intCompareOpProvider")
4073     static void LTInt128VectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4074         int[] a = fa.apply(SPECIES.length());
4075         int[] b = fb.apply(SPECIES.length());
4076 
4077         for (int i = 0; i < a.length; i += SPECIES.length()) {
4078             IntVector av = IntVector.fromArray(SPECIES, a, i);
4079             VectorMask<Integer> mv = av.compare(VectorOperators.LT, (long)b[i]);
4080 
4081             // Check results as part of computation.
4082             for (int j = 0; j < SPECIES.length(); j++) {
4083                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i]));
4084             }
4085         }
4086     }
4087 
4088 
4089     @Test(dataProvider = "intCompareOpMaskProvider")
4090     static void LTInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<int[]> fa,
4091                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4092         int[] a = fa.apply(SPECIES.length());
4093         int[] b = fb.apply(SPECIES.length());
4094         boolean[] mask = fm.apply(SPECIES.length());
4095 
4096         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4097 
4098         for (int i = 0; i < a.length; i += SPECIES.length()) {
4099             IntVector av = IntVector.fromArray(SPECIES, a, i);
4100             VectorMask<Integer> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4101 
4102             // Check results as part of computation.
4103             for (int j = 0; j < SPECIES.length(); j++) {
4104                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i])));
4105             }
4106         }
4107     }
4108 
4109     @Test(dataProvider = "intCompareOpProvider")
4110     static void EQInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4111         int[] a = fa.apply(SPECIES.length());
4112         int[] b = fb.apply(SPECIES.length());
4113 
4114         for (int i = 0; i < a.length; i += SPECIES.length()) {
4115             IntVector av = IntVector.fromArray(SPECIES, a, i);
4116             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, b[i]);
4117 
4118             // Check results as part of computation.
4119             for (int j = 0; j < SPECIES.length(); j++) {
4120                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4121             }
4122         }
4123     }
4124 
4125 
4126     @Test(dataProvider = "intCompareOpMaskProvider")
4127     static void EQInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa,
4128                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4129         int[] a = fa.apply(SPECIES.length());
4130         int[] b = fb.apply(SPECIES.length());
4131         boolean[] mask = fm.apply(SPECIES.length());
4132 
4133         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4134 
4135         for (int i = 0; i < a.length; i += SPECIES.length()) {
4136             IntVector av = IntVector.fromArray(SPECIES, a, i);
4137             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4138 
4139             // Check results as part of computation.
4140             for (int j = 0; j < SPECIES.length(); j++) {
4141                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4142             }
4143         }
4144     }
4145 
4146     @Test(dataProvider = "intCompareOpProvider")
4147     static void EQInt128VectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4148         int[] a = fa.apply(SPECIES.length());
4149         int[] b = fb.apply(SPECIES.length());
4150 
4151         for (int i = 0; i < a.length; i += SPECIES.length()) {
4152             IntVector av = IntVector.fromArray(SPECIES, a, i);
4153             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4154 
4155             // Check results as part of computation.
4156             for (int j = 0; j < SPECIES.length(); j++) {
4157                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i]));
4158             }
4159         }
4160     }
4161 
4162 
4163     @Test(dataProvider = "intCompareOpMaskProvider")
4164     static void EQInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<int[]> fa,
4165                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4166         int[] a = fa.apply(SPECIES.length());
4167         int[] b = fb.apply(SPECIES.length());
4168         boolean[] mask = fm.apply(SPECIES.length());
4169 
4170         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4171 
4172         for (int i = 0; i < a.length; i += SPECIES.length()) {
4173             IntVector av = IntVector.fromArray(SPECIES, a, i);
4174             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4175 
4176             // Check results as part of computation.
4177             for (int j = 0; j < SPECIES.length(); j++) {
4178                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i])));
4179             }
4180         }
4181     }
4182 
4183     static int blend(int a, int b, boolean mask) {
4184         return mask ? b : a;
4185     }
4186 
4187     @Test(dataProvider = "intBinaryOpMaskProvider")
4188     static void blendInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb,
4189                                           IntFunction<boolean[]> fm) {
4190         int[] a = fa.apply(SPECIES.length());
4191         int[] b = fb.apply(SPECIES.length());
4192         int[] r = fr.apply(SPECIES.length());
4193         boolean[] mask = fm.apply(SPECIES.length());
4194         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4195 
4196         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4197             for (int i = 0; i < a.length; i += SPECIES.length()) {
4198                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4199                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4200                 av.blend(bv, vmask).intoArray(r, i);
4201             }
4202         }
4203 
4204         assertArraysEquals(r, a, b, mask, Int128VectorTests::blend);
4205     }
4206 
4207     @Test(dataProvider = "intUnaryOpShuffleProvider")
4208     static void RearrangeInt128VectorTests(IntFunction<int[]> fa,
4209                                            BiFunction<Integer,Integer,int[]> fs) {
4210         int[] a = fa.apply(SPECIES.length());
4211         int[] order = fs.apply(a.length, SPECIES.length());
4212         int[] r = fr.apply(SPECIES.length());
4213 
4214         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4215             for (int i = 0; i < a.length; i += SPECIES.length()) {
4216                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4217                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
4218             }
4219         }
4220 
4221         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4222     }
4223 
4224     @Test(dataProvider = "intUnaryOpShuffleMaskProvider")
4225     static void RearrangeInt128VectorTestsMaskedSmokeTest(IntFunction<int[]> fa,
4226                                                           BiFunction<Integer,Integer,int[]> fs,
4227                                                           IntFunction<boolean[]> fm) {
4228         int[] a = fa.apply(SPECIES.length());
4229         int[] order = fs.apply(a.length, SPECIES.length());
4230         int[] r = fr.apply(SPECIES.length());
4231         boolean[] mask = fm.apply(SPECIES.length());
4232         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4233 
4234         for (int i = 0; i < a.length; i += SPECIES.length()) {
4235             IntVector av = IntVector.fromArray(SPECIES, a, i);
4236             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4237         }
4238 
4239         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4240     }
4241 
4242     @Test(dataProvider = "intUnaryOpMaskProvider")
4243     static void compressInt128VectorTests(IntFunction<int[]> fa,
4244                                                 IntFunction<boolean[]> fm) {
4245         int[] a = fa.apply(SPECIES.length());
4246         int[] r = fr.apply(SPECIES.length());
4247         boolean[] mask = fm.apply(SPECIES.length());
4248         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4249 
4250         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4251             for (int i = 0; i < a.length; i += SPECIES.length()) {
4252                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4253                 av.compress(vmask).intoArray(r, i);
4254             }
4255         }
4256 
4257         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4258     }
4259 
4260     @Test(dataProvider = "intUnaryOpMaskProvider")
4261     static void expandInt128VectorTests(IntFunction<int[]> fa,
4262                                                 IntFunction<boolean[]> fm) {
4263         int[] a = fa.apply(SPECIES.length());
4264         int[] r = fr.apply(SPECIES.length());
4265         boolean[] mask = fm.apply(SPECIES.length());
4266         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4267 
4268         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4269             for (int i = 0; i < a.length; i += SPECIES.length()) {
4270                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4271                 av.expand(vmask).intoArray(r, i);
4272             }
4273         }
4274 
4275         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4276     }
4277     @Test(dataProvider = "intUnaryOpProvider")
4278     static void getInt128VectorTests(IntFunction<int[]> fa) {
4279         int[] a = fa.apply(SPECIES.length());
4280         int[] r = fr.apply(SPECIES.length());
4281 
4282         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4283             for (int i = 0; i < a.length; i += SPECIES.length()) {
4284                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4285                 int num_lanes = SPECIES.length();
4286                 // Manually unroll because full unroll happens after intrinsification.
4287                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4288                 if (num_lanes == 1) {
4289                     r[i]=av.lane(0);
4290                 } else if (num_lanes == 2) {
4291                     r[i]=av.lane(0);
4292                     r[i+1]=av.lane(1);
4293                 } else if (num_lanes == 4) {
4294                     r[i]=av.lane(0);
4295                     r[i+1]=av.lane(1);
4296                     r[i+2]=av.lane(2);
4297                     r[i+3]=av.lane(3);
4298                 } else if (num_lanes == 8) {
4299                     r[i]=av.lane(0);
4300                     r[i+1]=av.lane(1);
4301                     r[i+2]=av.lane(2);
4302                     r[i+3]=av.lane(3);
4303                     r[i+4]=av.lane(4);
4304                     r[i+5]=av.lane(5);
4305                     r[i+6]=av.lane(6);
4306                     r[i+7]=av.lane(7);
4307                 } else if (num_lanes == 16) {
4308                     r[i]=av.lane(0);
4309                     r[i+1]=av.lane(1);
4310                     r[i+2]=av.lane(2);
4311                     r[i+3]=av.lane(3);
4312                     r[i+4]=av.lane(4);
4313                     r[i+5]=av.lane(5);
4314                     r[i+6]=av.lane(6);
4315                     r[i+7]=av.lane(7);
4316                     r[i+8]=av.lane(8);
4317                     r[i+9]=av.lane(9);
4318                     r[i+10]=av.lane(10);
4319                     r[i+11]=av.lane(11);
4320                     r[i+12]=av.lane(12);
4321                     r[i+13]=av.lane(13);
4322                     r[i+14]=av.lane(14);
4323                     r[i+15]=av.lane(15);
4324                 } else if (num_lanes == 32) {
4325                     r[i]=av.lane(0);
4326                     r[i+1]=av.lane(1);
4327                     r[i+2]=av.lane(2);
4328                     r[i+3]=av.lane(3);
4329                     r[i+4]=av.lane(4);
4330                     r[i+5]=av.lane(5);
4331                     r[i+6]=av.lane(6);
4332                     r[i+7]=av.lane(7);
4333                     r[i+8]=av.lane(8);
4334                     r[i+9]=av.lane(9);
4335                     r[i+10]=av.lane(10);
4336                     r[i+11]=av.lane(11);
4337                     r[i+12]=av.lane(12);
4338                     r[i+13]=av.lane(13);
4339                     r[i+14]=av.lane(14);
4340                     r[i+15]=av.lane(15);
4341                     r[i+16]=av.lane(16);
4342                     r[i+17]=av.lane(17);
4343                     r[i+18]=av.lane(18);
4344                     r[i+19]=av.lane(19);
4345                     r[i+20]=av.lane(20);
4346                     r[i+21]=av.lane(21);
4347                     r[i+22]=av.lane(22);
4348                     r[i+23]=av.lane(23);
4349                     r[i+24]=av.lane(24);
4350                     r[i+25]=av.lane(25);
4351                     r[i+26]=av.lane(26);
4352                     r[i+27]=av.lane(27);
4353                     r[i+28]=av.lane(28);
4354                     r[i+29]=av.lane(29);
4355                     r[i+30]=av.lane(30);
4356                     r[i+31]=av.lane(31);
4357                 } else if (num_lanes == 64) {
4358                     r[i]=av.lane(0);
4359                     r[i+1]=av.lane(1);
4360                     r[i+2]=av.lane(2);
4361                     r[i+3]=av.lane(3);
4362                     r[i+4]=av.lane(4);
4363                     r[i+5]=av.lane(5);
4364                     r[i+6]=av.lane(6);
4365                     r[i+7]=av.lane(7);
4366                     r[i+8]=av.lane(8);
4367                     r[i+9]=av.lane(9);
4368                     r[i+10]=av.lane(10);
4369                     r[i+11]=av.lane(11);
4370                     r[i+12]=av.lane(12);
4371                     r[i+13]=av.lane(13);
4372                     r[i+14]=av.lane(14);
4373                     r[i+15]=av.lane(15);
4374                     r[i+16]=av.lane(16);
4375                     r[i+17]=av.lane(17);
4376                     r[i+18]=av.lane(18);
4377                     r[i+19]=av.lane(19);
4378                     r[i+20]=av.lane(20);
4379                     r[i+21]=av.lane(21);
4380                     r[i+22]=av.lane(22);
4381                     r[i+23]=av.lane(23);
4382                     r[i+24]=av.lane(24);
4383                     r[i+25]=av.lane(25);
4384                     r[i+26]=av.lane(26);
4385                     r[i+27]=av.lane(27);
4386                     r[i+28]=av.lane(28);
4387                     r[i+29]=av.lane(29);
4388                     r[i+30]=av.lane(30);
4389                     r[i+31]=av.lane(31);
4390                     r[i+32]=av.lane(32);
4391                     r[i+33]=av.lane(33);
4392                     r[i+34]=av.lane(34);
4393                     r[i+35]=av.lane(35);
4394                     r[i+36]=av.lane(36);
4395                     r[i+37]=av.lane(37);
4396                     r[i+38]=av.lane(38);
4397                     r[i+39]=av.lane(39);
4398                     r[i+40]=av.lane(40);
4399                     r[i+41]=av.lane(41);
4400                     r[i+42]=av.lane(42);
4401                     r[i+43]=av.lane(43);
4402                     r[i+44]=av.lane(44);
4403                     r[i+45]=av.lane(45);
4404                     r[i+46]=av.lane(46);
4405                     r[i+47]=av.lane(47);
4406                     r[i+48]=av.lane(48);
4407                     r[i+49]=av.lane(49);
4408                     r[i+50]=av.lane(50);
4409                     r[i+51]=av.lane(51);
4410                     r[i+52]=av.lane(52);
4411                     r[i+53]=av.lane(53);
4412                     r[i+54]=av.lane(54);
4413                     r[i+55]=av.lane(55);
4414                     r[i+56]=av.lane(56);
4415                     r[i+57]=av.lane(57);
4416                     r[i+58]=av.lane(58);
4417                     r[i+59]=av.lane(59);
4418                     r[i+60]=av.lane(60);
4419                     r[i+61]=av.lane(61);
4420                     r[i+62]=av.lane(62);
4421                     r[i+63]=av.lane(63);
4422                 } else {
4423                     for (int j = 0; j < SPECIES.length(); j++) {
4424                         r[i+j]=av.lane(j);
4425                     }
4426                 }
4427             }
4428         }
4429 
4430         assertArraysEquals(r, a, Int128VectorTests::get);
4431     }
4432 
4433     @Test(dataProvider = "intUnaryOpProvider")
4434     static void BroadcastInt128VectorTests(IntFunction<int[]> fa) {
4435         int[] a = fa.apply(SPECIES.length());
4436         int[] r = new int[a.length];
4437 
4438         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4439             for (int i = 0; i < a.length; i += SPECIES.length()) {
4440                 IntVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4441             }
4442         }
4443 
4444         assertBroadcastArraysEquals(r, a);
4445     }
4446 
4447 
4448 
4449 
4450 
4451     @Test(dataProvider = "intUnaryOpProvider")
4452     static void ZeroInt128VectorTests(IntFunction<int[]> fa) {
4453         int[] a = fa.apply(SPECIES.length());
4454         int[] r = new int[a.length];
4455 
4456         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4457             for (int i = 0; i < a.length; i += SPECIES.length()) {
4458                 IntVector.zero(SPECIES).intoArray(a, i);
4459             }
4460         }
4461 
4462         Assert.assertEquals(a, r);
4463     }
4464 
4465 
4466 
4467 
4468     static int[] sliceUnary(int[] a, int origin, int idx) {
4469         int[] res = new int[SPECIES.length()];
4470         for (int i = 0; i < SPECIES.length(); i++){
4471             if(i+origin < SPECIES.length())
4472                 res[i] = a[idx+i+origin];
4473             else
4474                 res[i] = (int)0;
4475         }
4476         return res;
4477     }
4478 
4479     @Test(dataProvider = "intUnaryOpProvider")
4480     static void sliceUnaryInt128VectorTests(IntFunction<int[]> fa) {
4481         int[] a = fa.apply(SPECIES.length());
4482         int[] r = new int[a.length];
4483         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4484         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4485             for (int i = 0; i < a.length; i += SPECIES.length()) {
4486                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4487                 av.slice(origin).intoArray(r, i);
4488             }
4489         }
4490 
4491         assertArraysEquals(r, a, origin, Int128VectorTests::sliceUnary);
4492     }
4493     static int[] sliceBinary(int[] a, int[] b, int origin, int idx) {
4494         int[] res = new int[SPECIES.length()];
4495         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4496             if(i+origin < SPECIES.length())
4497                 res[i] = a[idx+i+origin];
4498             else {
4499                 res[i] = b[idx+j];
4500                 j++;
4501             }
4502         }
4503         return res;
4504     }
4505 
4506     @Test(dataProvider = "intBinaryOpProvider")
4507     static void sliceBinaryInt128VectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4508         int[] a = fa.apply(SPECIES.length());
4509         int[] b = fb.apply(SPECIES.length());
4510         int[] r = new int[a.length];
4511         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4512         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4513             for (int i = 0; i < a.length; i += SPECIES.length()) {
4514                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4515                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4516                 av.slice(origin, bv).intoArray(r, i);
4517             }
4518         }
4519 
4520         assertArraysEquals(r, a, b, origin, Int128VectorTests::sliceBinary);
4521     }
4522     static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) {
4523         int[] res = new int[SPECIES.length()];
4524         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4525             if(i+origin < SPECIES.length())
4526                 res[i] = mask[i] ? a[idx+i+origin] : (int)0;
4527             else {
4528                 res[i] = mask[i] ? b[idx+j] : (int)0;
4529                 j++;
4530             }
4531         }
4532         return res;
4533     }
4534 
4535     @Test(dataProvider = "intBinaryOpMaskProvider")
4536     static void sliceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4537     IntFunction<boolean[]> fm) {
4538         int[] a = fa.apply(SPECIES.length());
4539         int[] b = fb.apply(SPECIES.length());
4540         boolean[] mask = fm.apply(SPECIES.length());
4541         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4542 
4543         int[] r = new int[a.length];
4544         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4545         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4546             for (int i = 0; i < a.length; i += SPECIES.length()) {
4547                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4548                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4549                 av.slice(origin, bv, vmask).intoArray(r, i);
4550             }
4551         }
4552 
4553         assertArraysEquals(r, a, b, origin, mask, Int128VectorTests::slice);
4554     }
4555     static int[] unsliceUnary(int[] a, int origin, int idx) {
4556         int[] res = new int[SPECIES.length()];
4557         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4558             if(i < origin)
4559                 res[i] = (int)0;
4560             else {
4561                 res[i] = a[idx+j];
4562                 j++;
4563             }
4564         }
4565         return res;
4566     }
4567 
4568     @Test(dataProvider = "intUnaryOpProvider")
4569     static void unsliceUnaryInt128VectorTests(IntFunction<int[]> fa) {
4570         int[] a = fa.apply(SPECIES.length());
4571         int[] r = new int[a.length];
4572         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4573         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4574             for (int i = 0; i < a.length; i += SPECIES.length()) {
4575                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4576                 av.unslice(origin).intoArray(r, i);
4577             }
4578         }
4579 
4580         assertArraysEquals(r, a, origin, Int128VectorTests::unsliceUnary);
4581     }
4582     static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) {
4583         int[] res = new int[SPECIES.length()];
4584         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4585             if (part == 0) {
4586                 if (i < origin)
4587                     res[i] = b[idx+i];
4588                 else {
4589                     res[i] = a[idx+j];
4590                     j++;
4591                 }
4592             } else if (part == 1) {
4593                 if (i < origin)
4594                     res[i] = a[idx+SPECIES.length()-origin+i];
4595                 else {
4596                     res[i] = b[idx+origin+j];
4597                     j++;
4598                 }
4599             }
4600         }
4601         return res;
4602     }
4603 
4604     @Test(dataProvider = "intBinaryOpProvider")
4605     static void unsliceBinaryInt128VectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4606         int[] a = fa.apply(SPECIES.length());
4607         int[] b = fb.apply(SPECIES.length());
4608         int[] r = new int[a.length];
4609         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4610         int part = (new java.util.Random()).nextInt(2);
4611         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4612             for (int i = 0; i < a.length; i += SPECIES.length()) {
4613                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4614                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4615                 av.unslice(origin, bv, part).intoArray(r, i);
4616             }
4617         }
4618 
4619         assertArraysEquals(r, a, b, origin, part, Int128VectorTests::unsliceBinary);
4620     }
4621     static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) {
4622         int[] res = new int[SPECIES.length()];
4623         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4624             if(i+origin < SPECIES.length())
4625                 res[i] = b[idx+i+origin];
4626             else {
4627                 res[i] = b[idx+j];
4628                 j++;
4629             }
4630         }
4631         for (int i = 0; i < SPECIES.length(); i++){
4632             res[i] = mask[i] ? a[idx+i] : res[i];
4633         }
4634         int[] res1 = new int[SPECIES.length()];
4635         if (part == 0) {
4636             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4637                 if (i < origin)
4638                     res1[i] = b[idx+i];
4639                 else {
4640                    res1[i] = res[j];
4641                    j++;
4642                 }
4643             }
4644         } else if (part == 1) {
4645             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4646                 if (i < origin)
4647                     res1[i] = res[SPECIES.length()-origin+i];
4648                 else {
4649                     res1[i] = b[idx+origin+j];
4650                     j++;
4651                 }
4652             }
4653         }
4654         return res1;
4655     }
4656 
4657     @Test(dataProvider = "intBinaryOpMaskProvider")
4658     static void unsliceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4659     IntFunction<boolean[]> fm) {
4660         int[] a = fa.apply(SPECIES.length());
4661         int[] b = fb.apply(SPECIES.length());
4662         boolean[] mask = fm.apply(SPECIES.length());
4663         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4664         int[] r = new int[a.length];
4665         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4666         int part = (new java.util.Random()).nextInt(2);
4667         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4668             for (int i = 0; i < a.length; i += SPECIES.length()) {
4669                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4670                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4671                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4672             }
4673         }
4674 
4675         assertArraysEquals(r, a, b, origin, part, mask, Int128VectorTests::unslice);
4676     }
4677 
4678 
4679 
4680 
4681 
4682 
4683 
4684 
4685 
4686 
4687 
4688 
4689 
4690 
4691 
4692 
4693 
4694 
4695 
4696 
4697 
4698 
4699 
4700     static int BITWISE_BLEND(int a, int b, int c) {
4701         return (int)((a&~(c))|(b&c));
4702     }
4703     static int bitwiseBlend(int a, int b, int c) {
4704         return (int)((a&~(c))|(b&c));
4705     }
4706 
4707 
4708     @Test(dataProvider = "intTernaryOpProvider")
4709     static void BITWISE_BLENDInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4710         int[] a = fa.apply(SPECIES.length());
4711         int[] b = fb.apply(SPECIES.length());
4712         int[] c = fc.apply(SPECIES.length());
4713         int[] r = fr.apply(SPECIES.length());
4714 
4715         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4716             for (int i = 0; i < a.length; i += SPECIES.length()) {
4717                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4718                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4719                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
4720                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4721             }
4722         }
4723 
4724         assertArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND);
4725     }
4726     @Test(dataProvider = "intTernaryOpProvider")
4727     static void bitwiseBlendInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4728         int[] a = fa.apply(SPECIES.length());
4729         int[] b = fb.apply(SPECIES.length());
4730         int[] c = fc.apply(SPECIES.length());
4731         int[] r = fr.apply(SPECIES.length());
4732 
4733         for (int i = 0; i < a.length; i += SPECIES.length()) {
4734             IntVector av = IntVector.fromArray(SPECIES, a, i);
4735             IntVector bv = IntVector.fromArray(SPECIES, b, i);
4736             IntVector cv = IntVector.fromArray(SPECIES, c, i);
4737             av.bitwiseBlend(bv, cv).intoArray(r, i);
4738         }
4739 
4740         assertArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend);
4741     }
4742 
4743 
4744     @Test(dataProvider = "intTernaryOpMaskProvider")
4745     static void BITWISE_BLENDInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4746                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
4747         int[] a = fa.apply(SPECIES.length());
4748         int[] b = fb.apply(SPECIES.length());
4749         int[] c = fc.apply(SPECIES.length());
4750         int[] r = fr.apply(SPECIES.length());
4751         boolean[] mask = fm.apply(SPECIES.length());
4752         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4753 
4754         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4755             for (int i = 0; i < a.length; i += SPECIES.length()) {
4756                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4757                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4758                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
4759                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4760             }
4761         }
4762 
4763         assertArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND);
4764     }
4765 
4766 
4767 
4768 
4769     @Test(dataProvider = "intTernaryOpProvider")
4770     static void BITWISE_BLENDInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4771         int[] a = fa.apply(SPECIES.length());
4772         int[] b = fb.apply(SPECIES.length());
4773         int[] c = fc.apply(SPECIES.length());
4774         int[] r = fr.apply(SPECIES.length());
4775 
4776         for (int i = 0; i < a.length; i += SPECIES.length()) {
4777             IntVector av = IntVector.fromArray(SPECIES, a, i);
4778             IntVector bv = IntVector.fromArray(SPECIES, b, i);
4779             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
4780         }
4781         assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND);
4782     }
4783 
4784     @Test(dataProvider = "intTernaryOpProvider")
4785     static void BITWISE_BLENDInt128VectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4786         int[] a = fa.apply(SPECIES.length());
4787         int[] b = fb.apply(SPECIES.length());
4788         int[] c = fc.apply(SPECIES.length());
4789         int[] r = fr.apply(SPECIES.length());
4790 
4791         for (int i = 0; i < a.length; i += SPECIES.length()) {
4792             IntVector av = IntVector.fromArray(SPECIES, a, i);
4793             IntVector cv = IntVector.fromArray(SPECIES, c, i);
4794             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
4795         }
4796         assertAltBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND);
4797     }
4798     @Test(dataProvider = "intTernaryOpProvider")
4799     static void bitwiseBlendInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4800         int[] a = fa.apply(SPECIES.length());
4801         int[] b = fb.apply(SPECIES.length());
4802         int[] c = fc.apply(SPECIES.length());
4803         int[] r = fr.apply(SPECIES.length());
4804 
4805         for (int i = 0; i < a.length; i += SPECIES.length()) {
4806             IntVector av = IntVector.fromArray(SPECIES, a, i);
4807             IntVector bv = IntVector.fromArray(SPECIES, b, i);
4808             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
4809         }
4810         assertBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend);
4811     }
4812 
4813     @Test(dataProvider = "intTernaryOpProvider")
4814     static void bitwiseBlendInt128VectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4815         int[] a = fa.apply(SPECIES.length());
4816         int[] b = fb.apply(SPECIES.length());
4817         int[] c = fc.apply(SPECIES.length());
4818         int[] r = fr.apply(SPECIES.length());
4819 
4820         for (int i = 0; i < a.length; i += SPECIES.length()) {
4821             IntVector av = IntVector.fromArray(SPECIES, a, i);
4822             IntVector cv = IntVector.fromArray(SPECIES, c, i);
4823             av.bitwiseBlend(b[i], cv).intoArray(r, i);
4824         }
4825         assertAltBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend);
4826     }
4827 
4828 
4829     @Test(dataProvider = "intTernaryOpMaskProvider")
4830     static void BITWISE_BLENDInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
4831                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
4832         int[] a = fa.apply(SPECIES.length());
4833         int[] b = fb.apply(SPECIES.length());
4834         int[] c = fc.apply(SPECIES.length());
4835         int[] r = fr.apply(SPECIES.length());
4836         boolean[] mask = fm.apply(SPECIES.length());
4837         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4838 
4839         for (int i = 0; i < a.length; i += SPECIES.length()) {
4840             IntVector av = IntVector.fromArray(SPECIES, a, i);
4841             IntVector bv = IntVector.fromArray(SPECIES, b, i);
4842             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
4843         }
4844 
4845         assertBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND);
4846     }
4847 
4848     @Test(dataProvider = "intTernaryOpMaskProvider")
4849     static void BITWISE_BLENDInt128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
4850                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
4851         int[] a = fa.apply(SPECIES.length());
4852         int[] b = fb.apply(SPECIES.length());
4853         int[] c = fc.apply(SPECIES.length());
4854         int[] r = fr.apply(SPECIES.length());
4855         boolean[] mask = fm.apply(SPECIES.length());
4856         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4857 
4858         for (int i = 0; i < a.length; i += SPECIES.length()) {
4859             IntVector av = IntVector.fromArray(SPECIES, a, i);
4860             IntVector cv = IntVector.fromArray(SPECIES, c, i);
4861             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
4862         }
4863 
4864         assertAltBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND);
4865     }
4866 
4867 
4868 
4869 
4870     @Test(dataProvider = "intTernaryOpProvider")
4871     static void BITWISE_BLENDInt128VectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4872         int[] a = fa.apply(SPECIES.length());
4873         int[] b = fb.apply(SPECIES.length());
4874         int[] c = fc.apply(SPECIES.length());
4875         int[] r = fr.apply(SPECIES.length());
4876 
4877         for (int i = 0; i < a.length; i += SPECIES.length()) {
4878             IntVector av = IntVector.fromArray(SPECIES, a, i);
4879             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
4880         }
4881 
4882         assertDoubleBroadcastArraysEquals(r, a, b, c, Int128VectorTests::BITWISE_BLEND);
4883     }
4884     @Test(dataProvider = "intTernaryOpProvider")
4885     static void bitwiseBlendInt128VectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4886         int[] a = fa.apply(SPECIES.length());
4887         int[] b = fb.apply(SPECIES.length());
4888         int[] c = fc.apply(SPECIES.length());
4889         int[] r = fr.apply(SPECIES.length());
4890 
4891         for (int i = 0; i < a.length; i += SPECIES.length()) {
4892             IntVector av = IntVector.fromArray(SPECIES, a, i);
4893             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
4894         }
4895 
4896         assertDoubleBroadcastArraysEquals(r, a, b, c, Int128VectorTests::bitwiseBlend);
4897     }
4898 
4899 
4900     @Test(dataProvider = "intTernaryOpMaskProvider")
4901     static void BITWISE_BLENDInt128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
4902                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
4903         int[] a = fa.apply(SPECIES.length());
4904         int[] b = fb.apply(SPECIES.length());
4905         int[] c = fc.apply(SPECIES.length());
4906         int[] r = fr.apply(SPECIES.length());
4907         boolean[] mask = fm.apply(SPECIES.length());
4908         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4909 
4910         for (int i = 0; i < a.length; i += SPECIES.length()) {
4911             IntVector av = IntVector.fromArray(SPECIES, a, i);
4912             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
4913         }
4914 
4915         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Int128VectorTests::BITWISE_BLEND);
4916     }
4917 
4918 
4919     static int NEG(int a) {
4920         return (int)(-((int)a));
4921     }
4922 
4923     static int neg(int a) {
4924         return (int)(-((int)a));
4925     }
4926 
4927     @Test(dataProvider = "intUnaryOpProvider")
4928     static void NEGInt128VectorTests(IntFunction<int[]> fa) {
4929         int[] a = fa.apply(SPECIES.length());
4930         int[] r = fr.apply(SPECIES.length());
4931 
4932         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4933             for (int i = 0; i < a.length; i += SPECIES.length()) {
4934                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4935                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4936             }
4937         }
4938 
4939         assertArraysEquals(r, a, Int128VectorTests::NEG);
4940     }
4941 
4942     @Test(dataProvider = "intUnaryOpProvider")
4943     static void negInt128VectorTests(IntFunction<int[]> fa) {
4944         int[] a = fa.apply(SPECIES.length());
4945         int[] r = fr.apply(SPECIES.length());
4946 
4947         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4948             for (int i = 0; i < a.length; i += SPECIES.length()) {
4949                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4950                 av.neg().intoArray(r, i);
4951             }
4952         }
4953 
4954         assertArraysEquals(r, a, Int128VectorTests::neg);
4955     }
4956 
4957     @Test(dataProvider = "intUnaryOpMaskProvider")
4958     static void NEGMaskedInt128VectorTests(IntFunction<int[]> fa,
4959                                                 IntFunction<boolean[]> fm) {
4960         int[] a = fa.apply(SPECIES.length());
4961         int[] r = fr.apply(SPECIES.length());
4962         boolean[] mask = fm.apply(SPECIES.length());
4963         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4964 
4965         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4966             for (int i = 0; i < a.length; i += SPECIES.length()) {
4967                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4968                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4969             }
4970         }
4971 
4972         assertArraysEquals(r, a, mask, Int128VectorTests::NEG);
4973     }
4974 
4975     static int ABS(int a) {
4976         return (int)(Math.abs((int)a));
4977     }
4978 
4979     static int abs(int a) {
4980         return (int)(Math.abs((int)a));
4981     }
4982 
4983     @Test(dataProvider = "intUnaryOpProvider")
4984     static void ABSInt128VectorTests(IntFunction<int[]> fa) {
4985         int[] a = fa.apply(SPECIES.length());
4986         int[] r = fr.apply(SPECIES.length());
4987 
4988         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4989             for (int i = 0; i < a.length; i += SPECIES.length()) {
4990                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4991                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
4992             }
4993         }
4994 
4995         assertArraysEquals(r, a, Int128VectorTests::ABS);
4996     }
4997 
4998     @Test(dataProvider = "intUnaryOpProvider")
4999     static void absInt128VectorTests(IntFunction<int[]> fa) {
5000         int[] a = fa.apply(SPECIES.length());
5001         int[] r = fr.apply(SPECIES.length());
5002 
5003         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5004             for (int i = 0; i < a.length; i += SPECIES.length()) {
5005                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5006                 av.abs().intoArray(r, i);
5007             }
5008         }
5009 
5010         assertArraysEquals(r, a, Int128VectorTests::abs);
5011     }
5012 
5013     @Test(dataProvider = "intUnaryOpMaskProvider")
5014     static void ABSMaskedInt128VectorTests(IntFunction<int[]> fa,
5015                                                 IntFunction<boolean[]> fm) {
5016         int[] a = fa.apply(SPECIES.length());
5017         int[] r = fr.apply(SPECIES.length());
5018         boolean[] mask = fm.apply(SPECIES.length());
5019         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5020 
5021         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5022             for (int i = 0; i < a.length; i += SPECIES.length()) {
5023                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5024                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5025             }
5026         }
5027 
5028         assertArraysEquals(r, a, mask, Int128VectorTests::ABS);
5029     }
5030 
5031 
5032     static int NOT(int a) {
5033         return (int)(~((int)a));
5034     }
5035 
5036     static int not(int a) {
5037         return (int)(~((int)a));
5038     }
5039 
5040 
5041 
5042     @Test(dataProvider = "intUnaryOpProvider")
5043     static void NOTInt128VectorTests(IntFunction<int[]> fa) {
5044         int[] a = fa.apply(SPECIES.length());
5045         int[] r = fr.apply(SPECIES.length());
5046 
5047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5048             for (int i = 0; i < a.length; i += SPECIES.length()) {
5049                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5050                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5051             }
5052         }
5053 
5054         assertArraysEquals(r, a, Int128VectorTests::NOT);
5055     }
5056 
5057     @Test(dataProvider = "intUnaryOpProvider")
5058     static void notInt128VectorTests(IntFunction<int[]> fa) {
5059         int[] a = fa.apply(SPECIES.length());
5060         int[] r = fr.apply(SPECIES.length());
5061 
5062         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5063             for (int i = 0; i < a.length; i += SPECIES.length()) {
5064                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5065                 av.not().intoArray(r, i);
5066             }
5067         }
5068 
5069         assertArraysEquals(r, a, Int128VectorTests::not);
5070     }
5071 
5072 
5073 
5074     @Test(dataProvider = "intUnaryOpMaskProvider")
5075     static void NOTMaskedInt128VectorTests(IntFunction<int[]> fa,
5076                                                 IntFunction<boolean[]> fm) {
5077         int[] a = fa.apply(SPECIES.length());
5078         int[] r = fr.apply(SPECIES.length());
5079         boolean[] mask = fm.apply(SPECIES.length());
5080         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5081 
5082         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5083             for (int i = 0; i < a.length; i += SPECIES.length()) {
5084                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5085                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5086             }
5087         }
5088 
5089         assertArraysEquals(r, a, mask, Int128VectorTests::NOT);
5090     }
5091 
5092 
5093 
5094     static int ZOMO(int a) {
5095         return (int)((a==0?0:-1));
5096     }
5097 
5098 
5099 
5100     @Test(dataProvider = "intUnaryOpProvider")
5101     static void ZOMOInt128VectorTests(IntFunction<int[]> fa) {
5102         int[] a = fa.apply(SPECIES.length());
5103         int[] r = fr.apply(SPECIES.length());
5104 
5105         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5106             for (int i = 0; i < a.length; i += SPECIES.length()) {
5107                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5108                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5109             }
5110         }
5111 
5112         assertArraysEquals(r, a, Int128VectorTests::ZOMO);
5113     }
5114 
5115 
5116 
5117     @Test(dataProvider = "intUnaryOpMaskProvider")
5118     static void ZOMOMaskedInt128VectorTests(IntFunction<int[]> fa,
5119                                                 IntFunction<boolean[]> fm) {
5120         int[] a = fa.apply(SPECIES.length());
5121         int[] r = fr.apply(SPECIES.length());
5122         boolean[] mask = fm.apply(SPECIES.length());
5123         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5124 
5125         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5126             for (int i = 0; i < a.length; i += SPECIES.length()) {
5127                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5128                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5129             }
5130         }
5131 
5132         assertArraysEquals(r, a, mask, Int128VectorTests::ZOMO);
5133     }
5134 
5135 
5136 
5137 
5138 
5139     @Test(dataProvider = "intCompareOpProvider")
5140     static void ltInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5141         int[] a = fa.apply(SPECIES.length());
5142         int[] b = fb.apply(SPECIES.length());
5143 
5144         for (int i = 0; i < a.length; i += SPECIES.length()) {
5145             IntVector av = IntVector.fromArray(SPECIES, a, i);
5146             VectorMask<Integer> mv = av.lt(b[i]);
5147 
5148             // Check results as part of computation.
5149             for (int j = 0; j < SPECIES.length(); j++) {
5150                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5151             }
5152         }
5153     }
5154 
5155     @Test(dataProvider = "intCompareOpProvider")
5156     static void eqInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5157         int[] a = fa.apply(SPECIES.length());
5158         int[] b = fb.apply(SPECIES.length());
5159 
5160         for (int i = 0; i < a.length; i += SPECIES.length()) {
5161             IntVector av = IntVector.fromArray(SPECIES, a, i);
5162             VectorMask<Integer> mv = av.eq(b[i]);
5163 
5164             // Check results as part of computation.
5165             for (int j = 0; j < SPECIES.length(); j++) {
5166                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5167             }
5168         }
5169     }
5170 
5171     @Test(dataProvider = "intUnaryOpProvider")
5172     static void toIntArrayInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5173         int[] a = fa.apply(SPECIES.length());
5174 
5175         for (int i = 0; i < a.length; i += SPECIES.length()) {
5176             IntVector av = IntVector.fromArray(SPECIES, a, i);
5177             int[] r = av.toIntArray();
5178             assertArraysEquals(r, a, i);
5179         }
5180     }
5181 
5182     @Test(dataProvider = "intUnaryOpProvider")
5183     static void toLongArrayInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5184         int[] a = fa.apply(SPECIES.length());
5185 
5186         for (int i = 0; i < a.length; i += SPECIES.length()) {
5187             IntVector av = IntVector.fromArray(SPECIES, a, i);
5188             long[] r = av.toLongArray();
5189             assertArraysEquals(r, a, i);
5190         }
5191     }
5192 
5193     @Test(dataProvider = "intUnaryOpProvider")
5194     static void toDoubleArrayInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5195         int[] a = fa.apply(SPECIES.length());
5196 
5197         for (int i = 0; i < a.length; i += SPECIES.length()) {
5198             IntVector av = IntVector.fromArray(SPECIES, a, i);
5199             double[] r = av.toDoubleArray();
5200             assertArraysEquals(r, a, i);
5201         }
5202     }
5203 
5204     @Test(dataProvider = "intUnaryOpProvider")
5205     static void toStringInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5206         int[] a = fa.apply(SPECIES.length());
5207 
5208         for (int i = 0; i < a.length; i += SPECIES.length()) {
5209             IntVector av = IntVector.fromArray(SPECIES, a, i);
5210             String str = av.toString();
5211 
5212             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5213             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5214         }
5215     }
5216 
5217     @Test(dataProvider = "intUnaryOpProvider")
5218     static void hashCodeInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5219         int[] a = fa.apply(SPECIES.length());
5220 
5221         for (int i = 0; i < a.length; i += SPECIES.length()) {
5222             IntVector av = IntVector.fromArray(SPECIES, a, i);
5223             int hash = av.hashCode();
5224 
5225             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5226             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5227             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5228         }
5229     }
5230 
5231 
5232     static long ADDReduceLong(int[] a, int idx) {
5233         int res = 0;
5234         for (int i = idx; i < (idx + SPECIES.length()); i++) {
5235             res += a[i];
5236         }
5237 
5238         return (long)res;
5239     }
5240 
5241     static long ADDReduceAllLong(int[] a) {
5242         long res = 0;
5243         for (int i = 0; i < a.length; i += SPECIES.length()) {
5244             res += ADDReduceLong(a, i);
5245         }
5246 
5247         return res;
5248     }
5249 
5250     @Test(dataProvider = "intUnaryOpProvider")
5251     static void ADDReduceLongInt128VectorTests(IntFunction<int[]> fa) {
5252         int[] a = fa.apply(SPECIES.length());
5253         long[] r = lfr.apply(SPECIES.length());
5254         long ra = 0;
5255 
5256         for (int i = 0; i < a.length; i += SPECIES.length()) {
5257             IntVector av = IntVector.fromArray(SPECIES, a, i);
5258             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5259         }
5260 
5261         ra = 0;
5262         for (int i = 0; i < a.length; i ++) {
5263             ra += r[i];
5264         }
5265 
5266         assertReductionLongArraysEquals(r, ra, a,
5267                 Int128VectorTests::ADDReduceLong, Int128VectorTests::ADDReduceAllLong);
5268     }
5269 
5270     static long ADDReduceLongMasked(int[] a, int idx, boolean[] mask) {
5271         int res = 0;
5272         for (int i = idx; i < (idx + SPECIES.length()); i++) {
5273             if(mask[i % SPECIES.length()])
5274                 res += a[i];
5275         }
5276 
5277         return (long)res;
5278     }
5279 
5280     static long ADDReduceAllLongMasked(int[] a, boolean[] mask) {
5281         long res = 0;
5282         for (int i = 0; i < a.length; i += SPECIES.length()) {
5283             res += ADDReduceLongMasked(a, i, mask);
5284         }
5285 
5286         return res;
5287     }
5288 
5289     @Test(dataProvider = "intUnaryOpMaskProvider")
5290     static void ADDReduceLongInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
5291         int[] a = fa.apply(SPECIES.length());
5292         long[] r = lfr.apply(SPECIES.length());
5293         boolean[] mask = fm.apply(SPECIES.length());
5294         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5295         long ra = 0;
5296 
5297         for (int i = 0; i < a.length; i += SPECIES.length()) {
5298             IntVector av = IntVector.fromArray(SPECIES, a, i);
5299             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5300         }
5301 
5302         ra = 0;
5303         for (int i = 0; i < a.length; i ++) {
5304             ra += r[i];
5305         }
5306 
5307         assertReductionLongArraysEqualsMasked(r, ra, a, mask,
5308                 Int128VectorTests::ADDReduceLongMasked, Int128VectorTests::ADDReduceAllLongMasked);
5309     }
5310 
5311     @Test(dataProvider = "intUnaryOpProvider")
5312     static void BroadcastLongInt128VectorTestsSmokeTest(IntFunction<int[]> fa) {
5313         int[] a = fa.apply(SPECIES.length());
5314         int[] r = new int[a.length];
5315 
5316         for (int i = 0; i < a.length; i += SPECIES.length()) {
5317             IntVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
5318         }
5319         assertBroadcastArraysEquals(r, a);
5320     }
5321 
5322     @Test(dataProvider = "intBinaryOpMaskProvider")
5323     static void blendInt128VectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5324                                           IntFunction<boolean[]> fm) {
5325         int[] a = fa.apply(SPECIES.length());
5326         int[] b = fb.apply(SPECIES.length());
5327         int[] r = fr.apply(SPECIES.length());
5328         boolean[] mask = fm.apply(SPECIES.length());
5329         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5330 
5331         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5332             for (int i = 0; i < a.length; i += SPECIES.length()) {
5333                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5334                 av.blend((long)b[i], vmask).intoArray(r, i);
5335             }
5336         }
5337         assertBroadcastLongArraysEquals(r, a, b, mask, Int128VectorTests::blend);
5338     }
5339 
5340 
5341     @Test(dataProvider = "intUnaryOpShuffleProvider")
5342     static void SelectFromInt128VectorTests(IntFunction<int[]> fa,
5343                                            BiFunction<Integer,Integer,int[]> fs) {
5344         int[] a = fa.apply(SPECIES.length());
5345         int[] order = fs.apply(a.length, SPECIES.length());
5346         int[] r = fr.apply(SPECIES.length());
5347 
5348         for (int i = 0; i < a.length; i += SPECIES.length()) {
5349             IntVector av = IntVector.fromArray(SPECIES, a, i);
5350             IntVector bv = IntVector.fromArray(SPECIES, order, i);
5351             bv.selectFrom(av).intoArray(r, i);
5352         }
5353 
5354         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5355     }
5356 
5357     @Test(dataProvider = "intUnaryOpShuffleMaskProvider")
5358     static void SelectFromInt128VectorTestsMaskedSmokeTest(IntFunction<int[]> fa,
5359                                                            BiFunction<Integer,Integer,int[]> fs,
5360                                                            IntFunction<boolean[]> fm) {
5361         int[] a = fa.apply(SPECIES.length());
5362         int[] order = fs.apply(a.length, SPECIES.length());
5363         int[] r = fr.apply(SPECIES.length());
5364         boolean[] mask = fm.apply(SPECIES.length());
5365         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5366 
5367         for (int i = 0; i < a.length; i += SPECIES.length()) {
5368             IntVector av = IntVector.fromArray(SPECIES, a, i);
5369             IntVector bv = IntVector.fromArray(SPECIES, order, i);
5370             bv.selectFrom(av, vmask).intoArray(r, i);
5371         }
5372 
5373         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5374     }
5375 
5376     @Test(dataProvider = "shuffleProvider")
5377     static void shuffleMiscellaneousInt128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5378         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5379 
5380         for (int i = 0; i < a.length; i += SPECIES.length()) {
5381             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5382             int hash = shuffle.hashCode();
5383             int length = shuffle.length();
5384 
5385             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5386             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5387             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5388             Assert.assertEquals(length, SPECIES.length());
5389         }
5390     }
5391 
5392     @Test(dataProvider = "shuffleProvider")
5393     static void shuffleToStringInt128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5394         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5395 
5396         for (int i = 0; i < a.length; i += SPECIES.length()) {
5397             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5398             String str = shuffle.toString();
5399 
5400             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5401             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5402                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5403         }
5404     }
5405 
5406     @Test(dataProvider = "shuffleCompareOpProvider")
5407     static void shuffleEqualsInt128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5408         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5409         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5410 
5411         for (int i = 0; i < a.length; i += SPECIES.length()) {
5412             var av = VectorShuffle.fromArray(SPECIES, a, i);
5413             var bv = VectorShuffle.fromArray(SPECIES, b, i);
5414             boolean eq = av.equals(bv);
5415             int to = i + SPECIES.length();
5416             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5417         }
5418     }
5419 
5420     @Test(dataProvider = "maskCompareOpProvider")
5421     static void maskEqualsInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5422         boolean[] a = fa.apply(SPECIES.length());
5423         boolean[] b = fb.apply(SPECIES.length());
5424 
5425         for (int i = 0; i < a.length; i += SPECIES.length()) {
5426             var av = SPECIES.loadMask(a, i);
5427             var bv = SPECIES.loadMask(b, i);
5428             boolean equals = av.equals(bv);
5429             int to = i + SPECIES.length();
5430             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5431         }
5432     }
5433 
5434     static boolean beq(boolean a, boolean b) {
5435         return (a == b);
5436     }
5437 
5438     @Test(dataProvider = "maskCompareOpProvider")
5439     static void maskEqInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5440         boolean[] a = fa.apply(SPECIES.length());
5441         boolean[] b = fb.apply(SPECIES.length());
5442         boolean[] r = new boolean[a.length];
5443 
5444         for (int i = 0; i < a.length; i += SPECIES.length()) {
5445             var av = SPECIES.loadMask(a, i);
5446             var bv = SPECIES.loadMask(b, i);
5447             var cv = av.eq(bv);
5448             cv.intoArray(r, i);
5449         }
5450         assertArraysEquals(r, a, b, Int128VectorTests::beq);
5451     }
5452 
5453     @Test(dataProvider = "maskProvider")
5454     static void maskHashCodeInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5455         boolean[] a = fa.apply(SPECIES.length());
5456 
5457         for (int i = 0; i < a.length; i += SPECIES.length()) {
5458             var vmask = SPECIES.loadMask(a, i);
5459             int hash = vmask.hashCode();
5460 
5461             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5462             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5463             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5464         }
5465     }
5466 
5467     static int maskTrueCount(boolean[] a, int idx) {
5468         int trueCount = 0;
5469         for (int i = idx; i < idx + SPECIES.length(); i++) {
5470             trueCount += a[i] ? 1 : 0;
5471         }
5472         return trueCount;
5473     }
5474 
5475     @Test(dataProvider = "maskProvider")
5476     static void maskTrueCountInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5477         boolean[] a = fa.apply(SPECIES.length());
5478         int[] r = new int[a.length];
5479 
5480         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5481             for (int i = 0; i < a.length; i += SPECIES.length()) {
5482                 var vmask = SPECIES.loadMask(a, i);
5483                 r[i] = vmask.trueCount();
5484             }
5485         }
5486 
5487         assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskTrueCount);
5488     }
5489 
5490     static int maskLastTrue(boolean[] a, int idx) {
5491         int i = idx + SPECIES.length() - 1;
5492         for (; i >= idx; i--) {
5493             if (a[i]) {
5494                 break;
5495             }
5496         }
5497         return i - idx;
5498     }
5499 
5500     @Test(dataProvider = "maskProvider")
5501     static void maskLastTrueInt128VectorTestsSmokeTest(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.lastTrue();
5509             }
5510         }
5511 
5512         assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskLastTrue);
5513     }
5514 
5515     static int maskFirstTrue(boolean[] a, int idx) {
5516         int i = idx;
5517         for (; i < idx + SPECIES.length(); i++) {
5518             if (a[i]) {
5519                 break;
5520             }
5521         }
5522         return i - idx;
5523     }
5524 
5525     @Test(dataProvider = "maskProvider")
5526     static void maskFirstTrueInt128VectorTestsSmokeTest(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.firstTrue();
5534             }
5535         }
5536 
5537         assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskFirstTrue);
5538     }
5539 
5540     @Test(dataProvider = "maskProvider")
5541     static void maskCompressInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5542         int trueCount = 0;
5543         boolean[] a = fa.apply(SPECIES.length());
5544 
5545         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5546             for (int i = 0; i < a.length; i += SPECIES.length()) {
5547                 var vmask = SPECIES.loadMask(a, i);
5548                 trueCount = vmask.trueCount();
5549                 var rmask = vmask.compress();
5550                 for (int j = 0; j < SPECIES.length(); j++)  {
5551                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5552                 }
5553             }
5554         }
5555     }
5556 
5557     @DataProvider
5558     public static Object[][] longMaskProvider() {
5559         return new Object[][]{
5560                 {0xFFFFFFFFFFFFFFFFL},
5561                 {0x0000000000000000L},
5562                 {0x5555555555555555L},
5563                 {0x0123456789abcdefL},
5564         };
5565     }
5566 
5567     @Test(dataProvider = "longMaskProvider")
5568     static void maskFromToLongInt128VectorTestsSmokeTest(long inputLong) {
5569         var vmask = VectorMask.fromLong(SPECIES, inputLong);
5570         long outputLong = vmask.toLong();
5571         Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));
5572     }
5573 
5574     @DataProvider
5575     public static Object[][] offsetProvider() {
5576         return new Object[][]{
5577                 {0},
5578                 {-1},
5579                 {+1},
5580                 {+2},
5581                 {-2},
5582         };
5583     }
5584 
5585     @Test(dataProvider = "offsetProvider")
5586     static void indexInRangeInt128VectorTestsSmokeTest(int offset) {
5587         int limit = SPECIES.length() * BUFFER_REPS;
5588         for (int i = 0; i < limit; i += SPECIES.length()) {
5589             var actualMask = SPECIES.indexInRange(i + offset, limit);
5590             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5591             assert(actualMask.equals(expectedMask));
5592             for (int j = 0; j < SPECIES.length(); j++)  {
5593                 int index = i + j + offset;
5594                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5595             }
5596         }
5597     }
5598 
5599     @DataProvider
5600     public static Object[][] lengthProvider() {
5601         return new Object[][]{
5602                 {0},
5603                 {1},
5604                 {32},
5605                 {37},
5606                 {1024},
5607                 {1024+1},
5608                 {1024+5},
5609         };
5610     }
5611 
5612     @Test(dataProvider = "lengthProvider")
5613     static void loopBoundInt128VectorTestsSmokeTest(int length) {
5614         int actualLoopBound = SPECIES.loopBound(length);
5615         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5616         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5617     }
5618 
5619     @Test
5620     static void ElementSizeInt128VectorTestsSmokeTest() {
5621         IntVector av = IntVector.zero(SPECIES);
5622         int elsize = av.elementSize();
5623         Assert.assertEquals(elsize, Integer.SIZE);
5624     }
5625 
5626     @Test
5627     static void VectorShapeInt128VectorTestsSmokeTest() {
5628         IntVector av = IntVector.zero(SPECIES);
5629         VectorShape vsh = av.shape();
5630         assert(vsh.equals(VectorShape.S_128_BIT));
5631     }
5632 
5633     @Test
5634     static void ShapeWithLanesInt128VectorTestsSmokeTest() {
5635         IntVector av = IntVector.zero(SPECIES);
5636         VectorShape vsh = av.shape();
5637         VectorSpecies species = vsh.withLanes(int.class);
5638         assert(species.equals(SPECIES));
5639     }
5640 
5641     @Test
5642     static void ElementTypeInt128VectorTestsSmokeTest() {
5643         IntVector av = IntVector.zero(SPECIES);
5644         assert(av.species().elementType() == int.class);
5645     }
5646 
5647     @Test
5648     static void SpeciesElementSizeInt128VectorTestsSmokeTest() {
5649         IntVector av = IntVector.zero(SPECIES);
5650         assert(av.species().elementSize() == Integer.SIZE);
5651     }
5652 
5653     @Test
5654     static void VectorTypeInt128VectorTestsSmokeTest() {
5655         IntVector av = IntVector.zero(SPECIES);
5656         assert(av.species().vectorType() == av.getClass());
5657     }
5658 
5659     @Test
5660     static void WithLanesInt128VectorTestsSmokeTest() {
5661         IntVector av = IntVector.zero(SPECIES);
5662         VectorSpecies species = av.species().withLanes(int.class);
5663         assert(species.equals(SPECIES));
5664     }
5665 
5666     @Test
5667     static void WithShapeInt128VectorTestsSmokeTest() {
5668         IntVector av = IntVector.zero(SPECIES);
5669         VectorShape vsh = av.shape();
5670         VectorSpecies species = av.species().withShape(vsh);
5671         assert(species.equals(SPECIES));
5672     }
5673 }
5674