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