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