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