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