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