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