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