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