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