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