1 /*
   2  * Copyright (c) 2018, 2025, 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  * @key randomness
  27  *
  28  * @library /test/lib
  29  * @modules jdk.incubator.vector
  30  * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation ByteMaxVectorTests
  31  */
  32 
  33 // -- This file was mechanically generated: Do not edit! -- //
  34 
  35 import jdk.incubator.vector.VectorShape;
  36 import jdk.incubator.vector.VectorSpecies;
  37 import jdk.incubator.vector.VectorShuffle;
  38 import jdk.incubator.vector.VectorMask;
  39 import jdk.incubator.vector.VectorOperators;
  40 import jdk.incubator.vector.Vector;
  41 import jdk.incubator.vector.VectorMath;
  42 
  43 import jdk.incubator.vector.ByteVector;
  44 
  45 import org.testng.Assert;
  46 import org.testng.annotations.DataProvider;
  47 import org.testng.annotations.Test;
  48 
  49 import java.lang.Integer;
  50 import java.util.List;
  51 import java.util.Arrays;
  52 import java.util.function.BiFunction;
  53 import java.util.function.IntFunction;
  54 import java.util.Objects;
  55 import java.util.stream.Collectors;
  56 import java.util.stream.Stream;
  57 
  58 @Test
  59 public class ByteMaxVectorTests extends AbstractVectorTest {
  60 
  61     static final VectorSpecies<Byte> SPECIES =
  62                 ByteVector.SPECIES_MAX;
  63 
  64     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  65 
  66     static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10);
  67 
  68     static VectorShape getMaxBit() {
  69         return VectorShape.S_Max_BIT;
  70     }
  71 
  72     private static final int Max = 256;  // juts so we can do N/Max
  73 
  74     private static final byte CONST_SHIFT = Byte.SIZE / 2;
  75 
  76     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  77 
  78     static void assertArraysStrictlyEquals(byte[] r, byte[] a) {
  79         for (int i = 0; i < a.length; i++) {
  80             if (r[i] != a[i]) {
  81                 Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]);
  82             }
  83         }
  84     }
  85 
  86     interface FUnOp {
  87         byte apply(byte a);
  88     }
  89 
  90     static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) {
  91         int i = 0;
  92         try {
  93             for (; i < a.length; i++) {
  94                 Assert.assertEquals(r[i], f.apply(a[i]));
  95             }
  96         } catch (AssertionError e) {
  97             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  98         }
  99     }
 100 
 101     interface FUnArrayOp {
 102         byte[] apply(byte a);
 103     }
 104 
 105     static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) {
 106         int i = 0;
 107         try {
 108             for (; i < a.length; i += SPECIES.length()) {
 109                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 110                   f.apply(a[i]));
 111             }
 112         } catch (AssertionError e) {
 113             byte[] ref = f.apply(a[i]);
 114             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 115             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 116               + ", res: " + Arrays.toString(res)
 117               + "), at index #" + i);
 118         }
 119     }
 120 
 121     static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) {
 122         int i = 0;
 123         try {
 124             for (; i < a.length; i++) {
 125                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 126             }
 127         } catch (AssertionError e) {
 128             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()]);
 129         }
 130     }
 131 
 132     interface FReductionOp {
 133         byte apply(byte[] a, int idx);
 134     }
 135 
 136     interface FReductionAllOp {
 137         byte apply(byte[] a);
 138     }
 139 
 140     static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a,
 141                                             FReductionOp f, FReductionAllOp fa) {
 142         int i = 0;
 143         try {
 144             Assert.assertEquals(rc, fa.apply(a));
 145             for (; i < a.length; i += SPECIES.length()) {
 146                 Assert.assertEquals(r[i], f.apply(a, i));
 147             }
 148         } catch (AssertionError e) {
 149             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 150             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 151         }
 152     }
 153 
 154     interface FReductionMaskedOp {
 155         byte apply(byte[] a, int idx, boolean[] mask);
 156     }
 157 
 158     interface FReductionAllMaskedOp {
 159         byte apply(byte[] a, boolean[] mask);
 160     }
 161 
 162     static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boolean[] mask,
 163                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 164         int i = 0;
 165         try {
 166             Assert.assertEquals(rc, fa.apply(a, mask));
 167             for (; i < a.length; i += SPECIES.length()) {
 168                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 169             }
 170         } catch (AssertionError e) {
 171             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 172             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 173         }
 174     }
 175 
 176     interface FReductionOpLong {
 177         long apply(byte[] a, int idx);
 178     }
 179 
 180     interface FReductionAllOpLong {
 181         long apply(byte[] a);
 182     }
 183 
 184     static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a,
 185                                             FReductionOpLong f, FReductionAllOpLong fa) {
 186         int i = 0;
 187         try {
 188             Assert.assertEquals(rc, fa.apply(a));
 189             for (; i < a.length; i += SPECIES.length()) {
 190                 Assert.assertEquals(r[i], f.apply(a, i));
 191             }
 192         } catch (AssertionError e) {
 193             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 194             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 195         }
 196     }
 197 
 198     interface FReductionMaskedOpLong {
 199         long apply(byte[] a, int idx, boolean[] mask);
 200     }
 201 
 202     interface FReductionAllMaskedOpLong {
 203         long apply(byte[] a, boolean[] mask);
 204     }
 205 
 206     static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, boolean[] mask,
 207                                             FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {
 208         int i = 0;
 209         try {
 210             Assert.assertEquals(rc, fa.apply(a, mask));
 211             for (; i < a.length; i += SPECIES.length()) {
 212                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 213             }
 214         } catch (AssertionError e) {
 215             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 216             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 217         }
 218     }
 219 
 220     interface FBoolReductionOp {
 221         boolean apply(boolean[] a, int idx);
 222     }
 223 
 224     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 225         int i = 0;
 226         try {
 227             for (; i < a.length; i += SPECIES.length()) {
 228                 Assert.assertEquals(r[i], f.apply(a, i));
 229             }
 230         } catch (AssertionError e) {
 231             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 232         }
 233     }
 234 
 235     interface FMaskReductionOp {
 236         int apply(boolean[] a, int idx);
 237     }
 238 
 239     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 240         int i = 0;
 241         try {
 242             for (; i < a.length; i += SPECIES.length()) {
 243                 Assert.assertEquals(r[i], f.apply(a, i));
 244             }
 245         } catch (AssertionError e) {
 246             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 247         }
 248     }
 249 
 250     static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) {
 251         int i = 0, j = 0;
 252         try {
 253             for (; i < a.length; i += vector_len) {
 254                 for (j = 0; j < vector_len; j++) {
 255                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 256                 }
 257             }
 258         } catch (AssertionError e) {
 259             int idx = i + j;
 260             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 261         }
 262     }
 263 
 264     static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vector_len) {
 265         int i = 0, j = 0, k = 0;
 266         try {
 267             for (; i < a.length; i += vector_len) {
 268                 k = 0;
 269                 for (j = 0; j < vector_len; j++) {
 270                     if (m[(i + j) % SPECIES.length()]) {
 271                         Assert.assertEquals(r[i + k], a[i + j]);
 272                         k++;
 273                     }
 274                 }
 275                 for (; k < vector_len; k++) {
 276                     Assert.assertEquals(r[i + k], (byte)0);
 277                 }
 278             }
 279         } catch (AssertionError e) {
 280             int idx = i + k;
 281             if (m[(i + j) % SPECIES.length()]) {
 282                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 283             } else {
 284                 Assert.assertEquals(r[idx], (byte)0, "at index #" + idx);
 285             }
 286         }
 287     }
 288 
 289     static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector_len) {
 290         int i = 0, j = 0, k = 0;
 291         try {
 292             for (; i < a.length; i += vector_len) {
 293                 k = 0;
 294                 for (j = 0; j < vector_len; j++) {
 295                     if (m[(i + j) % SPECIES.length()]) {
 296                         Assert.assertEquals(r[i + j], a[i + k]);
 297                         k++;
 298                     } else {
 299                         Assert.assertEquals(r[i + j], (byte)0);
 300                     }
 301                 }
 302             }
 303         } catch (AssertionError e) {
 304             int idx = i + j;
 305             if (m[idx % SPECIES.length()]) {
 306                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 307             } else {
 308                 Assert.assertEquals(r[idx], (byte)0, "at index #" + idx);
 309             }
 310         }
 311     }
 312 
 313     static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, byte[] b, int vector_len) {
 314         int i = 0, j = 0;
 315         boolean is_exceptional_idx = false;
 316         int idx = 0, wrapped_index = 0, oidx = 0;
 317         try {
 318             for (; i < a.length; i += vector_len) {
 319                 for (j = 0; j < vector_len; j++) {
 320                     idx = i + j;
 321                     wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len);
 322                     is_exceptional_idx = wrapped_index >= vector_len;
 323                     oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index;
 324                     Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]));
 325                 }
 326             }
 327         } catch (AssertionError e) {
 328             Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]);
 329         }
 330     }
 331 
 332     static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) {
 333         int i = 0, j = 0;
 334         try {
 335             for (; i < a.length; i += vector_len) {
 336                 for (j = 0; j < vector_len; j++) {
 337                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 338                 }
 339             }
 340         } catch (AssertionError e) {
 341             int idx = i + j;
 342             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 343         }
 344     }
 345 
 346     static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) {
 347         int i = 0, j = 0;
 348         try {
 349             for (; i < a.length; i += vector_len) {
 350                 for (j = 0; j < vector_len; j++) {
 351                     if (mask[j % SPECIES.length()])
 352                          Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 353                     else
 354                          Assert.assertEquals(r[i+j], (byte)0);
 355                 }
 356             }
 357         } catch (AssertionError e) {
 358             int idx = i + j;
 359             if (mask[j % SPECIES.length()])
 360                 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 361             else
 362                 Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 363         }
 364     }
 365 
 366     static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) {
 367         int i = 0, j = 0;
 368         try {
 369             for (; i < a.length; i += vector_len) {
 370                 for (j = 0; j < vector_len; j++) {
 371                     if (mask[j % SPECIES.length()])
 372                          Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 373                     else
 374                          Assert.assertEquals(r[i+j], (byte)0);
 375                 }
 376             }
 377         } catch (AssertionError e) {
 378             int idx = i + j;
 379             if (mask[j % SPECIES.length()])
 380                 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()]);
 381             else
 382                 Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
 383         }
 384     }
 385 
 386     static void assertBroadcastArraysEquals(byte[] r, byte[] a) {
 387         int i = 0;
 388         for (; i < a.length; i += SPECIES.length()) {
 389             int idx = i;
 390             for (int j = idx; j < (idx + SPECIES.length()); j++)
 391                 a[j]=a[idx];
 392         }
 393 
 394         try {
 395             for (i = 0; i < a.length; i++) {
 396                 Assert.assertEquals(r[i], a[i]);
 397             }
 398         } catch (AssertionError e) {
 399             Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
 400         }
 401     }
 402 
 403     interface FBinOp {
 404         byte apply(byte a, byte b);
 405     }
 406 
 407     interface FBinMaskOp {
 408         byte apply(byte a, byte b, boolean m);
 409 
 410         static FBinMaskOp lift(FBinOp f) {
 411             return (a, b, m) -> m ? f.apply(a, b) : a;
 412         }
 413     }
 414 
 415     static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] b, byte[] c, FBinOp f) {
 416         int i = 0;
 417         try {
 418             for (; i < a.length; i++) {
 419                 //Left associative
 420                 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]));
 421 
 422                 //Right associative
 423                 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])));
 424 
 425                 //Results equal sanity check
 426                 Assert.assertEquals(rl[i], rr[i]);
 427             }
 428         } catch (AssertionError e) {
 429             Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 430             Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 431             Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
 432         }
 433     }
 434 
 435    static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] b, byte[] c, boolean[] mask, FBinOp f) {
 436        assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f));
 437    }
 438 
 439     static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] b, byte[] c, boolean[] mask, FBinMaskOp f) {
 440         int i = 0;
 441         boolean mask_bit = false;
 442         try {
 443             for (; i < a.length; i++) {
 444                 mask_bit = mask[i % SPECIES.length()];
 445                 //Left associative
 446                 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit));
 447 
 448                 //Right associative
 449                 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit));
 450 
 451                 //Results equal sanity check
 452                 Assert.assertEquals(rl[i], rr[i]);
 453             }
 454         } catch (AssertionError e) {
 455             Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
 456             Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
 457             Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
 458         }
 459     }
 460 
 461     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) {
 462         int i = 0;
 463         try {
 464             for (; i < a.length; i++) {
 465                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 466             }
 467         } catch (AssertionError e) {
 468             Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
 469         }
 470     }
 471 
 472     static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) {
 473         int i = 0;
 474         try {
 475             for (; i < a.length; i++) {
 476                 Assert.assertEquals(r[i], f.apply(a[i], b));
 477             }
 478         } catch (AssertionError e) {
 479             Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i);
 480         }
 481     }
 482 
 483     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) {
 484         int i = 0;
 485         try {
 486             for (; i < a.length; i++) {
 487                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
 488             }
 489         } catch (AssertionError e) {
 490             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
 491                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 492         }
 493     }
 494 
 495     static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) {
 496         int i = 0;
 497         try {
 498             for (; i < a.length; i++) {
 499                 Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
 500             }
 501         } catch (AssertionError e) {
 502             Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
 503                                 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
 504         }
 505     }
 506 
 507     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) {
 508         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 509     }
 510 
 511     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) {
 512         int i = 0;
 513         try {
 514             for (; i < a.length; i++) {
 515                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 516             }
 517         } catch (AssertionError err) {
 518             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()]);
 519         }
 520     }
 521 
 522     static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinOp f) {
 523         assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 524     }
 525 
 526     static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinMaskOp f) {
 527         int i = 0;
 528         try {
 529             for (; i < a.length; i++) {
 530                 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]));
 531             }
 532         } catch (AssertionError err) {
 533             Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]);
 534         }
 535     }
 536 
 537     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) {
 538         assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 539     }
 540 
 541     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) {
 542         int i = 0;
 543         try {
 544             for (; i < a.length; i++) {
 545                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 546             }
 547         } catch (AssertionError err) {
 548             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 549                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 550                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 551                                 mask[i % SPECIES.length()]);
 552         }
 553     }
 554 
 555     static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) {
 556         assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 557     }
 558 
 559     static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) {
 560         int i = 0;
 561         try {
 562             for (; i < a.length; i++) {
 563                 Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
 564             }
 565         } catch (AssertionError err) {
 566             Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
 567                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 568                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 569                                 mask[i % SPECIES.length()]);
 570         }
 571     }
 572 
 573     static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) {
 574         int i = 0;
 575         int j = 0;
 576         try {
 577             for (; j < a.length; j += SPECIES.length()) {
 578                 for (i = 0; i < SPECIES.length(); i++) {
 579                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
 580                 }
 581             }
 582         } catch (AssertionError e) {
 583             Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
 584         }
 585     }
 586 
 587     static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinOp f) {
 588         assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
 589     }
 590 
 591     static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBinMaskOp f) {
 592         int i = 0;
 593         int j = 0;
 594         try {
 595             for (; j < a.length; j += SPECIES.length()) {
 596                 for (i = 0; i < SPECIES.length(); i++) {
 597                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 598                 }
 599             }
 600         } catch (AssertionError err) {
 601             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]);
 602         }
 603     }
 604 
 605     interface FBinConstOp {
 606         byte apply(byte a);
 607     }
 608 
 609     interface FBinConstMaskOp {
 610         byte apply(byte a, boolean m);
 611 
 612         static FBinConstMaskOp lift(FBinConstOp f) {
 613             return (a, m) -> m ? f.apply(a) : a;
 614         }
 615     }
 616 
 617     static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) {
 618         int i = 0;
 619         int j = 0;
 620         try {
 621             for (; j < a.length; j += SPECIES.length()) {
 622                 for (i = 0; i < SPECIES.length(); i++) {
 623                     Assert.assertEquals(r[i+j], f.apply(a[i+j]));
 624                 }
 625             }
 626         } catch (AssertionError e) {
 627             Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
 628         }
 629     }
 630 
 631     static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstOp f) {
 632         assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
 633     }
 634 
 635     static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConstMaskOp f) {
 636         int i = 0;
 637         int j = 0;
 638         try {
 639             for (; j < a.length; j += SPECIES.length()) {
 640                 for (i = 0; i < SPECIES.length(); i++) {
 641                     Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
 642                 }
 643             }
 644         } catch (AssertionError err) {
 645             Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
 646         }
 647     }
 648 
 649     interface FTernOp {
 650         byte apply(byte a, byte b, byte c);
 651     }
 652 
 653     interface FTernMaskOp {
 654         byte apply(byte a, byte b, byte c, boolean m);
 655 
 656         static FTernMaskOp lift(FTernOp f) {
 657             return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
 658         }
 659     }
 660 
 661     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) {
 662         int i = 0;
 663         try {
 664             for (; i < a.length; i++) {
 665                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
 666             }
 667         } catch (AssertionError e) {
 668             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
 669         }
 670     }
 671 
 672     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernOp f) {
 673         assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 674     }
 675 
 676     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask, FTernMaskOp f) {
 677         int i = 0;
 678         try {
 679             for (; i < a.length; i++) {
 680                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
 681             }
 682         } catch (AssertionError err) {
 683             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
 684               + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 685         }
 686     }
 687 
 688     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) {
 689         int i = 0;
 690         try {
 691             for (; i < a.length; i++) {
 692                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
 693             }
 694         } catch (AssertionError e) {
 695             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
 696                                 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
 697                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 698         }
 699     }
 700 
 701     static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) {
 702         int i = 0;
 703         try {
 704             for (; i < a.length; i++) {
 705                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
 706             }
 707         } catch (AssertionError e) {
 708             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
 709                                 i + ", input1 = " + a[i] + ", input2 = " +
 710                                 b[(i / SPECIES.length()) * SPECIES.length()] + ",  input3 = " + c[i]);
 711         }
 712     }
 713 
 714     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 715                                             FTernOp f) {
 716         assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 717     }
 718 
 719     static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 720                                             FTernMaskOp f) {
 721         int i = 0;
 722         try {
 723             for (; i < a.length; i++) {
 724                 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 725                                     mask[i % SPECIES.length()]));
 726             }
 727         } catch (AssertionError err) {
 728             Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
 729                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
 730                                 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 731                                 mask[i % SPECIES.length()]);
 732         }
 733     }
 734 
 735     static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 736                                             FTernOp f) {
 737         assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 738     }
 739 
 740     static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 741                                             FTernMaskOp f) {
 742         int i = 0;
 743         try {
 744             for (; i < a.length; i++) {
 745                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 746                                     mask[i % SPECIES.length()]));
 747             }
 748         } catch (AssertionError err) {
 749             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
 750                                 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
 751                                 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 752                                 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
 753         }
 754     }
 755 
 756     static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f) {
 757         int i = 0;
 758         try {
 759             for (; i < a.length; i++) {
 760                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 761                                     c[(i / SPECIES.length()) * SPECIES.length()]));
 762             }
 763         } catch (AssertionError e) {
 764             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 765                                 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
 766                                 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
 767                                 c[(i / SPECIES.length()) * SPECIES.length()]);
 768         }
 769     }
 770 
 771     static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 772                                                   FTernOp f) {
 773         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
 774     }
 775 
 776     static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] mask,
 777                                                   FTernMaskOp f) {
 778         int i = 0;
 779         try {
 780             for (; i < a.length; i++) {
 781                 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 782                                     c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
 783             }
 784         } catch (AssertionError err) {
 785             Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
 786                                 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
 787                                 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
 788                                 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
 789                                 mask[i % SPECIES.length()]);
 790         }
 791     }
 792 
 793 
 794 
 795     interface FGatherScatterOp {
 796         byte[] apply(byte[] a, int ix, int[] b, int iy);
 797     }
 798 
 799     static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) {
 800         int i = 0;
 801         try {
 802             for (; i < a.length; i += SPECIES.length()) {
 803                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 804                   f.apply(a, i, b, i));
 805             }
 806         } catch (AssertionError e) {
 807             byte[] ref = f.apply(a, i, b, i);
 808             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 809             Assert.assertEquals(res, ref,
 810               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 811               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 812               + ", b: "
 813               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 814               + " at index #" + i);
 815         }
 816     }
 817 
 818     interface FGatherMaskedOp {
 819         byte[] apply(byte[] a, int ix, boolean[] mask, int[] b, int iy);
 820     }
 821 
 822     interface FScatterMaskedOp {
 823         byte[] apply(byte[] r, byte[] a, int ix, boolean[] mask, int[] b, int iy);
 824     }
 825 
 826     static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
 827         int i = 0;
 828         try {
 829             for (; i < a.length; i += SPECIES.length()) {
 830                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 831                   f.apply(a, i, mask, b, i));
 832             }
 833         } catch (AssertionError e) {
 834             byte[] ref = f.apply(a, i, mask, b, i);
 835             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 836             Assert.assertEquals(res, ref,
 837               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 838               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 839               + ", b: "
 840               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 841               + ", mask: "
 842               + Arrays.toString(mask)
 843               + " at index #" + i);
 844         }
 845     }
 846 
 847     static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
 848         int i = 0;
 849         try {
 850             for (; i < a.length; i += SPECIES.length()) {
 851                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 852                   f.apply(r, a, i, mask, b, i));
 853             }
 854         } catch (AssertionError e) {
 855             byte[] ref = f.apply(r, a, i, mask, b, i);
 856             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 857             Assert.assertEquals(res, ref,
 858               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 859               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 860               + ", b: "
 861               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 862               + ", r: "
 863               + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
 864               + ", mask: "
 865               + Arrays.toString(mask)
 866               + " at index #" + i);
 867         }
 868     }
 869 
 870     interface FLaneOp {
 871         byte[] apply(byte[] a, int origin, int idx);
 872     }
 873 
 874     static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) {
 875         int i = 0;
 876         try {
 877             for (; i < a.length; i += SPECIES.length()) {
 878                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 879                   f.apply(a, origin, i));
 880             }
 881         } catch (AssertionError e) {
 882             byte[] ref = f.apply(a, origin, i);
 883             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 884             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 885               + ", res: " + Arrays.toString(res)
 886               + "), at index #" + i);
 887         }
 888     }
 889 
 890     interface FLaneBop {
 891         byte[] apply(byte[] a, byte[] b, int origin, int idx);
 892     }
 893 
 894     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBop f) {
 895         int i = 0;
 896         try {
 897             for (; i < a.length; i += SPECIES.length()) {
 898                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 899                   f.apply(a, b, origin, i));
 900             }
 901         } catch (AssertionError e) {
 902             byte[] ref = f.apply(a, b, origin, i);
 903             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 904             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 905               + ", res: " + Arrays.toString(res)
 906               + "), at index #" + i
 907               + ", at origin #" + origin);
 908         }
 909     }
 910 
 911     interface FLaneMaskedBop {
 912         byte[] apply(byte[] a, byte[] b, int origin, boolean[] mask, int idx);
 913     }
 914 
 915     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
 916         int i = 0;
 917         try {
 918             for (; i < a.length; i += SPECIES.length()) {
 919                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 920                   f.apply(a, b, origin, mask, i));
 921             }
 922         } catch (AssertionError e) {
 923             byte[] ref = f.apply(a, b, origin, mask, i);
 924             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 925             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 926               + ", res: " + Arrays.toString(res)
 927               + "), at index #" + i
 928               + ", at origin #" + origin);
 929         }
 930     }
 931 
 932     interface FLanePartBop {
 933         byte[] apply(byte[] a, byte[] b, int origin, int part, int idx);
 934     }
 935 
 936     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, FLanePartBop f) {
 937         int i = 0;
 938         try {
 939             for (; i < a.length; i += SPECIES.length()) {
 940                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 941                   f.apply(a, b, origin, part, i));
 942             }
 943         } catch (AssertionError e) {
 944             byte[] ref = f.apply(a, b, origin, part, i);
 945             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 946             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 947               + ", res: " + Arrays.toString(res)
 948               + "), at index #" + i
 949               + ", at origin #" + origin
 950               + ", with part #" + part);
 951         }
 952     }
 953 
 954     interface FLanePartMaskedBop {
 955         byte[] apply(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx);
 956     }
 957 
 958     static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
 959         int i = 0;
 960         try {
 961             for (; i < a.length; i += SPECIES.length()) {
 962                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 963                   f.apply(a, b, origin, part, mask, i));
 964             }
 965         } catch (AssertionError e) {
 966             byte[] ref = f.apply(a, b, origin, part, mask, i);
 967             byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 968             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 969               + ", res: " + Arrays.toString(res)
 970               + "), at index #" + i
 971               + ", at origin #" + origin
 972               + ", with part #" + part);
 973         }
 974     }
 975 
 976 
 977     static void assertArraysEquals(int[] r, byte[] a, int offs) {
 978         int i = 0;
 979         try {
 980             for (; i < r.length; i++) {
 981                 Assert.assertEquals(r[i], (int)(a[i+offs]));
 982             }
 983         } catch (AssertionError e) {
 984             Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 985         }
 986     }
 987 
 988 
 989     static void assertArraysEquals(byte[] r, byte[] a, int offs) {
 990         int i = 0;
 991         try {
 992             for (; i < r.length; i++) {
 993                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 994             }
 995         } catch (AssertionError e) {
 996             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 997         }
 998     }
 999 
1000     static void assertArraysEquals(long[] r, byte[] a, int offs) {
1001         int i = 0;
1002         try {
1003             for (; i < r.length; i++) {
1004                 Assert.assertEquals(r[i], (long)(a[i+offs]));
1005             }
1006         } catch (AssertionError e) {
1007             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1008         }
1009     }
1010 
1011     static void assertArraysEquals(double[] r, byte[] a, int offs) {
1012         int i = 0;
1013         try {
1014             for (; i < r.length; i++) {
1015                 Assert.assertEquals(r[i], (double)(a[i+offs]));
1016             }
1017         } catch (AssertionError e) {
1018             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1019         }
1020     }
1021 
1022     static byte bits(byte e) {
1023         return  e;
1024     }
1025 
1026     static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of(
1027             withToString("byte[-i * 5]", (int s) -> {
1028                 return fill(s * BUFFER_REPS,
1029                             i -> (byte)(-i * 5));
1030             }),
1031             withToString("byte[i * 5]", (int s) -> {
1032                 return fill(s * BUFFER_REPS,
1033                             i -> (byte)(i * 5));
1034             }),
1035             withToString("byte[i + 1]", (int s) -> {
1036                 return fill(s * BUFFER_REPS,
1037                             i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1)));
1038             }),
1039             withToString("byte[cornerCaseValue(i)]", (int s) -> {
1040                 return fill(s * BUFFER_REPS,
1041                             i -> cornerCaseValue(i));
1042             })
1043     );
1044 
1045     static final List<IntFunction<byte[]>> BYTE_SATURATING_GENERATORS = List.of(
1046             withToString("byte[Byte.MIN_VALUE]", (int s) -> {
1047                 return fill(s * BUFFER_REPS,
1048                             i -> (byte)(Byte.MIN_VALUE));
1049             }),
1050             withToString("byte[Byte.MAX_VALUE]", (int s) -> {
1051                 return fill(s * BUFFER_REPS,
1052                             i -> (byte)(Byte.MAX_VALUE));
1053             }),
1054             withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> {
1055                 return fill(s * BUFFER_REPS,
1056                             i -> (byte)(Byte.MAX_VALUE - 100));
1057             }),
1058             withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> {
1059                 return fill(s * BUFFER_REPS,
1060                             i -> (byte)(Byte.MIN_VALUE + 100));
1061             }),
1062             withToString("byte[-i * 5]", (int s) -> {
1063                 return fill(s * BUFFER_REPS,
1064                             i -> (byte)(-i * 5));
1065             }),
1066             withToString("byte[i * 5]", (int s) -> {
1067                 return fill(s * BUFFER_REPS,
1068                             i -> (byte)(i * 5));
1069             })
1070     );
1071 
1072     static final List<IntFunction<byte[]>> BYTE_SATURATING_GENERATORS_ASSOC = List.of(
1073             withToString("byte[Byte.MAX_VALUE]", (int s) -> {
1074                 return fill(s * BUFFER_REPS,
1075                             i -> (byte)(Byte.MAX_VALUE));
1076             }),
1077             withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> {
1078                 return fill(s * BUFFER_REPS,
1079                             i -> (byte)(Byte.MAX_VALUE - 100));
1080             }),
1081             withToString("byte[-1]", (int s) -> {
1082                 return fill(s * BUFFER_REPS,
1083                             i -> (byte)(-1));
1084             })
1085     );
1086 
1087     // Create combinations of pairs
1088     // @@@ Might be sensitive to order e.g. div by 0
1089     static final List<List<IntFunction<byte[]>>> BYTE_GENERATOR_PAIRS =
1090         Stream.of(BYTE_GENERATORS.get(0)).
1091                 flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1092                 collect(Collectors.toList());
1093 
1094     static final List<List<IntFunction<byte[]>>> BYTE_SATURATING_GENERATOR_PAIRS =
1095         Stream.of(BYTE_GENERATORS.get(0)).
1096                 flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1097                 collect(Collectors.toList());
1098 
1099     static final List<List<IntFunction<byte[]>>> BYTE_SATURATING_GENERATOR_TRIPLETS =
1100             Stream.of(BYTE_GENERATORS.get(1))
1101                     .flatMap(fa -> BYTE_SATURATING_GENERATORS_ASSOC.stream().map(fb -> List.of(fa, fb)))
1102                     .flatMap(pair -> BYTE_SATURATING_GENERATORS_ASSOC.stream().map(f -> List.of(pair.get(0), pair.get(1), f)))
1103                     .collect(Collectors.toList());
1104 
1105     @DataProvider
1106     public Object[][] boolUnaryOpProvider() {
1107         return BOOL_ARRAY_GENERATORS.stream().
1108                 map(f -> new Object[]{f}).
1109                 toArray(Object[][]::new);
1110     }
1111 
1112     static final List<List<IntFunction<byte[]>>> BYTE_GENERATOR_TRIPLES =
1113         BYTE_GENERATOR_PAIRS.stream().
1114                 flatMap(pair -> BYTE_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1115                 collect(Collectors.toList());
1116 
1117     static final List<IntFunction<byte[]>> SELECT_FROM_INDEX_GENERATORS = List.of(
1118             withToString("byte[0..VECLEN*2)", (int s) -> {
1119                 return fill(s * BUFFER_REPS,
1120                             i -> (byte)(RAND.nextInt()));
1121             })
1122     );
1123 
1124     static final List<List<IntFunction<byte[]>>> BYTE_GENERATOR_SELECT_FROM_TRIPLES =
1125         BYTE_GENERATOR_PAIRS.stream().
1126                 flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1127                 collect(Collectors.toList());
1128 
1129     @DataProvider
1130     public Object[][] byteBinaryOpProvider() {
1131         return BYTE_GENERATOR_PAIRS.stream().map(List::toArray).
1132                 toArray(Object[][]::new);
1133     }
1134 
1135     @DataProvider
1136     public Object[][] byteSaturatingBinaryOpProvider() {
1137         return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray).
1138                 toArray(Object[][]::new);
1139     }
1140 
1141     @DataProvider
1142     public Object[][] byteSaturatingBinaryOpAssocProvider() {
1143         return BYTE_SATURATING_GENERATOR_TRIPLETS.stream().map(List::toArray).
1144                 toArray(Object[][]::new);
1145     }
1146 
1147     @DataProvider
1148     public Object[][] byteSaturatingBinaryOpAssocMaskProvider() {
1149         return BOOLEAN_MASK_GENERATORS.stream().
1150                 flatMap(fm -> BYTE_SATURATING_GENERATOR_TRIPLETS.stream().map(lfa -> {
1151                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1152                 })).
1153                 toArray(Object[][]::new);
1154     }
1155 
1156 
1157     @DataProvider
1158     public Object[][] byteIndexedOpProvider() {
1159         return BYTE_GENERATOR_PAIRS.stream().map(List::toArray).
1160                 toArray(Object[][]::new);
1161     }
1162 
1163     @DataProvider
1164     public Object[][] byteSaturatingBinaryOpMaskProvider() {
1165         return BOOLEAN_MASK_GENERATORS.stream().
1166                 flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> {
1167                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1168                 })).
1169                 toArray(Object[][]::new);
1170     }
1171 
1172    @DataProvider
1173    public Object[][] byteSaturatingUnaryOpProvider() {
1174        return BYTE_SATURATING_GENERATORS.stream().
1175                     map(f -> new Object[]{f}).
1176                     toArray(Object[][]::new);
1177    }
1178 
1179    @DataProvider
1180    public Object[][] byteSaturatingUnaryOpMaskProvider() {
1181         return BOOLEAN_MASK_GENERATORS.stream().
1182                 flatMap(fm -> BYTE_SATURATING_GENERATORS.stream().map(fa -> {
1183                     return new Object[] {fa, fm};
1184                 })).
1185                 toArray(Object[][]::new);
1186    }
1187 
1188     @DataProvider
1189     public Object[][] byteBinaryOpMaskProvider() {
1190         return BOOLEAN_MASK_GENERATORS.stream().
1191                 flatMap(fm -> BYTE_GENERATOR_PAIRS.stream().map(lfa -> {
1192                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1193                 })).
1194                 toArray(Object[][]::new);
1195     }
1196 
1197     @DataProvider
1198     public Object[][] byteTernaryOpProvider() {
1199         return BYTE_GENERATOR_TRIPLES.stream().map(List::toArray).
1200                 toArray(Object[][]::new);
1201     }
1202 
1203     @DataProvider
1204     public Object[][] byteSelectFromTwoVectorOpProvider() {
1205         return BYTE_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray).
1206                 toArray(Object[][]::new);
1207     }
1208 
1209     @DataProvider
1210     public Object[][] byteTernaryOpMaskProvider() {
1211         return BOOLEAN_MASK_GENERATORS.stream().
1212                 flatMap(fm -> BYTE_GENERATOR_TRIPLES.stream().map(lfa -> {
1213                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1214                 })).
1215                 toArray(Object[][]::new);
1216     }
1217 
1218     @DataProvider
1219     public Object[][] byteUnaryOpProvider() {
1220         return BYTE_GENERATORS.stream().
1221                 map(f -> new Object[]{f}).
1222                 toArray(Object[][]::new);
1223     }
1224 
1225     @DataProvider
1226     public Object[][] byteUnaryOpMaskProvider() {
1227         return BOOLEAN_MASK_GENERATORS.stream().
1228                 flatMap(fm -> BYTE_GENERATORS.stream().map(fa -> {
1229                     return new Object[] {fa, fm};
1230                 })).
1231                 toArray(Object[][]::new);
1232     }
1233 
1234     @DataProvider
1235     public Object[][] maskProvider() {
1236         return BOOLEAN_MASK_GENERATORS.stream().
1237                 map(f -> new Object[]{f}).
1238                 toArray(Object[][]::new);
1239     }
1240 
1241     @DataProvider
1242     public Object[][] maskCompareOpProvider() {
1243         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1244                 toArray(Object[][]::new);
1245     }
1246 
1247     @DataProvider
1248     public Object[][] shuffleProvider() {
1249         return INT_SHUFFLE_GENERATORS.stream().
1250                 map(f -> new Object[]{f}).
1251                 toArray(Object[][]::new);
1252     }
1253 
1254     @DataProvider
1255     public Object[][] shuffleCompareOpProvider() {
1256         return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1257                 toArray(Object[][]::new);
1258     }
1259 
1260     @DataProvider
1261     public Object[][] byteUnaryOpShuffleProvider() {
1262         return INT_SHUFFLE_GENERATORS.stream().
1263                 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1264                     return new Object[] {fa, fs};
1265                 })).
1266                 toArray(Object[][]::new);
1267     }
1268 
1269     @DataProvider
1270     public Object[][] byteUnaryOpShuffleMaskProvider() {
1271         return BOOLEAN_MASK_GENERATORS.stream().
1272                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1273                     flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1274                         return new Object[] {fa, fs, fm};
1275                 }))).
1276                 toArray(Object[][]::new);
1277     }
1278 
1279     static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
1280             withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1281                 byte[] a = new byte[l];
1282                 int upper = Math.min(Byte.MAX_VALUE + 1, m);
1283                 for (int i = 0; i < 1; i++) {
1284                     a[i] = (byte)RAND.nextInt(upper);
1285                 }
1286                 return a;
1287             })
1288     );
1289 
1290     @DataProvider
1291     public Object[][] byteUnaryOpSelectFromProvider() {
1292         return BYTE_SHUFFLE_GENERATORS.stream().
1293                 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1294                     return new Object[] {fa, fs};
1295                 })).
1296                 toArray(Object[][]::new);
1297     }
1298 
1299     @DataProvider
1300     public Object[][] byteUnaryOpSelectFromMaskProvider() {
1301         return BOOLEAN_MASK_GENERATORS.stream().
1302                 flatMap(fm -> BYTE_SHUFFLE_GENERATORS.stream().
1303                     flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1304                         return new Object[] {fa, fs, fm};
1305                 }))).
1306                 toArray(Object[][]::new);
1307     }
1308 
1309     static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
1310             withToString("byte[i]", (int s) -> {
1311                 return fill(s * BUFFER_REPS,
1312                             i -> (byte)i);
1313             }),
1314             withToString("byte[i - length / 2]", (int s) -> {
1315                 return fill(s * BUFFER_REPS,
1316                             i -> (byte)(i - (s * BUFFER_REPS / 2)));
1317             }),
1318             withToString("byte[i + 1]", (int s) -> {
1319                 return fill(s * BUFFER_REPS,
1320                             i -> (byte)(i + 1));
1321             }),
1322             withToString("byte[i - 2]", (int s) -> {
1323                 return fill(s * BUFFER_REPS,
1324                             i -> (byte)(i - 2));
1325             }),
1326             withToString("byte[zigZag(i)]", (int s) -> {
1327                 return fill(s * BUFFER_REPS,
1328                             i -> i%3 == 0 ? (byte)i : (i%3 == 1 ? (byte)(i + 1) : (byte)(i - 2)));
1329             }),
1330             withToString("byte[cornerCaseValue(i)]", (int s) -> {
1331                 return fill(s * BUFFER_REPS,
1332                             i -> cornerCaseValue(i));
1333             })
1334     );
1335 
1336     static final List<List<IntFunction<byte[]>>> BYTE_TEST_GENERATOR_ARGS =
1337         BYTE_COMPARE_GENERATORS.stream().
1338                 map(fa -> List.of(fa)).
1339                 collect(Collectors.toList());
1340 
1341     @DataProvider
1342     public Object[][] byteTestOpProvider() {
1343         return BYTE_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1344                 toArray(Object[][]::new);
1345     }
1346 
1347     @DataProvider
1348     public Object[][] byteTestOpMaskProvider() {
1349         return BOOLEAN_MASK_GENERATORS.stream().
1350                 flatMap(fm -> BYTE_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1351                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1352                 })).
1353                 toArray(Object[][]::new);
1354     }
1355 
1356     static final List<List<IntFunction<byte[]>>> BYTE_COMPARE_GENERATOR_PAIRS =
1357         BYTE_COMPARE_GENERATORS.stream().
1358                 flatMap(fa -> BYTE_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1359                 collect(Collectors.toList());
1360 
1361     @DataProvider
1362     public Object[][] byteCompareOpProvider() {
1363         return BYTE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1364                 toArray(Object[][]::new);
1365     }
1366 
1367     @DataProvider
1368     public Object[][] byteCompareOpMaskProvider() {
1369         return BOOLEAN_MASK_GENERATORS.stream().
1370                 flatMap(fm -> BYTE_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1371                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1372                 })).
1373                 toArray(Object[][]::new);
1374     }
1375 
1376     interface ToByteF {
1377         byte apply(int i);
1378     }
1379 
1380     static byte[] fill(int s , ToByteF f) {
1381         return fill(new byte[s], f);
1382     }
1383 
1384     static byte[] fill(byte[] a, ToByteF f) {
1385         for (int i = 0; i < a.length; i++) {
1386             a[i] = f.apply(i);
1387         }
1388         return a;
1389     }
1390 
1391     static byte cornerCaseValue(int i) {
1392         switch(i % 5) {
1393             case 0:
1394                 return Byte.MAX_VALUE;
1395             case 1:
1396                 return Byte.MIN_VALUE;
1397             case 2:
1398                 return Byte.MIN_VALUE;
1399             case 3:
1400                 return Byte.MAX_VALUE;
1401             default:
1402                 return (byte)0;
1403         }
1404     }
1405 
1406     static final IntFunction<byte[]> fr = (vl) -> {
1407         int length = BUFFER_REPS * vl;
1408         return new byte[length];
1409     };
1410 
1411     static final IntFunction<boolean[]> fmr = (vl) -> {
1412         int length = BUFFER_REPS * vl;
1413         return new boolean[length];
1414     };
1415 
1416     static final IntFunction<long[]> lfr = (vl) -> {
1417         int length = BUFFER_REPS * vl;
1418         return new long[length];
1419     };
1420 
1421     static void replaceZero(byte[] a, byte v) {
1422         for (int i = 0; i < a.length; i++) {
1423             if (a[i] == 0) {
1424                 a[i] = v;
1425             }
1426         }
1427     }
1428 
1429     static void replaceZero(byte[] a, boolean[] mask, byte v) {
1430         for (int i = 0; i < a.length; i++) {
1431             if (mask[i % mask.length] && a[i] == 0) {
1432                 a[i] = v;
1433             }
1434         }
1435     }
1436 
1437     static byte ROL_scalar(byte a, byte b) {
1438         return (byte)(((((byte)a) & 0xFF) << (b & 7)) | ((((byte)a) & 0xFF) >>> (8 - (b & 7))));
1439     }
1440 
1441     static byte ROR_scalar(byte a, byte b) {
1442         return (byte)(((((byte)a) & 0xFF) >>> (b & 7)) | ((((byte)a) & 0xFF) << (8 - (b & 7))));
1443     }
1444 
1445     static byte TRAILING_ZEROS_COUNT_scalar(byte a) {
1446         return (byte) (a != 0 ? Integer.numberOfTrailingZeros(a) : 8);
1447     }
1448 
1449     static byte LEADING_ZEROS_COUNT_scalar(byte a) {
1450         return (byte) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 24 : 0);
1451     }
1452 
1453     static byte REVERSE_scalar(byte a) {
1454         byte b = (byte) ROL_scalar(a, (byte) 4);
1455         b = (byte) (((b & 0x55) << 1) | ((b & 0xAA) >>> 1));
1456         b = (byte) (((b & 0x33) << 2) | ((b & 0xCC) >>> 2));
1457         return b;
1458     }
1459 
1460     static boolean eq(byte a, byte b) {
1461         return a == b;
1462     }
1463 
1464     static boolean neq(byte a, byte b) {
1465         return a != b;
1466     }
1467 
1468     static boolean lt(byte a, byte b) {
1469         return a < b;
1470     }
1471 
1472     static boolean le(byte a, byte b) {
1473         return a <= b;
1474     }
1475 
1476     static boolean gt(byte a, byte b) {
1477         return a > b;
1478     }
1479 
1480     static boolean ge(byte a, byte b) {
1481         return a >= b;
1482     }
1483 
1484     static boolean ult(byte a, byte b) {
1485         return Byte.compareUnsigned(a, b) < 0;
1486     }
1487 
1488     static boolean ule(byte a, byte b) {
1489         return Byte.compareUnsigned(a, b) <= 0;
1490     }
1491 
1492     static boolean ugt(byte a, byte b) {
1493         return Byte.compareUnsigned(a, b) > 0;
1494     }
1495 
1496     static boolean uge(byte a, byte b) {
1497         return Byte.compareUnsigned(a, b) >= 0;
1498     }
1499 
1500     static byte firstNonZero(byte a, byte b) {
1501         return Byte.compare(a, (byte) 0) != 0 ? a : b;
1502     }
1503 
1504     @Test
1505     static void smokeTest1() {
1506         ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
1507         ByteVector three2 = (ByteVector) SPECIES.broadcast(-3);
1508         assert(three.eq(three2).allTrue());
1509         ByteVector three3 = three2.broadcast(1).broadcast(-3);
1510         assert(three.eq(three3).allTrue());
1511         int scale = 2;
1512         Class<?> ETYPE = byte.class;
1513         if (ETYPE == double.class || ETYPE == long.class)
1514             scale = 1000000;
1515         else if (ETYPE == byte.class && SPECIES.length() >= 64)
1516             scale = 1;
1517         ByteVector higher = three.addIndex(scale);
1518         VectorMask<Byte> m = three.compare(VectorOperators.LE, higher);
1519         assert(m.allTrue());
1520         m = higher.min((byte)-1).test(VectorOperators.IS_NEGATIVE);
1521         assert(m.allTrue());
1522         byte max = higher.reduceLanes(VectorOperators.MAX);
1523         assert(max == -3 + scale * (SPECIES.length()-1));
1524     }
1525 
1526     private static byte[]
1527     bothToArray(ByteVector a, ByteVector b) {
1528         byte[] r = new byte[a.length() + b.length()];
1529         a.intoArray(r, 0);
1530         b.intoArray(r, a.length());
1531         return r;
1532     }
1533 
1534     @Test
1535     static void smokeTest2() {
1536         // Do some zipping and shuffling.
1537         ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1538         ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1539         Assert.assertEquals(io, io2);
1540         ByteVector a = io.add((byte)1); //[1,2]
1541         ByteVector b = a.neg();  //[-1,-2]
1542         byte[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1543         VectorShuffle<Byte> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1544         VectorShuffle<Byte> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1545         ByteVector zab0 = a.rearrange(zip0,b); //[1,-1]
1546         ByteVector zab1 = a.rearrange(zip1,b); //[2,-2]
1547         byte[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1548         // manually zip
1549         byte[] manual = new byte[zabValues.length];
1550         for (int i = 0; i < manual.length; i += 2) {
1551             manual[i+0] = abValues[i/2];
1552             manual[i+1] = abValues[a.length() + i/2];
1553         }
1554         Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1555         VectorShuffle<Byte> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1556         VectorShuffle<Byte> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1557         ByteVector uab0 = zab0.rearrange(unz0,zab1);
1558         ByteVector uab1 = zab0.rearrange(unz1,zab1);
1559         byte[] abValues1 = bothToArray(uab0, uab1);
1560         Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1561     }
1562 
1563     static void iotaShuffle() {
1564         ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1565         ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1566         Assert.assertEquals(io, io2);
1567     }
1568 
1569     @Test
1570     // Test all shuffle related operations.
1571     static void shuffleTest() {
1572         // To test backend instructions, make sure that C2 is used.
1573         for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1574             iotaShuffle();
1575         }
1576     }
1577 
1578     @Test
1579     void viewAsIntegeralLanesTest() {
1580         Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1581         Assert.assertEquals(asIntegral.species(), SPECIES);
1582     }
1583 
1584     @Test(expectedExceptions = UnsupportedOperationException.class)
1585     void viewAsFloatingLanesTest() {
1586         SPECIES.zero().viewAsFloatingLanes();
1587     }
1588 
1589     @Test
1590     // Test div by 0.
1591     static void bitwiseDivByZeroSmokeTest() {
1592         try {
1593             ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1594             ByteVector b = (ByteVector) SPECIES.broadcast(0);
1595             a.div(b);
1596             Assert.fail();
1597         } catch (ArithmeticException e) {
1598         }
1599 
1600         try {
1601             ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1602             ByteVector b = (ByteVector) SPECIES.broadcast(0);
1603             VectorMask<Byte> m = a.lt((byte) 1);
1604             a.div(b, m);
1605             Assert.fail();
1606         } catch (ArithmeticException e) {
1607         }
1608     }
1609 
1610     static byte ADD(byte a, byte b) {
1611         return (byte)(a + b);
1612     }
1613 
1614     @Test(dataProvider = "byteBinaryOpProvider")
1615     static void ADDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1616         byte[] a = fa.apply(SPECIES.length());
1617         byte[] b = fb.apply(SPECIES.length());
1618         byte[] r = fr.apply(SPECIES.length());
1619 
1620         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1621             for (int i = 0; i < a.length; i += SPECIES.length()) {
1622                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1623                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1624                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1625             }
1626         }
1627 
1628         assertArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
1629     }
1630 
1631     static byte add(byte a, byte b) {
1632         return (byte)(a + b);
1633     }
1634 
1635     @Test(dataProvider = "byteBinaryOpProvider")
1636     static void addByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1637         byte[] a = fa.apply(SPECIES.length());
1638         byte[] b = fb.apply(SPECIES.length());
1639         byte[] r = fr.apply(SPECIES.length());
1640 
1641         for (int i = 0; i < a.length; i += SPECIES.length()) {
1642             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1643             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1644             av.add(bv).intoArray(r, i);
1645         }
1646 
1647         assertArraysEquals(r, a, b, ByteMaxVectorTests::add);
1648     }
1649 
1650     @Test(dataProvider = "byteBinaryOpMaskProvider")
1651     static void ADDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1652                                           IntFunction<boolean[]> fm) {
1653         byte[] a = fa.apply(SPECIES.length());
1654         byte[] b = fb.apply(SPECIES.length());
1655         byte[] r = fr.apply(SPECIES.length());
1656         boolean[] mask = fm.apply(SPECIES.length());
1657         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1658 
1659         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1660             for (int i = 0; i < a.length; i += SPECIES.length()) {
1661                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1662                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1663                 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1664             }
1665         }
1666 
1667         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
1668     }
1669 
1670     @Test(dataProvider = "byteBinaryOpMaskProvider")
1671     static void addByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1672                                           IntFunction<boolean[]> fm) {
1673         byte[] a = fa.apply(SPECIES.length());
1674         byte[] b = fb.apply(SPECIES.length());
1675         byte[] r = fr.apply(SPECIES.length());
1676         boolean[] mask = fm.apply(SPECIES.length());
1677         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1678 
1679         for (int i = 0; i < a.length; i += SPECIES.length()) {
1680             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1681             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1682             av.add(bv, vmask).intoArray(r, i);
1683         }
1684 
1685         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::add);
1686     }
1687 
1688     static byte SUB(byte a, byte b) {
1689         return (byte)(a - b);
1690     }
1691 
1692     @Test(dataProvider = "byteBinaryOpProvider")
1693     static void SUBByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1694         byte[] a = fa.apply(SPECIES.length());
1695         byte[] b = fb.apply(SPECIES.length());
1696         byte[] r = fr.apply(SPECIES.length());
1697 
1698         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1699             for (int i = 0; i < a.length; i += SPECIES.length()) {
1700                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1701                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1702                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1703             }
1704         }
1705 
1706         assertArraysEquals(r, a, b, ByteMaxVectorTests::SUB);
1707     }
1708 
1709     static byte sub(byte a, byte b) {
1710         return (byte)(a - b);
1711     }
1712 
1713     @Test(dataProvider = "byteBinaryOpProvider")
1714     static void subByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1715         byte[] a = fa.apply(SPECIES.length());
1716         byte[] b = fb.apply(SPECIES.length());
1717         byte[] r = fr.apply(SPECIES.length());
1718 
1719         for (int i = 0; i < a.length; i += SPECIES.length()) {
1720             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1721             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1722             av.sub(bv).intoArray(r, i);
1723         }
1724 
1725         assertArraysEquals(r, a, b, ByteMaxVectorTests::sub);
1726     }
1727 
1728     @Test(dataProvider = "byteBinaryOpMaskProvider")
1729     static void SUBByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1730                                           IntFunction<boolean[]> fm) {
1731         byte[] a = fa.apply(SPECIES.length());
1732         byte[] b = fb.apply(SPECIES.length());
1733         byte[] r = fr.apply(SPECIES.length());
1734         boolean[] mask = fm.apply(SPECIES.length());
1735         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1736 
1737         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1738             for (int i = 0; i < a.length; i += SPECIES.length()) {
1739                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1740                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1741                 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1742             }
1743         }
1744 
1745         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUB);
1746     }
1747 
1748     @Test(dataProvider = "byteBinaryOpMaskProvider")
1749     static void subByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1750                                           IntFunction<boolean[]> fm) {
1751         byte[] a = fa.apply(SPECIES.length());
1752         byte[] b = fb.apply(SPECIES.length());
1753         byte[] r = fr.apply(SPECIES.length());
1754         boolean[] mask = fm.apply(SPECIES.length());
1755         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1756 
1757         for (int i = 0; i < a.length; i += SPECIES.length()) {
1758             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1759             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1760             av.sub(bv, vmask).intoArray(r, i);
1761         }
1762 
1763         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub);
1764     }
1765 
1766     static byte MUL(byte a, byte b) {
1767         return (byte)(a * b);
1768     }
1769 
1770     @Test(dataProvider = "byteBinaryOpProvider")
1771     static void MULByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1772         byte[] a = fa.apply(SPECIES.length());
1773         byte[] b = fb.apply(SPECIES.length());
1774         byte[] r = fr.apply(SPECIES.length());
1775 
1776         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1777             for (int i = 0; i < a.length; i += SPECIES.length()) {
1778                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1779                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1780                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1781             }
1782         }
1783 
1784         assertArraysEquals(r, a, b, ByteMaxVectorTests::MUL);
1785     }
1786 
1787     static byte mul(byte a, byte b) {
1788         return (byte)(a * b);
1789     }
1790 
1791     @Test(dataProvider = "byteBinaryOpProvider")
1792     static void mulByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1793         byte[] a = fa.apply(SPECIES.length());
1794         byte[] b = fb.apply(SPECIES.length());
1795         byte[] r = fr.apply(SPECIES.length());
1796 
1797         for (int i = 0; i < a.length; i += SPECIES.length()) {
1798             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1799             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1800             av.mul(bv).intoArray(r, i);
1801         }
1802 
1803         assertArraysEquals(r, a, b, ByteMaxVectorTests::mul);
1804     }
1805 
1806     @Test(dataProvider = "byteBinaryOpMaskProvider")
1807     static void MULByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1808                                           IntFunction<boolean[]> fm) {
1809         byte[] a = fa.apply(SPECIES.length());
1810         byte[] b = fb.apply(SPECIES.length());
1811         byte[] r = fr.apply(SPECIES.length());
1812         boolean[] mask = fm.apply(SPECIES.length());
1813         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1814 
1815         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1816             for (int i = 0; i < a.length; i += SPECIES.length()) {
1817                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1818                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1819                 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1820             }
1821         }
1822 
1823         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::MUL);
1824     }
1825 
1826     @Test(dataProvider = "byteBinaryOpMaskProvider")
1827     static void mulByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1828                                           IntFunction<boolean[]> fm) {
1829         byte[] a = fa.apply(SPECIES.length());
1830         byte[] b = fb.apply(SPECIES.length());
1831         byte[] r = fr.apply(SPECIES.length());
1832         boolean[] mask = fm.apply(SPECIES.length());
1833         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1834 
1835         for (int i = 0; i < a.length; i += SPECIES.length()) {
1836             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1837             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1838             av.mul(bv, vmask).intoArray(r, i);
1839         }
1840 
1841         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
1842     }
1843 
1844     static byte DIV(byte a, byte b) {
1845         return (byte)(a / b);
1846     }
1847 
1848     @Test(dataProvider = "byteBinaryOpProvider")
1849     static void DIVByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1850         byte[] a = fa.apply(SPECIES.length());
1851         byte[] b = fb.apply(SPECIES.length());
1852         byte[] r = fr.apply(SPECIES.length());
1853 
1854         replaceZero(b, (byte) 1);
1855 
1856         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1857             for (int i = 0; i < a.length; i += SPECIES.length()) {
1858                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1859                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1860                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1861             }
1862         }
1863 
1864         assertArraysEquals(r, a, b, ByteMaxVectorTests::DIV);
1865     }
1866 
1867     static byte div(byte a, byte b) {
1868         return (byte)(a / b);
1869     }
1870 
1871     @Test(dataProvider = "byteBinaryOpProvider")
1872     static void divByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1873         byte[] a = fa.apply(SPECIES.length());
1874         byte[] b = fb.apply(SPECIES.length());
1875         byte[] r = fr.apply(SPECIES.length());
1876 
1877         replaceZero(b, (byte) 1);
1878 
1879         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1880             for (int i = 0; i < a.length; i += SPECIES.length()) {
1881                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1882                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1883                 av.div(bv).intoArray(r, i);
1884             }
1885         }
1886 
1887         assertArraysEquals(r, a, b, ByteMaxVectorTests::div);
1888     }
1889 
1890     @Test(dataProvider = "byteBinaryOpMaskProvider")
1891     static void DIVByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1892                                           IntFunction<boolean[]> fm) {
1893         byte[] a = fa.apply(SPECIES.length());
1894         byte[] b = fb.apply(SPECIES.length());
1895         byte[] r = fr.apply(SPECIES.length());
1896         boolean[] mask = fm.apply(SPECIES.length());
1897         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1898 
1899         replaceZero(b, mask, (byte) 1);
1900 
1901         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1902             for (int i = 0; i < a.length; i += SPECIES.length()) {
1903                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1904                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1905                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1906             }
1907         }
1908 
1909         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::DIV);
1910     }
1911 
1912     @Test(dataProvider = "byteBinaryOpMaskProvider")
1913     static void divByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1914                                           IntFunction<boolean[]> fm) {
1915         byte[] a = fa.apply(SPECIES.length());
1916         byte[] b = fb.apply(SPECIES.length());
1917         byte[] r = fr.apply(SPECIES.length());
1918         boolean[] mask = fm.apply(SPECIES.length());
1919         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1920 
1921         replaceZero(b, mask, (byte) 1);
1922 
1923         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1924             for (int i = 0; i < a.length; i += SPECIES.length()) {
1925                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1926                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1927                 av.div(bv, vmask).intoArray(r, i);
1928             }
1929         }
1930 
1931         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::div);
1932     }
1933 
1934     static byte FIRST_NONZERO(byte a, byte b) {
1935         return (byte)((a)!=0?a:b);
1936     }
1937 
1938     @Test(dataProvider = "byteBinaryOpProvider")
1939     static void FIRST_NONZEROByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1940         byte[] a = fa.apply(SPECIES.length());
1941         byte[] b = fb.apply(SPECIES.length());
1942         byte[] r = fr.apply(SPECIES.length());
1943 
1944         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1945             for (int i = 0; i < a.length; i += SPECIES.length()) {
1946                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1947                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1948                 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1949             }
1950         }
1951 
1952         assertArraysEquals(r, a, b, ByteMaxVectorTests::FIRST_NONZERO);
1953     }
1954 
1955     @Test(dataProvider = "byteBinaryOpMaskProvider")
1956     static void FIRST_NONZEROByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1957                                           IntFunction<boolean[]> fm) {
1958         byte[] a = fa.apply(SPECIES.length());
1959         byte[] b = fb.apply(SPECIES.length());
1960         byte[] r = fr.apply(SPECIES.length());
1961         boolean[] mask = fm.apply(SPECIES.length());
1962         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1963 
1964         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1965             for (int i = 0; i < a.length; i += SPECIES.length()) {
1966                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1967                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1968                 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1969             }
1970         }
1971 
1972         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::FIRST_NONZERO);
1973     }
1974 
1975     static byte AND(byte a, byte b) {
1976         return (byte)(a & b);
1977     }
1978 
1979     @Test(dataProvider = "byteBinaryOpProvider")
1980     static void ANDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1981         byte[] a = fa.apply(SPECIES.length());
1982         byte[] b = fb.apply(SPECIES.length());
1983         byte[] r = fr.apply(SPECIES.length());
1984 
1985         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1986             for (int i = 0; i < a.length; i += SPECIES.length()) {
1987                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1988                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1989                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1990             }
1991         }
1992 
1993         assertArraysEquals(r, a, b, ByteMaxVectorTests::AND);
1994     }
1995 
1996     static byte and(byte a, byte b) {
1997         return (byte)(a & b);
1998     }
1999 
2000     @Test(dataProvider = "byteBinaryOpProvider")
2001     static void andByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2002         byte[] a = fa.apply(SPECIES.length());
2003         byte[] b = fb.apply(SPECIES.length());
2004         byte[] r = fr.apply(SPECIES.length());
2005 
2006         for (int i = 0; i < a.length; i += SPECIES.length()) {
2007             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2008             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2009             av.and(bv).intoArray(r, i);
2010         }
2011 
2012         assertArraysEquals(r, a, b, ByteMaxVectorTests::and);
2013     }
2014 
2015     @Test(dataProvider = "byteBinaryOpMaskProvider")
2016     static void ANDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2017                                           IntFunction<boolean[]> fm) {
2018         byte[] a = fa.apply(SPECIES.length());
2019         byte[] b = fb.apply(SPECIES.length());
2020         byte[] r = fr.apply(SPECIES.length());
2021         boolean[] mask = fm.apply(SPECIES.length());
2022         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2023 
2024         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2025             for (int i = 0; i < a.length; i += SPECIES.length()) {
2026                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2027                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2028                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
2029             }
2030         }
2031 
2032         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
2033     }
2034 
2035     static byte AND_NOT(byte a, byte b) {
2036         return (byte)(a & ~b);
2037     }
2038 
2039     @Test(dataProvider = "byteBinaryOpProvider")
2040     static void AND_NOTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2041         byte[] a = fa.apply(SPECIES.length());
2042         byte[] b = fb.apply(SPECIES.length());
2043         byte[] r = fr.apply(SPECIES.length());
2044 
2045         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2046             for (int i = 0; i < a.length; i += SPECIES.length()) {
2047                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2048                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2049                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
2050             }
2051         }
2052 
2053         assertArraysEquals(r, a, b, ByteMaxVectorTests::AND_NOT);
2054     }
2055 
2056     @Test(dataProvider = "byteBinaryOpMaskProvider")
2057     static void AND_NOTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2058                                           IntFunction<boolean[]> fm) {
2059         byte[] a = fa.apply(SPECIES.length());
2060         byte[] b = fb.apply(SPECIES.length());
2061         byte[] r = fr.apply(SPECIES.length());
2062         boolean[] mask = fm.apply(SPECIES.length());
2063         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2064 
2065         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2066             for (int i = 0; i < a.length; i += SPECIES.length()) {
2067                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2068                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2069                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
2070             }
2071         }
2072 
2073         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND_NOT);
2074     }
2075 
2076     static byte OR(byte a, byte b) {
2077         return (byte)(a | b);
2078     }
2079 
2080     @Test(dataProvider = "byteBinaryOpProvider")
2081     static void ORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2082         byte[] a = fa.apply(SPECIES.length());
2083         byte[] b = fb.apply(SPECIES.length());
2084         byte[] r = fr.apply(SPECIES.length());
2085 
2086         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2087             for (int i = 0; i < a.length; i += SPECIES.length()) {
2088                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2089                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2090                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
2091             }
2092         }
2093 
2094         assertArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2095     }
2096 
2097     static byte or(byte a, byte b) {
2098         return (byte)(a | b);
2099     }
2100 
2101     @Test(dataProvider = "byteBinaryOpProvider")
2102     static void orByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2103         byte[] a = fa.apply(SPECIES.length());
2104         byte[] b = fb.apply(SPECIES.length());
2105         byte[] r = fr.apply(SPECIES.length());
2106 
2107         for (int i = 0; i < a.length; i += SPECIES.length()) {
2108             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2109             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2110             av.or(bv).intoArray(r, i);
2111         }
2112 
2113         assertArraysEquals(r, a, b, ByteMaxVectorTests::or);
2114     }
2115 
2116     @Test(dataProvider = "byteBinaryOpMaskProvider")
2117     static void ORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2118                                           IntFunction<boolean[]> fm) {
2119         byte[] a = fa.apply(SPECIES.length());
2120         byte[] b = fb.apply(SPECIES.length());
2121         byte[] r = fr.apply(SPECIES.length());
2122         boolean[] mask = fm.apply(SPECIES.length());
2123         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2124 
2125         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2126             for (int i = 0; i < a.length; i += SPECIES.length()) {
2127                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2128                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2129                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
2130             }
2131         }
2132 
2133         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2134     }
2135 
2136     static byte XOR(byte a, byte b) {
2137         return (byte)(a ^ b);
2138     }
2139 
2140     @Test(dataProvider = "byteBinaryOpProvider")
2141     static void XORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2142         byte[] a = fa.apply(SPECIES.length());
2143         byte[] b = fb.apply(SPECIES.length());
2144         byte[] r = fr.apply(SPECIES.length());
2145 
2146         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2147             for (int i = 0; i < a.length; i += SPECIES.length()) {
2148                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2149                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2150                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
2151             }
2152         }
2153 
2154         assertArraysEquals(r, a, b, ByteMaxVectorTests::XOR);
2155     }
2156 
2157     @Test(dataProvider = "byteBinaryOpMaskProvider")
2158     static void XORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2159                                           IntFunction<boolean[]> fm) {
2160         byte[] a = fa.apply(SPECIES.length());
2161         byte[] b = fb.apply(SPECIES.length());
2162         byte[] r = fr.apply(SPECIES.length());
2163         boolean[] mask = fm.apply(SPECIES.length());
2164         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2165 
2166         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2167             for (int i = 0; i < a.length; i += SPECIES.length()) {
2168                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2169                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2170                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
2171             }
2172         }
2173 
2174         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::XOR);
2175     }
2176 
2177     @Test(dataProvider = "byteBinaryOpProvider")
2178     static void addByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2179         byte[] a = fa.apply(SPECIES.length());
2180         byte[] b = fb.apply(SPECIES.length());
2181         byte[] r = fr.apply(SPECIES.length());
2182 
2183         for (int i = 0; i < a.length; i += SPECIES.length()) {
2184             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2185             av.add(b[i]).intoArray(r, i);
2186         }
2187 
2188         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::add);
2189     }
2190 
2191     @Test(dataProvider = "byteBinaryOpMaskProvider")
2192     static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2193                                           IntFunction<boolean[]> fm) {
2194         byte[] a = fa.apply(SPECIES.length());
2195         byte[] b = fb.apply(SPECIES.length());
2196         byte[] r = fr.apply(SPECIES.length());
2197         boolean[] mask = fm.apply(SPECIES.length());
2198         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2199 
2200         for (int i = 0; i < a.length; i += SPECIES.length()) {
2201             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2202             av.add(b[i], vmask).intoArray(r, i);
2203         }
2204 
2205         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::add);
2206     }
2207 
2208     @Test(dataProvider = "byteBinaryOpProvider")
2209     static void subByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2210         byte[] a = fa.apply(SPECIES.length());
2211         byte[] b = fb.apply(SPECIES.length());
2212         byte[] r = fr.apply(SPECIES.length());
2213 
2214         for (int i = 0; i < a.length; i += SPECIES.length()) {
2215             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2216             av.sub(b[i]).intoArray(r, i);
2217         }
2218 
2219         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::sub);
2220     }
2221 
2222     @Test(dataProvider = "byteBinaryOpMaskProvider")
2223     static void subByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2224                                           IntFunction<boolean[]> fm) {
2225         byte[] a = fa.apply(SPECIES.length());
2226         byte[] b = fb.apply(SPECIES.length());
2227         byte[] r = fr.apply(SPECIES.length());
2228         boolean[] mask = fm.apply(SPECIES.length());
2229         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2230 
2231         for (int i = 0; i < a.length; i += SPECIES.length()) {
2232             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2233             av.sub(b[i], vmask).intoArray(r, i);
2234         }
2235 
2236         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub);
2237     }
2238 
2239     @Test(dataProvider = "byteBinaryOpProvider")
2240     static void mulByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2241         byte[] a = fa.apply(SPECIES.length());
2242         byte[] b = fb.apply(SPECIES.length());
2243         byte[] r = fr.apply(SPECIES.length());
2244 
2245         for (int i = 0; i < a.length; i += SPECIES.length()) {
2246             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2247             av.mul(b[i]).intoArray(r, i);
2248         }
2249 
2250         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::mul);
2251     }
2252 
2253     @Test(dataProvider = "byteBinaryOpMaskProvider")
2254     static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2255                                           IntFunction<boolean[]> fm) {
2256         byte[] a = fa.apply(SPECIES.length());
2257         byte[] b = fb.apply(SPECIES.length());
2258         byte[] r = fr.apply(SPECIES.length());
2259         boolean[] mask = fm.apply(SPECIES.length());
2260         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2261 
2262         for (int i = 0; i < a.length; i += SPECIES.length()) {
2263             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2264             av.mul(b[i], vmask).intoArray(r, i);
2265         }
2266 
2267         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
2268     }
2269 
2270     @Test(dataProvider = "byteBinaryOpProvider")
2271     static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2272         byte[] a = fa.apply(SPECIES.length());
2273         byte[] b = fb.apply(SPECIES.length());
2274         byte[] r = fr.apply(SPECIES.length());
2275 
2276         replaceZero(b, (byte) 1);
2277 
2278         for (int i = 0; i < a.length; i += SPECIES.length()) {
2279             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2280             av.div(b[i]).intoArray(r, i);
2281         }
2282 
2283         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::div);
2284     }
2285 
2286     @Test(dataProvider = "byteBinaryOpMaskProvider")
2287     static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2288                                           IntFunction<boolean[]> fm) {
2289         byte[] a = fa.apply(SPECIES.length());
2290         byte[] b = fb.apply(SPECIES.length());
2291         byte[] r = fr.apply(SPECIES.length());
2292         boolean[] mask = fm.apply(SPECIES.length());
2293         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2294 
2295         replaceZero(b, (byte) 1);
2296 
2297         for (int i = 0; i < a.length; i += SPECIES.length()) {
2298             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2299             av.div(b[i], vmask).intoArray(r, i);
2300         }
2301 
2302         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::div);
2303     }
2304 
2305     @Test(dataProvider = "byteBinaryOpProvider")
2306     static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2307         byte[] a = fa.apply(SPECIES.length());
2308         byte[] b = fb.apply(SPECIES.length());
2309         byte[] r = fr.apply(SPECIES.length());
2310 
2311         for (int i = 0; i < a.length; i += SPECIES.length()) {
2312             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2313             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2314         }
2315 
2316         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2317     }
2318 
2319     @Test(dataProvider = "byteBinaryOpProvider")
2320     static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2321         byte[] a = fa.apply(SPECIES.length());
2322         byte[] b = fb.apply(SPECIES.length());
2323         byte[] r = fr.apply(SPECIES.length());
2324 
2325         for (int i = 0; i < a.length; i += SPECIES.length()) {
2326             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2327             av.or(b[i]).intoArray(r, i);
2328         }
2329 
2330         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::or);
2331     }
2332 
2333     @Test(dataProvider = "byteBinaryOpMaskProvider")
2334     static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2335                                           IntFunction<boolean[]> fm) {
2336         byte[] a = fa.apply(SPECIES.length());
2337         byte[] b = fb.apply(SPECIES.length());
2338         byte[] r = fr.apply(SPECIES.length());
2339         boolean[] mask = fm.apply(SPECIES.length());
2340         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2341 
2342         for (int i = 0; i < a.length; i += SPECIES.length()) {
2343             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2344             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2345         }
2346 
2347         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2348     }
2349 
2350     @Test(dataProvider = "byteBinaryOpProvider")
2351     static void ANDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2352         byte[] a = fa.apply(SPECIES.length());
2353         byte[] b = fb.apply(SPECIES.length());
2354         byte[] r = fr.apply(SPECIES.length());
2355 
2356         for (int i = 0; i < a.length; i += SPECIES.length()) {
2357             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2358             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2359         }
2360 
2361         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::AND);
2362     }
2363 
2364     @Test(dataProvider = "byteBinaryOpProvider")
2365     static void andByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2366         byte[] a = fa.apply(SPECIES.length());
2367         byte[] b = fb.apply(SPECIES.length());
2368         byte[] r = fr.apply(SPECIES.length());
2369 
2370         for (int i = 0; i < a.length; i += SPECIES.length()) {
2371             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2372             av.and(b[i]).intoArray(r, i);
2373         }
2374 
2375         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::and);
2376     }
2377 
2378     @Test(dataProvider = "byteBinaryOpMaskProvider")
2379     static void ANDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2380                                           IntFunction<boolean[]> fm) {
2381         byte[] a = fa.apply(SPECIES.length());
2382         byte[] b = fb.apply(SPECIES.length());
2383         byte[] r = fr.apply(SPECIES.length());
2384         boolean[] mask = fm.apply(SPECIES.length());
2385         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2386 
2387         for (int i = 0; i < a.length; i += SPECIES.length()) {
2388             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2389             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2390         }
2391 
2392         assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
2393     }
2394 
2395     @Test(dataProvider = "byteBinaryOpProvider")
2396     static void ORByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2397         byte[] a = fa.apply(SPECIES.length());
2398         byte[] b = fb.apply(SPECIES.length());
2399         byte[] r = fr.apply(SPECIES.length());
2400 
2401         for (int i = 0; i < a.length; i += SPECIES.length()) {
2402             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2403             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2404         }
2405 
2406         assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2407     }
2408 
2409     @Test(dataProvider = "byteBinaryOpMaskProvider")
2410     static void ORByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2411                                           IntFunction<boolean[]> fm) {
2412         byte[] a = fa.apply(SPECIES.length());
2413         byte[] b = fb.apply(SPECIES.length());
2414         byte[] r = fr.apply(SPECIES.length());
2415         boolean[] mask = fm.apply(SPECIES.length());
2416         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2417 
2418         for (int i = 0; i < a.length; i += SPECIES.length()) {
2419             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2420             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2421         }
2422 
2423         assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2424     }
2425 
2426     @Test(dataProvider = "byteBinaryOpProvider")
2427     static void ADDByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2428         byte[] a = fa.apply(SPECIES.length());
2429         byte[] b = fb.apply(SPECIES.length());
2430         byte[] r = fr.apply(SPECIES.length());
2431 
2432         for (int i = 0; i < a.length; i += SPECIES.length()) {
2433             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2434             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2435         }
2436 
2437         assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
2438     }
2439 
2440     @Test(dataProvider = "byteBinaryOpMaskProvider")
2441     static void ADDByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2442                                           IntFunction<boolean[]> fm) {
2443         byte[] a = fa.apply(SPECIES.length());
2444         byte[] b = fb.apply(SPECIES.length());
2445         byte[] r = fr.apply(SPECIES.length());
2446         boolean[] mask = fm.apply(SPECIES.length());
2447         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2448 
2449         for (int i = 0; i < a.length; i += SPECIES.length()) {
2450             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2451             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2452         }
2453 
2454         assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
2455     }
2456 
2457     static byte LSHL(byte a, byte b) {
2458         return (byte)((a << (b & 0x7)));
2459     }
2460 
2461     @Test(dataProvider = "byteBinaryOpProvider")
2462     static void LSHLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2463         byte[] a = fa.apply(SPECIES.length());
2464         byte[] b = fb.apply(SPECIES.length());
2465         byte[] r = fr.apply(SPECIES.length());
2466 
2467         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2468             for (int i = 0; i < a.length; i += SPECIES.length()) {
2469                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2470                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2471                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2472             }
2473         }
2474 
2475         assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHL);
2476     }
2477 
2478     @Test(dataProvider = "byteBinaryOpMaskProvider")
2479     static void LSHLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2480                                           IntFunction<boolean[]> fm) {
2481         byte[] a = fa.apply(SPECIES.length());
2482         byte[] b = fb.apply(SPECIES.length());
2483         byte[] r = fr.apply(SPECIES.length());
2484         boolean[] mask = fm.apply(SPECIES.length());
2485         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2486 
2487         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2488             for (int i = 0; i < a.length; i += SPECIES.length()) {
2489                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2490                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2491                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2492             }
2493         }
2494 
2495         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL);
2496     }
2497 
2498     static byte ASHR(byte a, byte b) {
2499         return (byte)((a >> (b & 0x7)));
2500     }
2501 
2502     @Test(dataProvider = "byteBinaryOpProvider")
2503     static void ASHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2504         byte[] a = fa.apply(SPECIES.length());
2505         byte[] b = fb.apply(SPECIES.length());
2506         byte[] r = fr.apply(SPECIES.length());
2507 
2508         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2509             for (int i = 0; i < a.length; i += SPECIES.length()) {
2510                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2511                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2512                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2513             }
2514         }
2515 
2516         assertArraysEquals(r, a, b, ByteMaxVectorTests::ASHR);
2517     }
2518 
2519     @Test(dataProvider = "byteBinaryOpMaskProvider")
2520     static void ASHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2521                                           IntFunction<boolean[]> fm) {
2522         byte[] a = fa.apply(SPECIES.length());
2523         byte[] b = fb.apply(SPECIES.length());
2524         byte[] r = fr.apply(SPECIES.length());
2525         boolean[] mask = fm.apply(SPECIES.length());
2526         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2527 
2528         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2529             for (int i = 0; i < a.length; i += SPECIES.length()) {
2530                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2531                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2532                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2533             }
2534         }
2535 
2536         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR);
2537     }
2538 
2539     static byte LSHR(byte a, byte b) {
2540         return (byte)(((a & 0xFF) >>> (b & 0x7)));
2541     }
2542 
2543     @Test(dataProvider = "byteBinaryOpProvider")
2544     static void LSHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2545         byte[] a = fa.apply(SPECIES.length());
2546         byte[] b = fb.apply(SPECIES.length());
2547         byte[] r = fr.apply(SPECIES.length());
2548 
2549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2550             for (int i = 0; i < a.length; i += SPECIES.length()) {
2551                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2552                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2553                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2554             }
2555         }
2556 
2557         assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHR);
2558     }
2559 
2560     @Test(dataProvider = "byteBinaryOpMaskProvider")
2561     static void LSHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2562                                           IntFunction<boolean[]> fm) {
2563         byte[] a = fa.apply(SPECIES.length());
2564         byte[] b = fb.apply(SPECIES.length());
2565         byte[] r = fr.apply(SPECIES.length());
2566         boolean[] mask = fm.apply(SPECIES.length());
2567         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2568 
2569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2570             for (int i = 0; i < a.length; i += SPECIES.length()) {
2571                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2572                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2573                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2574             }
2575         }
2576 
2577         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR);
2578     }
2579 
2580     static byte LSHL_unary(byte a, byte b) {
2581         return (byte)((a << (b & 7)));
2582     }
2583 
2584     @Test(dataProvider = "byteBinaryOpProvider")
2585     static void LSHLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2586         byte[] a = fa.apply(SPECIES.length());
2587         byte[] b = fb.apply(SPECIES.length());
2588         byte[] r = fr.apply(SPECIES.length());
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                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2594             }
2595         }
2596 
2597         assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHL_unary);
2598     }
2599 
2600     @Test(dataProvider = "byteBinaryOpMaskProvider")
2601     static void LSHLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2602                                           IntFunction<boolean[]> fm) {
2603         byte[] a = fa.apply(SPECIES.length());
2604         byte[] b = fb.apply(SPECIES.length());
2605         byte[] r = fr.apply(SPECIES.length());
2606         boolean[] mask = fm.apply(SPECIES.length());
2607         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2608 
2609         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2610             for (int i = 0; i < a.length; i += SPECIES.length()) {
2611                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2612                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2613             }
2614         }
2615 
2616         assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL_unary);
2617     }
2618 
2619     static byte LSHR_unary(byte a, byte b) {
2620         return (byte)(((a & 0xFF) >>> (b & 7)));
2621     }
2622 
2623     @Test(dataProvider = "byteBinaryOpProvider")
2624     static void LSHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2625         byte[] a = fa.apply(SPECIES.length());
2626         byte[] b = fb.apply(SPECIES.length());
2627         byte[] r = fr.apply(SPECIES.length());
2628 
2629         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2630             for (int i = 0; i < a.length; i += SPECIES.length()) {
2631                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2632                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2633             }
2634         }
2635 
2636         assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHR_unary);
2637     }
2638 
2639     @Test(dataProvider = "byteBinaryOpMaskProvider")
2640     static void LSHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2641                                           IntFunction<boolean[]> fm) {
2642         byte[] a = fa.apply(SPECIES.length());
2643         byte[] b = fb.apply(SPECIES.length());
2644         byte[] r = fr.apply(SPECIES.length());
2645         boolean[] mask = fm.apply(SPECIES.length());
2646         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2647 
2648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2649             for (int i = 0; i < a.length; i += SPECIES.length()) {
2650                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2651                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2652             }
2653         }
2654 
2655         assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR_unary);
2656     }
2657 
2658     static byte ASHR_unary(byte a, byte b) {
2659         return (byte)((a >> (b & 7)));
2660     }
2661 
2662     @Test(dataProvider = "byteBinaryOpProvider")
2663     static void ASHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2664         byte[] a = fa.apply(SPECIES.length());
2665         byte[] b = fb.apply(SPECIES.length());
2666         byte[] r = fr.apply(SPECIES.length());
2667 
2668         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2669             for (int i = 0; i < a.length; i += SPECIES.length()) {
2670                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2671                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2672             }
2673         }
2674 
2675         assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ASHR_unary);
2676     }
2677 
2678     @Test(dataProvider = "byteBinaryOpMaskProvider")
2679     static void ASHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2680                                           IntFunction<boolean[]> fm) {
2681         byte[] a = fa.apply(SPECIES.length());
2682         byte[] b = fb.apply(SPECIES.length());
2683         byte[] r = fr.apply(SPECIES.length());
2684         boolean[] mask = fm.apply(SPECIES.length());
2685         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2686 
2687         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2688             for (int i = 0; i < a.length; i += SPECIES.length()) {
2689                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2690                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2691             }
2692         }
2693 
2694         assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR_unary);
2695     }
2696 
2697     static byte ROR(byte a, byte b) {
2698         return (byte)(ROR_scalar(a,b));
2699     }
2700 
2701     @Test(dataProvider = "byteBinaryOpProvider")
2702     static void RORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2703         byte[] a = fa.apply(SPECIES.length());
2704         byte[] b = fb.apply(SPECIES.length());
2705         byte[] r = fr.apply(SPECIES.length());
2706 
2707         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2708             for (int i = 0; i < a.length; i += SPECIES.length()) {
2709                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2710                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2711                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2712             }
2713         }
2714 
2715         assertArraysEquals(r, a, b, ByteMaxVectorTests::ROR);
2716     }
2717 
2718     @Test(dataProvider = "byteBinaryOpMaskProvider")
2719     static void RORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2720                                           IntFunction<boolean[]> fm) {
2721         byte[] a = fa.apply(SPECIES.length());
2722         byte[] b = fb.apply(SPECIES.length());
2723         byte[] r = fr.apply(SPECIES.length());
2724         boolean[] mask = fm.apply(SPECIES.length());
2725         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2726 
2727         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2728             for (int i = 0; i < a.length; i += SPECIES.length()) {
2729                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2730                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2731                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2732             }
2733         }
2734 
2735         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR);
2736     }
2737 
2738     static byte ROL(byte a, byte b) {
2739         return (byte)(ROL_scalar(a,b));
2740     }
2741 
2742     @Test(dataProvider = "byteBinaryOpProvider")
2743     static void ROLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2744         byte[] a = fa.apply(SPECIES.length());
2745         byte[] b = fb.apply(SPECIES.length());
2746         byte[] r = fr.apply(SPECIES.length());
2747 
2748         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2749             for (int i = 0; i < a.length; i += SPECIES.length()) {
2750                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2751                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2752                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2753             }
2754         }
2755 
2756         assertArraysEquals(r, a, b, ByteMaxVectorTests::ROL);
2757     }
2758 
2759     @Test(dataProvider = "byteBinaryOpMaskProvider")
2760     static void ROLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2761                                           IntFunction<boolean[]> fm) {
2762         byte[] a = fa.apply(SPECIES.length());
2763         byte[] b = fb.apply(SPECIES.length());
2764         byte[] r = fr.apply(SPECIES.length());
2765         boolean[] mask = fm.apply(SPECIES.length());
2766         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2767 
2768         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2769             for (int i = 0; i < a.length; i += SPECIES.length()) {
2770                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2771                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2772                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2773             }
2774         }
2775 
2776         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL);
2777     }
2778 
2779     static byte ROR_unary(byte a, byte b) {
2780         return (byte)(ROR_scalar(a, b));
2781     }
2782 
2783     @Test(dataProvider = "byteBinaryOpProvider")
2784     static void RORByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2785         byte[] a = fa.apply(SPECIES.length());
2786         byte[] b = fb.apply(SPECIES.length());
2787         byte[] r = fr.apply(SPECIES.length());
2788 
2789         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2790             for (int i = 0; i < a.length; i += SPECIES.length()) {
2791                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2792                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2793             }
2794         }
2795 
2796         assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROR_unary);
2797     }
2798 
2799     @Test(dataProvider = "byteBinaryOpMaskProvider")
2800     static void RORByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2801                                           IntFunction<boolean[]> fm) {
2802         byte[] a = fa.apply(SPECIES.length());
2803         byte[] b = fb.apply(SPECIES.length());
2804         byte[] r = fr.apply(SPECIES.length());
2805         boolean[] mask = fm.apply(SPECIES.length());
2806         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2807 
2808         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2809             for (int i = 0; i < a.length; i += SPECIES.length()) {
2810                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2811                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2812             }
2813         }
2814 
2815         assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR_unary);
2816     }
2817 
2818     static byte ROL_unary(byte a, byte b) {
2819         return (byte)(ROL_scalar(a, b));
2820     }
2821 
2822     @Test(dataProvider = "byteBinaryOpProvider")
2823     static void ROLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2824         byte[] a = fa.apply(SPECIES.length());
2825         byte[] b = fb.apply(SPECIES.length());
2826         byte[] r = fr.apply(SPECIES.length());
2827 
2828         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2829             for (int i = 0; i < a.length; i += SPECIES.length()) {
2830                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2831                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2832             }
2833         }
2834 
2835         assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROL_unary);
2836     }
2837 
2838     @Test(dataProvider = "byteBinaryOpMaskProvider")
2839     static void ROLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2840                                           IntFunction<boolean[]> fm) {
2841         byte[] a = fa.apply(SPECIES.length());
2842         byte[] b = fb.apply(SPECIES.length());
2843         byte[] r = fr.apply(SPECIES.length());
2844         boolean[] mask = fm.apply(SPECIES.length());
2845         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2846 
2847         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2848             for (int i = 0; i < a.length; i += SPECIES.length()) {
2849                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2850                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2851             }
2852         }
2853 
2854         assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL_unary);
2855     }
2856     static byte LSHR_binary_const(byte a) {
2857         return (byte)(((a & 0xFF) >>> CONST_SHIFT));
2858     }
2859 
2860     @Test(dataProvider = "byteUnaryOpProvider")
2861     static void LSHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2862         byte[] a = fa.apply(SPECIES.length());
2863         byte[] r = fr.apply(SPECIES.length());
2864 
2865         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2866             for (int i = 0; i < a.length; i += SPECIES.length()) {
2867                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2868                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2869             }
2870         }
2871 
2872         assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHR_binary_const);
2873     }
2874 
2875     @Test(dataProvider = "byteUnaryOpMaskProvider")
2876     static void LSHRByteMaxVectorTestsScalarShiftMaskedConst(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.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2887             }
2888         }
2889 
2890         assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHR_binary_const);
2891     }
2892 
2893     static byte LSHL_binary_const(byte a) {
2894         return (byte)((a << CONST_SHIFT));
2895     }
2896 
2897     @Test(dataProvider = "byteUnaryOpProvider")
2898     static void LSHLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2899         byte[] a = fa.apply(SPECIES.length());
2900         byte[] r = fr.apply(SPECIES.length());
2901 
2902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2903             for (int i = 0; i < a.length; i += SPECIES.length()) {
2904                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2905                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2906             }
2907         }
2908 
2909         assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHL_binary_const);
2910     }
2911 
2912     @Test(dataProvider = "byteUnaryOpMaskProvider")
2913     static void LSHLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2914                                           IntFunction<boolean[]> fm) {
2915         byte[] a = fa.apply(SPECIES.length());
2916         byte[] r = fr.apply(SPECIES.length());
2917         boolean[] mask = fm.apply(SPECIES.length());
2918         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2919 
2920         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2921             for (int i = 0; i < a.length; i += SPECIES.length()) {
2922                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2923                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2924             }
2925         }
2926 
2927         assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHL_binary_const);
2928     }
2929 
2930     static byte ASHR_binary_const(byte a) {
2931         return (byte)((a >> CONST_SHIFT));
2932     }
2933 
2934     @Test(dataProvider = "byteUnaryOpProvider")
2935     static void ASHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2936         byte[] a = fa.apply(SPECIES.length());
2937         byte[] r = fr.apply(SPECIES.length());
2938 
2939         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2940             for (int i = 0; i < a.length; i += SPECIES.length()) {
2941                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2942                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2943             }
2944         }
2945 
2946         assertShiftConstEquals(r, a, ByteMaxVectorTests::ASHR_binary_const);
2947     }
2948 
2949     @Test(dataProvider = "byteUnaryOpMaskProvider")
2950     static void ASHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2951                                           IntFunction<boolean[]> fm) {
2952         byte[] a = fa.apply(SPECIES.length());
2953         byte[] r = fr.apply(SPECIES.length());
2954         boolean[] mask = fm.apply(SPECIES.length());
2955         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2956 
2957         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2958             for (int i = 0; i < a.length; i += SPECIES.length()) {
2959                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2960                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2961             }
2962         }
2963 
2964         assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ASHR_binary_const);
2965     }
2966 
2967     static byte ROR_binary_const(byte a) {
2968         return (byte)(ROR_scalar(a, CONST_SHIFT));
2969     }
2970 
2971     @Test(dataProvider = "byteUnaryOpProvider")
2972     static void RORByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2973         byte[] a = fa.apply(SPECIES.length());
2974         byte[] r = fr.apply(SPECIES.length());
2975 
2976         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2977             for (int i = 0; i < a.length; i += SPECIES.length()) {
2978                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2979                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2980             }
2981         }
2982 
2983         assertShiftConstEquals(r, a, ByteMaxVectorTests::ROR_binary_const);
2984     }
2985 
2986     @Test(dataProvider = "byteUnaryOpMaskProvider")
2987     static void RORByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2988                                           IntFunction<boolean[]> fm) {
2989         byte[] a = fa.apply(SPECIES.length());
2990         byte[] r = fr.apply(SPECIES.length());
2991         boolean[] mask = fm.apply(SPECIES.length());
2992         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2993 
2994         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2995             for (int i = 0; i < a.length; i += SPECIES.length()) {
2996                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2997                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2998             }
2999         }
3000 
3001         assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROR_binary_const);
3002     }
3003 
3004     static byte ROL_binary_const(byte a) {
3005         return (byte)(ROL_scalar(a, CONST_SHIFT));
3006     }
3007 
3008     @Test(dataProvider = "byteUnaryOpProvider")
3009     static void ROLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
3010         byte[] a = fa.apply(SPECIES.length());
3011         byte[] r = fr.apply(SPECIES.length());
3012 
3013         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3014             for (int i = 0; i < a.length; i += SPECIES.length()) {
3015                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3016                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
3017             }
3018         }
3019 
3020         assertShiftConstEquals(r, a, ByteMaxVectorTests::ROL_binary_const);
3021     }
3022 
3023     @Test(dataProvider = "byteUnaryOpMaskProvider")
3024     static void ROLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
3025                                           IntFunction<boolean[]> fm) {
3026         byte[] a = fa.apply(SPECIES.length());
3027         byte[] r = fr.apply(SPECIES.length());
3028         boolean[] mask = fm.apply(SPECIES.length());
3029         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3030 
3031         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3032             for (int i = 0; i < a.length; i += SPECIES.length()) {
3033                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3034                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
3035             }
3036         }
3037 
3038         assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROL_binary_const);
3039     }
3040 
3041 
3042     @Test(dataProvider = "byteUnaryOpProvider")
3043     static void MINByteMaxVectorTestsWithMemOp(IntFunction<byte[]> fa) {
3044         byte[] a = fa.apply(SPECIES.length());
3045         byte[] r = fr.apply(SPECIES.length());
3046 
3047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3048             for (int i = 0; i < a.length; i += SPECIES.length()) {
3049                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3050                 av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i);
3051             }
3052         }
3053 
3054         assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MIN);
3055     }
3056 
3057     @Test(dataProvider = "byteUnaryOpProvider")
3058     static void minByteMaxVectorTestsWithMemOp(IntFunction<byte[]> fa) {
3059         byte[] a = fa.apply(SPECIES.length());
3060         byte[] r = fr.apply(SPECIES.length());
3061 
3062         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3063             for (int i = 0; i < a.length; i += SPECIES.length()) {
3064                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3065                 av.min(bcast_vec).intoArray(r, i);
3066             }
3067         }
3068 
3069         assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::min);
3070     }
3071 
3072     @Test(dataProvider = "byteUnaryOpMaskProvider")
3073     static void MINByteMaxVectorTestsMaskedWithMemOp(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3074         byte[] a = fa.apply(SPECIES.length());
3075         byte[] r = fr.apply(SPECIES.length());
3076         boolean[] mask = fm.apply(SPECIES.length());
3077         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3078 
3079         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3080             for (int i = 0; i < a.length; i += SPECIES.length()) {
3081                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3082                 av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i);
3083             }
3084         }
3085 
3086         assertArraysEquals(r, a, (byte)10, mask, ByteMaxVectorTests::MIN);
3087     }
3088 
3089     @Test(dataProvider = "byteUnaryOpProvider")
3090     static void MAXByteMaxVectorTestsWithMemOp(IntFunction<byte[]> fa) {
3091         byte[] a = fa.apply(SPECIES.length());
3092         byte[] r = fr.apply(SPECIES.length());
3093 
3094         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3095             for (int i = 0; i < a.length; i += SPECIES.length()) {
3096                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3097                 av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i);
3098             }
3099         }
3100 
3101         assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MAX);
3102     }
3103 
3104     @Test(dataProvider = "byteUnaryOpProvider")
3105     static void maxByteMaxVectorTestsWithMemOp(IntFunction<byte[]> fa) {
3106         byte[] a = fa.apply(SPECIES.length());
3107         byte[] r = fr.apply(SPECIES.length());
3108 
3109         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3110             for (int i = 0; i < a.length; i += SPECIES.length()) {
3111                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3112                 av.max(bcast_vec).intoArray(r, i);
3113             }
3114         }
3115 
3116         assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::max);
3117     }
3118 
3119     @Test(dataProvider = "byteUnaryOpMaskProvider")
3120     static void MAXByteMaxVectorTestsMaskedWithMemOp(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3121         byte[] a = fa.apply(SPECIES.length());
3122         byte[] r = fr.apply(SPECIES.length());
3123         boolean[] mask = fm.apply(SPECIES.length());
3124         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3125 
3126         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3127             for (int i = 0; i < a.length; i += SPECIES.length()) {
3128                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3129                 av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i);
3130             }
3131         }
3132 
3133         assertArraysEquals(r, a, (byte)10, mask, ByteMaxVectorTests::MAX);
3134     }
3135 
3136     static byte MIN(byte a, byte b) {
3137         return (byte)(Math.min(a, b));
3138     }
3139 
3140     @Test(dataProvider = "byteBinaryOpProvider")
3141     static void MINByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3142         byte[] a = fa.apply(SPECIES.length());
3143         byte[] b = fb.apply(SPECIES.length());
3144         byte[] r = fr.apply(SPECIES.length());
3145 
3146         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3147             for (int i = 0; i < a.length; i += SPECIES.length()) {
3148                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3149                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3150                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
3151             }
3152         }
3153 
3154         assertArraysEquals(r, a, b, ByteMaxVectorTests::MIN);
3155     }
3156 
3157     static byte min(byte a, byte b) {
3158         return (byte)(Math.min(a, b));
3159     }
3160 
3161     @Test(dataProvider = "byteBinaryOpProvider")
3162     static void minByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3163         byte[] a = fa.apply(SPECIES.length());
3164         byte[] b = fb.apply(SPECIES.length());
3165         byte[] r = fr.apply(SPECIES.length());
3166 
3167         for (int i = 0; i < a.length; i += SPECIES.length()) {
3168             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3169             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3170             av.min(bv).intoArray(r, i);
3171         }
3172 
3173         assertArraysEquals(r, a, b, ByteMaxVectorTests::min);
3174     }
3175 
3176     static byte MAX(byte a, byte b) {
3177         return (byte)(Math.max(a, b));
3178     }
3179 
3180     @Test(dataProvider = "byteBinaryOpProvider")
3181     static void MAXByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3182         byte[] a = fa.apply(SPECIES.length());
3183         byte[] b = fb.apply(SPECIES.length());
3184         byte[] r = fr.apply(SPECIES.length());
3185 
3186         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3187             for (int i = 0; i < a.length; i += SPECIES.length()) {
3188                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3189                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3190                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
3191             }
3192         }
3193 
3194         assertArraysEquals(r, a, b, ByteMaxVectorTests::MAX);
3195     }
3196 
3197     static byte max(byte a, byte b) {
3198         return (byte)(Math.max(a, b));
3199     }
3200 
3201     @Test(dataProvider = "byteBinaryOpProvider")
3202     static void maxByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3203         byte[] a = fa.apply(SPECIES.length());
3204         byte[] b = fb.apply(SPECIES.length());
3205         byte[] r = fr.apply(SPECIES.length());
3206 
3207         for (int i = 0; i < a.length; i += SPECIES.length()) {
3208             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3209             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3210             av.max(bv).intoArray(r, i);
3211         }
3212 
3213         assertArraysEquals(r, a, b, ByteMaxVectorTests::max);
3214     }
3215 
3216     static byte UMIN(byte a, byte b) {
3217         return (byte)(VectorMath.minUnsigned(a, b));
3218     }
3219 
3220     @Test(dataProvider = "byteBinaryOpProvider")
3221     static void UMINByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3222         byte[] a = fa.apply(SPECIES.length());
3223         byte[] b = fb.apply(SPECIES.length());
3224         byte[] r = fr.apply(SPECIES.length());
3225 
3226         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3227             for (int i = 0; i < a.length; i += SPECIES.length()) {
3228                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3229                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3230                 av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i);
3231             }
3232         }
3233 
3234         assertArraysEquals(r, a, b, ByteMaxVectorTests::UMIN);
3235     }
3236 
3237     @Test(dataProvider = "byteBinaryOpMaskProvider")
3238     static void UMINByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3239                                           IntFunction<boolean[]> fm) {
3240         byte[] a = fa.apply(SPECIES.length());
3241         byte[] b = fb.apply(SPECIES.length());
3242         byte[] r = fr.apply(SPECIES.length());
3243         boolean[] mask = fm.apply(SPECIES.length());
3244         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3245 
3246         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3247             for (int i = 0; i < a.length; i += SPECIES.length()) {
3248                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3249                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3250                 av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i);
3251             }
3252         }
3253 
3254         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMIN);
3255     }
3256 
3257     static byte UMAX(byte a, byte b) {
3258         return (byte)(VectorMath.maxUnsigned(a, b));
3259     }
3260 
3261     @Test(dataProvider = "byteBinaryOpProvider")
3262     static void UMAXByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3263         byte[] a = fa.apply(SPECIES.length());
3264         byte[] b = fb.apply(SPECIES.length());
3265         byte[] r = fr.apply(SPECIES.length());
3266 
3267         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3268             for (int i = 0; i < a.length; i += SPECIES.length()) {
3269                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3270                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3271                 av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i);
3272             }
3273         }
3274 
3275         assertArraysEquals(r, a, b, ByteMaxVectorTests::UMAX);
3276     }
3277 
3278     @Test(dataProvider = "byteBinaryOpMaskProvider")
3279     static void UMAXByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3280                                           IntFunction<boolean[]> fm) {
3281         byte[] a = fa.apply(SPECIES.length());
3282         byte[] b = fb.apply(SPECIES.length());
3283         byte[] r = fr.apply(SPECIES.length());
3284         boolean[] mask = fm.apply(SPECIES.length());
3285         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3286 
3287         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3288             for (int i = 0; i < a.length; i += SPECIES.length()) {
3289                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3290                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3291                 av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i);
3292             }
3293         }
3294 
3295         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMAX);
3296     }
3297 
3298     static byte SADD(byte a, byte b) {
3299         return (byte)(VectorMath.addSaturating(a, b));
3300     }
3301 
3302     @Test(dataProvider = "byteSaturatingBinaryOpProvider")
3303     static void SADDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3304         byte[] a = fa.apply(SPECIES.length());
3305         byte[] b = fb.apply(SPECIES.length());
3306         byte[] r = fr.apply(SPECIES.length());
3307 
3308         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3309             for (int i = 0; i < a.length; i += SPECIES.length()) {
3310                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3311                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3312                 av.lanewise(VectorOperators.SADD, bv).intoArray(r, i);
3313             }
3314         }
3315 
3316         assertArraysEquals(r, a, b, ByteMaxVectorTests::SADD);
3317     }
3318 
3319     @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider")
3320     static void SADDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3321                                           IntFunction<boolean[]> fm) {
3322         byte[] a = fa.apply(SPECIES.length());
3323         byte[] b = fb.apply(SPECIES.length());
3324         byte[] r = fr.apply(SPECIES.length());
3325         boolean[] mask = fm.apply(SPECIES.length());
3326         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 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                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3332                 av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i);
3333             }
3334         }
3335 
3336         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SADD);
3337     }
3338 
3339     static byte SSUB(byte a, byte b) {
3340         return (byte)(VectorMath.subSaturating(a, b));
3341     }
3342 
3343     @Test(dataProvider = "byteSaturatingBinaryOpProvider")
3344     static void SSUBByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3345         byte[] a = fa.apply(SPECIES.length());
3346         byte[] b = fb.apply(SPECIES.length());
3347         byte[] r = fr.apply(SPECIES.length());
3348 
3349         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3350             for (int i = 0; i < a.length; i += SPECIES.length()) {
3351                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3352                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3353                 av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i);
3354             }
3355         }
3356 
3357         assertArraysEquals(r, a, b, ByteMaxVectorTests::SSUB);
3358     }
3359 
3360     @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider")
3361     static void SSUBByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3362                                           IntFunction<boolean[]> fm) {
3363         byte[] a = fa.apply(SPECIES.length());
3364         byte[] b = fb.apply(SPECIES.length());
3365         byte[] r = fr.apply(SPECIES.length());
3366         boolean[] mask = fm.apply(SPECIES.length());
3367         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3368 
3369         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3370             for (int i = 0; i < a.length; i += SPECIES.length()) {
3371                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3372                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3373                 av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i);
3374             }
3375         }
3376 
3377         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SSUB);
3378     }
3379 
3380     static byte SUADD(byte a, byte b) {
3381         return (byte)(VectorMath.addSaturatingUnsigned(a, b));
3382     }
3383 
3384     @Test(dataProvider = "byteSaturatingBinaryOpProvider")
3385     static void SUADDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3386         byte[] a = fa.apply(SPECIES.length());
3387         byte[] b = fb.apply(SPECIES.length());
3388         byte[] r = fr.apply(SPECIES.length());
3389 
3390         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3391             for (int i = 0; i < a.length; i += SPECIES.length()) {
3392                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3393                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3394                 av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i);
3395             }
3396         }
3397 
3398         assertArraysEquals(r, a, b, ByteMaxVectorTests::SUADD);
3399     }
3400 
3401     @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider")
3402     static void SUADDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3403                                           IntFunction<boolean[]> fm) {
3404         byte[] a = fa.apply(SPECIES.length());
3405         byte[] b = fb.apply(SPECIES.length());
3406         byte[] r = fr.apply(SPECIES.length());
3407         boolean[] mask = fm.apply(SPECIES.length());
3408         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3409 
3410         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3411             for (int i = 0; i < a.length; i += SPECIES.length()) {
3412                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3413                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3414                 av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i);
3415             }
3416         }
3417 
3418         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUADD);
3419     }
3420 
3421     static byte SUSUB(byte a, byte b) {
3422         return (byte)(VectorMath.subSaturatingUnsigned(a, b));
3423     }
3424 
3425     @Test(dataProvider = "byteSaturatingBinaryOpProvider")
3426     static void SUSUBByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3427         byte[] a = fa.apply(SPECIES.length());
3428         byte[] b = fb.apply(SPECIES.length());
3429         byte[] r = fr.apply(SPECIES.length());
3430 
3431         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3432             for (int i = 0; i < a.length; i += SPECIES.length()) {
3433                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3434                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3435                 av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i);
3436             }
3437         }
3438 
3439         assertArraysEquals(r, a, b, ByteMaxVectorTests::SUSUB);
3440     }
3441 
3442     @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider")
3443     static void SUSUBByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3444                                           IntFunction<boolean[]> fm) {
3445         byte[] a = fa.apply(SPECIES.length());
3446         byte[] b = fb.apply(SPECIES.length());
3447         byte[] r = fr.apply(SPECIES.length());
3448         boolean[] mask = fm.apply(SPECIES.length());
3449         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3450 
3451         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3452             for (int i = 0; i < a.length; i += SPECIES.length()) {
3453                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3454                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3455                 av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i);
3456             }
3457         }
3458 
3459         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUSUB);
3460     }
3461 
3462     @Test(dataProvider = "byteBinaryOpProvider")
3463     static void MINByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3464         byte[] a = fa.apply(SPECIES.length());
3465         byte[] b = fb.apply(SPECIES.length());
3466         byte[] r = fr.apply(SPECIES.length());
3467 
3468         for (int i = 0; i < a.length; i += SPECIES.length()) {
3469             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3470             av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
3471         }
3472 
3473         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MIN);
3474     }
3475 
3476     @Test(dataProvider = "byteBinaryOpProvider")
3477     static void minByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3478         byte[] a = fa.apply(SPECIES.length());
3479         byte[] b = fb.apply(SPECIES.length());
3480         byte[] r = fr.apply(SPECIES.length());
3481 
3482         for (int i = 0; i < a.length; i += SPECIES.length()) {
3483             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3484             av.min(b[i]).intoArray(r, i);
3485         }
3486 
3487         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::min);
3488     }
3489 
3490     @Test(dataProvider = "byteBinaryOpProvider")
3491     static void MAXByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3492         byte[] a = fa.apply(SPECIES.length());
3493         byte[] b = fb.apply(SPECIES.length());
3494         byte[] r = fr.apply(SPECIES.length());
3495 
3496         for (int i = 0; i < a.length; i += SPECIES.length()) {
3497             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3498             av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
3499         }
3500 
3501         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::MAX);
3502     }
3503 
3504     @Test(dataProvider = "byteBinaryOpProvider")
3505     static void maxByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3506         byte[] a = fa.apply(SPECIES.length());
3507         byte[] b = fb.apply(SPECIES.length());
3508         byte[] r = fr.apply(SPECIES.length());
3509 
3510         for (int i = 0; i < a.length; i += SPECIES.length()) {
3511             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3512             av.max(b[i]).intoArray(r, i);
3513         }
3514 
3515         assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::max);
3516     }
3517     @Test(dataProvider = "byteSaturatingBinaryOpAssocProvider")
3518     static void SUADDAssocByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
3519         byte[] a = fa.apply(SPECIES.length());
3520         byte[] b = fb.apply(SPECIES.length());
3521         byte[] c = fc.apply(SPECIES.length());
3522         byte[] rl = fr.apply(SPECIES.length());
3523         byte[] rr = fr.apply(SPECIES.length());
3524 
3525         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3526             for (int i = 0; i < a.length; i += SPECIES.length()) {
3527                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3528                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3529                 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
3530                 av.lanewise(VectorOperators.SUADD, bv).lanewise(VectorOperators.SUADD, cv).intoArray(rl, i);
3531                 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv)).intoArray(rr, i);
3532             }
3533         }
3534 
3535         assertArraysEqualsAssociative(rl, rr, a, b, c, ByteMaxVectorTests::SUADD);
3536     }
3537 
3538     @Test(dataProvider = "byteSaturatingBinaryOpAssocMaskProvider")
3539     static void SUADDAssocByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
3540                                                      IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
3541         byte[] a = fa.apply(SPECIES.length());
3542         byte[] b = fb.apply(SPECIES.length());
3543         byte[] c = fc.apply(SPECIES.length());
3544         boolean[] mask = fm.apply(SPECIES.length());
3545         byte[] rl = fr.apply(SPECIES.length());
3546         byte[] rr = fr.apply(SPECIES.length());
3547 
3548         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3549 
3550         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3551             for (int i = 0; i < a.length; i += SPECIES.length()) {
3552                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3553                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3554                 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
3555                 av.lanewise(VectorOperators.SUADD, bv, vmask).lanewise(VectorOperators.SUADD, cv, vmask).intoArray(rl, i);
3556                 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv, vmask), vmask).intoArray(rr, i);
3557             }
3558         }
3559 
3560         assertArraysEqualsAssociative(rl, rr, a, b, c, mask, ByteMaxVectorTests::SUADD);
3561     }
3562 
3563     static byte ANDReduce(byte[] a, int idx) {
3564         byte res = -1;
3565         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3566             res &= a[i];
3567         }
3568 
3569         return res;
3570     }
3571 
3572     static byte ANDReduceAll(byte[] a) {
3573         byte res = -1;
3574         for (int i = 0; i < a.length; i += SPECIES.length()) {
3575             res &= ANDReduce(a, i);
3576         }
3577 
3578         return res;
3579     }
3580 
3581     @Test(dataProvider = "byteUnaryOpProvider")
3582     static void ANDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3583         byte[] a = fa.apply(SPECIES.length());
3584         byte[] r = fr.apply(SPECIES.length());
3585         byte ra = -1;
3586 
3587         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3588             for (int i = 0; i < a.length; i += SPECIES.length()) {
3589                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3590                 r[i] = av.reduceLanes(VectorOperators.AND);
3591             }
3592         }
3593 
3594         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3595             ra = -1;
3596             for (int i = 0; i < a.length; i += SPECIES.length()) {
3597                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3598                 ra &= av.reduceLanes(VectorOperators.AND);
3599             }
3600         }
3601 
3602         assertReductionArraysEquals(r, ra, a,
3603                 ByteMaxVectorTests::ANDReduce, ByteMaxVectorTests::ANDReduceAll);
3604     }
3605 
3606     static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) {
3607         byte res = -1;
3608         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3609             if (mask[i % SPECIES.length()])
3610                 res &= a[i];
3611         }
3612 
3613         return res;
3614     }
3615 
3616     static byte ANDReduceAllMasked(byte[] a, boolean[] mask) {
3617         byte res = -1;
3618         for (int i = 0; i < a.length; i += SPECIES.length()) {
3619             res &= ANDReduceMasked(a, i, mask);
3620         }
3621 
3622         return res;
3623     }
3624 
3625     @Test(dataProvider = "byteUnaryOpMaskProvider")
3626     static void ANDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3627         byte[] a = fa.apply(SPECIES.length());
3628         byte[] r = fr.apply(SPECIES.length());
3629         boolean[] mask = fm.apply(SPECIES.length());
3630         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3631         byte ra = -1;
3632 
3633         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3634             for (int i = 0; i < a.length; i += SPECIES.length()) {
3635                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3636                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3637             }
3638         }
3639 
3640         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3641             ra = -1;
3642             for (int i = 0; i < a.length; i += SPECIES.length()) {
3643                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3644                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3645             }
3646         }
3647 
3648         assertReductionArraysEqualsMasked(r, ra, a, mask,
3649                 ByteMaxVectorTests::ANDReduceMasked, ByteMaxVectorTests::ANDReduceAllMasked);
3650     }
3651 
3652     static byte ORReduce(byte[] a, int idx) {
3653         byte res = 0;
3654         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3655             res |= a[i];
3656         }
3657 
3658         return res;
3659     }
3660 
3661     static byte ORReduceAll(byte[] a) {
3662         byte res = 0;
3663         for (int i = 0; i < a.length; i += SPECIES.length()) {
3664             res |= ORReduce(a, i);
3665         }
3666 
3667         return res;
3668     }
3669 
3670     @Test(dataProvider = "byteUnaryOpProvider")
3671     static void ORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3672         byte[] a = fa.apply(SPECIES.length());
3673         byte[] r = fr.apply(SPECIES.length());
3674         byte ra = 0;
3675 
3676         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3677             for (int i = 0; i < a.length; i += SPECIES.length()) {
3678                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3679                 r[i] = av.reduceLanes(VectorOperators.OR);
3680             }
3681         }
3682 
3683         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3684             ra = 0;
3685             for (int i = 0; i < a.length; i += SPECIES.length()) {
3686                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3687                 ra |= av.reduceLanes(VectorOperators.OR);
3688             }
3689         }
3690 
3691         assertReductionArraysEquals(r, ra, a,
3692                 ByteMaxVectorTests::ORReduce, ByteMaxVectorTests::ORReduceAll);
3693     }
3694 
3695     static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) {
3696         byte res = 0;
3697         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3698             if (mask[i % SPECIES.length()])
3699                 res |= a[i];
3700         }
3701 
3702         return res;
3703     }
3704 
3705     static byte ORReduceAllMasked(byte[] a, boolean[] mask) {
3706         byte res = 0;
3707         for (int i = 0; i < a.length; i += SPECIES.length()) {
3708             res |= ORReduceMasked(a, i, mask);
3709         }
3710 
3711         return res;
3712     }
3713 
3714     @Test(dataProvider = "byteUnaryOpMaskProvider")
3715     static void ORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3716         byte[] a = fa.apply(SPECIES.length());
3717         byte[] r = fr.apply(SPECIES.length());
3718         boolean[] mask = fm.apply(SPECIES.length());
3719         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3720         byte ra = 0;
3721 
3722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3723             for (int i = 0; i < a.length; i += SPECIES.length()) {
3724                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3725                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3726             }
3727         }
3728 
3729         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3730             ra = 0;
3731             for (int i = 0; i < a.length; i += SPECIES.length()) {
3732                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3733                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3734             }
3735         }
3736 
3737         assertReductionArraysEqualsMasked(r, ra, a, mask,
3738                 ByteMaxVectorTests::ORReduceMasked, ByteMaxVectorTests::ORReduceAllMasked);
3739     }
3740 
3741     static byte XORReduce(byte[] a, int idx) {
3742         byte res = 0;
3743         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3744             res ^= a[i];
3745         }
3746 
3747         return res;
3748     }
3749 
3750     static byte XORReduceAll(byte[] a) {
3751         byte res = 0;
3752         for (int i = 0; i < a.length; i += SPECIES.length()) {
3753             res ^= XORReduce(a, i);
3754         }
3755 
3756         return res;
3757     }
3758 
3759     @Test(dataProvider = "byteUnaryOpProvider")
3760     static void XORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3761         byte[] a = fa.apply(SPECIES.length());
3762         byte[] r = fr.apply(SPECIES.length());
3763         byte ra = 0;
3764 
3765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3766             for (int i = 0; i < a.length; i += SPECIES.length()) {
3767                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3768                 r[i] = av.reduceLanes(VectorOperators.XOR);
3769             }
3770         }
3771 
3772         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3773             ra = 0;
3774             for (int i = 0; i < a.length; i += SPECIES.length()) {
3775                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3776                 ra ^= av.reduceLanes(VectorOperators.XOR);
3777             }
3778         }
3779 
3780         assertReductionArraysEquals(r, ra, a,
3781                 ByteMaxVectorTests::XORReduce, ByteMaxVectorTests::XORReduceAll);
3782     }
3783 
3784     static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) {
3785         byte res = 0;
3786         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3787             if (mask[i % SPECIES.length()])
3788                 res ^= a[i];
3789         }
3790 
3791         return res;
3792     }
3793 
3794     static byte XORReduceAllMasked(byte[] a, boolean[] mask) {
3795         byte res = 0;
3796         for (int i = 0; i < a.length; i += SPECIES.length()) {
3797             res ^= XORReduceMasked(a, i, mask);
3798         }
3799 
3800         return res;
3801     }
3802 
3803     @Test(dataProvider = "byteUnaryOpMaskProvider")
3804     static void XORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3805         byte[] a = fa.apply(SPECIES.length());
3806         byte[] r = fr.apply(SPECIES.length());
3807         boolean[] mask = fm.apply(SPECIES.length());
3808         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3809         byte ra = 0;
3810 
3811         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3812             for (int i = 0; i < a.length; i += SPECIES.length()) {
3813                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3814                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3815             }
3816         }
3817 
3818         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3819             ra = 0;
3820             for (int i = 0; i < a.length; i += SPECIES.length()) {
3821                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3822                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3823             }
3824         }
3825 
3826         assertReductionArraysEqualsMasked(r, ra, a, mask,
3827                 ByteMaxVectorTests::XORReduceMasked, ByteMaxVectorTests::XORReduceAllMasked);
3828     }
3829 
3830     static byte ADDReduce(byte[] a, int idx) {
3831         byte res = 0;
3832         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3833             res += a[i];
3834         }
3835 
3836         return res;
3837     }
3838 
3839     static byte ADDReduceAll(byte[] a) {
3840         byte res = 0;
3841         for (int i = 0; i < a.length; i += SPECIES.length()) {
3842             res += ADDReduce(a, i);
3843         }
3844 
3845         return res;
3846     }
3847 
3848     @Test(dataProvider = "byteUnaryOpProvider")
3849     static void ADDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3850         byte[] a = fa.apply(SPECIES.length());
3851         byte[] r = fr.apply(SPECIES.length());
3852         byte ra = 0;
3853 
3854         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3855             for (int i = 0; i < a.length; i += SPECIES.length()) {
3856                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3857                 r[i] = av.reduceLanes(VectorOperators.ADD);
3858             }
3859         }
3860 
3861         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3862             ra = 0;
3863             for (int i = 0; i < a.length; i += SPECIES.length()) {
3864                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3865                 ra += av.reduceLanes(VectorOperators.ADD);
3866             }
3867         }
3868 
3869         assertReductionArraysEquals(r, ra, a,
3870                 ByteMaxVectorTests::ADDReduce, ByteMaxVectorTests::ADDReduceAll);
3871     }
3872 
3873     static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) {
3874         byte res = 0;
3875         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3876             if (mask[i % SPECIES.length()])
3877                 res += a[i];
3878         }
3879 
3880         return res;
3881     }
3882 
3883     static byte ADDReduceAllMasked(byte[] a, boolean[] mask) {
3884         byte res = 0;
3885         for (int i = 0; i < a.length; i += SPECIES.length()) {
3886             res += ADDReduceMasked(a, i, mask);
3887         }
3888 
3889         return res;
3890     }
3891 
3892     @Test(dataProvider = "byteUnaryOpMaskProvider")
3893     static void ADDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3894         byte[] a = fa.apply(SPECIES.length());
3895         byte[] r = fr.apply(SPECIES.length());
3896         boolean[] mask = fm.apply(SPECIES.length());
3897         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3898         byte ra = 0;
3899 
3900         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3901             for (int i = 0; i < a.length; i += SPECIES.length()) {
3902                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3903                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3904             }
3905         }
3906 
3907         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3908             ra = 0;
3909             for (int i = 0; i < a.length; i += SPECIES.length()) {
3910                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3911                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3912             }
3913         }
3914 
3915         assertReductionArraysEqualsMasked(r, ra, a, mask,
3916                 ByteMaxVectorTests::ADDReduceMasked, ByteMaxVectorTests::ADDReduceAllMasked);
3917     }
3918 
3919     static byte MULReduce(byte[] a, int idx) {
3920         byte res = 1;
3921         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3922             res *= a[i];
3923         }
3924 
3925         return res;
3926     }
3927 
3928     static byte MULReduceAll(byte[] a) {
3929         byte res = 1;
3930         for (int i = 0; i < a.length; i += SPECIES.length()) {
3931             res *= MULReduce(a, i);
3932         }
3933 
3934         return res;
3935     }
3936 
3937     @Test(dataProvider = "byteUnaryOpProvider")
3938     static void MULReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3939         byte[] a = fa.apply(SPECIES.length());
3940         byte[] r = fr.apply(SPECIES.length());
3941         byte ra = 1;
3942 
3943         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3944             for (int i = 0; i < a.length; i += SPECIES.length()) {
3945                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3946                 r[i] = av.reduceLanes(VectorOperators.MUL);
3947             }
3948         }
3949 
3950         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3951             ra = 1;
3952             for (int i = 0; i < a.length; i += SPECIES.length()) {
3953                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3954                 ra *= av.reduceLanes(VectorOperators.MUL);
3955             }
3956         }
3957 
3958         assertReductionArraysEquals(r, ra, a,
3959                 ByteMaxVectorTests::MULReduce, ByteMaxVectorTests::MULReduceAll);
3960     }
3961 
3962     static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) {
3963         byte res = 1;
3964         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3965             if (mask[i % SPECIES.length()])
3966                 res *= a[i];
3967         }
3968 
3969         return res;
3970     }
3971 
3972     static byte MULReduceAllMasked(byte[] a, boolean[] mask) {
3973         byte res = 1;
3974         for (int i = 0; i < a.length; i += SPECIES.length()) {
3975             res *= MULReduceMasked(a, i, mask);
3976         }
3977 
3978         return res;
3979     }
3980 
3981     @Test(dataProvider = "byteUnaryOpMaskProvider")
3982     static void MULReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3983         byte[] a = fa.apply(SPECIES.length());
3984         byte[] r = fr.apply(SPECIES.length());
3985         boolean[] mask = fm.apply(SPECIES.length());
3986         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3987         byte ra = 1;
3988 
3989         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3990             for (int i = 0; i < a.length; i += SPECIES.length()) {
3991                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3992                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3993             }
3994         }
3995 
3996         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3997             ra = 1;
3998             for (int i = 0; i < a.length; i += SPECIES.length()) {
3999                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4000                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
4001             }
4002         }
4003 
4004         assertReductionArraysEqualsMasked(r, ra, a, mask,
4005                 ByteMaxVectorTests::MULReduceMasked, ByteMaxVectorTests::MULReduceAllMasked);
4006     }
4007 
4008     static byte MINReduce(byte[] a, int idx) {
4009         byte res = Byte.MAX_VALUE;
4010         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4011             res = (byte) Math.min(res, a[i]);
4012         }
4013 
4014         return res;
4015     }
4016 
4017     static byte MINReduceAll(byte[] a) {
4018         byte res = Byte.MAX_VALUE;
4019         for (int i = 0; i < a.length; i += SPECIES.length()) {
4020             res = (byte) Math.min(res, MINReduce(a, i));
4021         }
4022 
4023         return res;
4024     }
4025 
4026     @Test(dataProvider = "byteUnaryOpProvider")
4027     static void MINReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4028         byte[] a = fa.apply(SPECIES.length());
4029         byte[] r = fr.apply(SPECIES.length());
4030         byte ra = Byte.MAX_VALUE;
4031 
4032         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4033             for (int i = 0; i < a.length; i += SPECIES.length()) {
4034                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4035                 r[i] = av.reduceLanes(VectorOperators.MIN);
4036             }
4037         }
4038 
4039         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4040             ra = Byte.MAX_VALUE;
4041             for (int i = 0; i < a.length; i += SPECIES.length()) {
4042                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4043                 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
4044             }
4045         }
4046 
4047         assertReductionArraysEquals(r, ra, a,
4048                 ByteMaxVectorTests::MINReduce, ByteMaxVectorTests::MINReduceAll);
4049     }
4050 
4051     static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) {
4052         byte res = Byte.MAX_VALUE;
4053         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4054             if (mask[i % SPECIES.length()])
4055                 res = (byte) Math.min(res, a[i]);
4056         }
4057 
4058         return res;
4059     }
4060 
4061     static byte MINReduceAllMasked(byte[] a, boolean[] mask) {
4062         byte res = Byte.MAX_VALUE;
4063         for (int i = 0; i < a.length; i += SPECIES.length()) {
4064             res = (byte) Math.min(res, MINReduceMasked(a, i, mask));
4065         }
4066 
4067         return res;
4068     }
4069 
4070     @Test(dataProvider = "byteUnaryOpMaskProvider")
4071     static void MINReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4072         byte[] a = fa.apply(SPECIES.length());
4073         byte[] r = fr.apply(SPECIES.length());
4074         boolean[] mask = fm.apply(SPECIES.length());
4075         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4076         byte ra = Byte.MAX_VALUE;
4077 
4078         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4079             for (int i = 0; i < a.length; i += SPECIES.length()) {
4080                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4081                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
4082             }
4083         }
4084 
4085         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4086             ra = Byte.MAX_VALUE;
4087             for (int i = 0; i < a.length; i += SPECIES.length()) {
4088                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4089                 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
4090             }
4091         }
4092 
4093         assertReductionArraysEqualsMasked(r, ra, a, mask,
4094                 ByteMaxVectorTests::MINReduceMasked, ByteMaxVectorTests::MINReduceAllMasked);
4095     }
4096 
4097     static byte MAXReduce(byte[] a, int idx) {
4098         byte res = Byte.MIN_VALUE;
4099         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4100             res = (byte) Math.max(res, a[i]);
4101         }
4102 
4103         return res;
4104     }
4105 
4106     static byte MAXReduceAll(byte[] a) {
4107         byte res = Byte.MIN_VALUE;
4108         for (int i = 0; i < a.length; i += SPECIES.length()) {
4109             res = (byte) Math.max(res, MAXReduce(a, i));
4110         }
4111 
4112         return res;
4113     }
4114 
4115     @Test(dataProvider = "byteUnaryOpProvider")
4116     static void MAXReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4117         byte[] a = fa.apply(SPECIES.length());
4118         byte[] r = fr.apply(SPECIES.length());
4119         byte ra = Byte.MIN_VALUE;
4120 
4121         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4122             for (int i = 0; i < a.length; i += SPECIES.length()) {
4123                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4124                 r[i] = av.reduceLanes(VectorOperators.MAX);
4125             }
4126         }
4127 
4128         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4129             ra = Byte.MIN_VALUE;
4130             for (int i = 0; i < a.length; i += SPECIES.length()) {
4131                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4132                 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
4133             }
4134         }
4135 
4136         assertReductionArraysEquals(r, ra, a,
4137                 ByteMaxVectorTests::MAXReduce, ByteMaxVectorTests::MAXReduceAll);
4138     }
4139 
4140     static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) {
4141         byte res = Byte.MIN_VALUE;
4142         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4143             if (mask[i % SPECIES.length()])
4144                 res = (byte) Math.max(res, a[i]);
4145         }
4146 
4147         return res;
4148     }
4149 
4150     static byte MAXReduceAllMasked(byte[] a, boolean[] mask) {
4151         byte res = Byte.MIN_VALUE;
4152         for (int i = 0; i < a.length; i += SPECIES.length()) {
4153             res = (byte) Math.max(res, MAXReduceMasked(a, i, mask));
4154         }
4155 
4156         return res;
4157     }
4158 
4159     @Test(dataProvider = "byteUnaryOpMaskProvider")
4160     static void MAXReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4161         byte[] a = fa.apply(SPECIES.length());
4162         byte[] r = fr.apply(SPECIES.length());
4163         boolean[] mask = fm.apply(SPECIES.length());
4164         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4165         byte ra = Byte.MIN_VALUE;
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                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
4171             }
4172         }
4173 
4174         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4175             ra = Byte.MIN_VALUE;
4176             for (int i = 0; i < a.length; i += SPECIES.length()) {
4177                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4178                 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
4179             }
4180         }
4181 
4182         assertReductionArraysEqualsMasked(r, ra, a, mask,
4183                 ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked);
4184     }
4185 
4186     static byte UMINReduce(byte[] a, int idx) {
4187         byte res = Byte.MAX_VALUE;
4188         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4189             res = (byte) VectorMath.minUnsigned(res, a[i]);
4190         }
4191 
4192         return res;
4193     }
4194 
4195     static byte UMINReduceAll(byte[] a) {
4196         byte res = Byte.MAX_VALUE;
4197         for (int i = 0; i < a.length; i += SPECIES.length()) {
4198             res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
4199         }
4200 
4201         return res;
4202     }
4203 
4204     @Test(dataProvider = "byteUnaryOpProvider")
4205     static void UMINReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4206         byte[] a = fa.apply(SPECIES.length());
4207         byte[] r = fr.apply(SPECIES.length());
4208         byte ra = Byte.MAX_VALUE;
4209 
4210         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4211             for (int i = 0; i < a.length; i += SPECIES.length()) {
4212                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4213                 r[i] = av.reduceLanes(VectorOperators.UMIN);
4214             }
4215         }
4216 
4217         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4218             ra = Byte.MAX_VALUE;
4219             for (int i = 0; i < a.length; i += SPECIES.length()) {
4220                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4221                 ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
4222             }
4223         }
4224 
4225         assertReductionArraysEquals(r, ra, a,
4226                 ByteMaxVectorTests::UMINReduce, ByteMaxVectorTests::UMINReduceAll);
4227     }
4228 
4229     static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
4230         byte res = Byte.MAX_VALUE;
4231         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4232             if (mask[i % SPECIES.length()])
4233                 res = (byte) VectorMath.minUnsigned(res, a[i]);
4234         }
4235 
4236         return res;
4237     }
4238 
4239     static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
4240         byte res = Byte.MAX_VALUE;
4241         for (int i = 0; i < a.length; i += SPECIES.length()) {
4242             res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
4243         }
4244 
4245         return res;
4246     }
4247 
4248     @Test(dataProvider = "byteUnaryOpMaskProvider")
4249     static void UMINReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4250         byte[] a = fa.apply(SPECIES.length());
4251         byte[] r = fr.apply(SPECIES.length());
4252         boolean[] mask = fm.apply(SPECIES.length());
4253         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4254         byte ra = Byte.MAX_VALUE;
4255 
4256         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4257             for (int i = 0; i < a.length; i += SPECIES.length()) {
4258                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4259                 r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
4260             }
4261         }
4262 
4263         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4264             ra = Byte.MAX_VALUE;
4265             for (int i = 0; i < a.length; i += SPECIES.length()) {
4266                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4267                 ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
4268             }
4269         }
4270 
4271         assertReductionArraysEqualsMasked(r, ra, a, mask,
4272                 ByteMaxVectorTests::UMINReduceMasked, ByteMaxVectorTests::UMINReduceAllMasked);
4273     }
4274 
4275     static byte UMAXReduce(byte[] a, int idx) {
4276         byte res = Byte.MIN_VALUE;
4277         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4278             res = (byte) VectorMath.maxUnsigned(res, a[i]);
4279         }
4280 
4281         return res;
4282     }
4283 
4284     static byte UMAXReduceAll(byte[] a) {
4285         byte res = Byte.MIN_VALUE;
4286         for (int i = 0; i < a.length; i += SPECIES.length()) {
4287             res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
4288         }
4289 
4290         return res;
4291     }
4292 
4293     @Test(dataProvider = "byteUnaryOpProvider")
4294     static void UMAXReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4295         byte[] a = fa.apply(SPECIES.length());
4296         byte[] r = fr.apply(SPECIES.length());
4297         byte ra = Byte.MIN_VALUE;
4298 
4299         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4300             for (int i = 0; i < a.length; i += SPECIES.length()) {
4301                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4302                 r[i] = av.reduceLanes(VectorOperators.UMAX);
4303             }
4304         }
4305 
4306         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4307             ra = Byte.MIN_VALUE;
4308             for (int i = 0; i < a.length; i += SPECIES.length()) {
4309                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4310                 ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
4311             }
4312         }
4313 
4314         assertReductionArraysEquals(r, ra, a,
4315                 ByteMaxVectorTests::UMAXReduce, ByteMaxVectorTests::UMAXReduceAll);
4316     }
4317 
4318     static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
4319         byte res = Byte.MIN_VALUE;
4320         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4321             if (mask[i % SPECIES.length()])
4322                 res = (byte) VectorMath.maxUnsigned(res, a[i]);
4323         }
4324 
4325         return res;
4326     }
4327 
4328     static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
4329         byte res = Byte.MIN_VALUE;
4330         for (int i = 0; i < a.length; i += SPECIES.length()) {
4331             res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
4332         }
4333 
4334         return res;
4335     }
4336 
4337     @Test(dataProvider = "byteUnaryOpMaskProvider")
4338     static void UMAXReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4339         byte[] a = fa.apply(SPECIES.length());
4340         byte[] r = fr.apply(SPECIES.length());
4341         boolean[] mask = fm.apply(SPECIES.length());
4342         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4343         byte ra = Byte.MIN_VALUE;
4344 
4345         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4346             for (int i = 0; i < a.length; i += SPECIES.length()) {
4347                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4348                 r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
4349             }
4350         }
4351 
4352         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4353             ra = Byte.MIN_VALUE;
4354             for (int i = 0; i < a.length; i += SPECIES.length()) {
4355                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4356                 ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
4357             }
4358         }
4359 
4360         assertReductionArraysEqualsMasked(r, ra, a, mask,
4361                 ByteMaxVectorTests::UMAXReduceMasked, ByteMaxVectorTests::UMAXReduceAllMasked);
4362     }
4363 
4364     static byte FIRST_NONZEROReduce(byte[] a, int idx) {
4365         byte res = (byte) 0;
4366         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4367             res = firstNonZero(res, a[i]);
4368         }
4369 
4370         return res;
4371     }
4372 
4373     static byte FIRST_NONZEROReduceAll(byte[] a) {
4374         byte res = (byte) 0;
4375         for (int i = 0; i < a.length; i += SPECIES.length()) {
4376             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
4377         }
4378 
4379         return res;
4380     }
4381 
4382     @Test(dataProvider = "byteUnaryOpProvider")
4383     static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4384         byte[] a = fa.apply(SPECIES.length());
4385         byte[] r = fr.apply(SPECIES.length());
4386         byte ra = (byte) 0;
4387 
4388         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4389             for (int i = 0; i < a.length; i += SPECIES.length()) {
4390                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4391                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
4392             }
4393         }
4394 
4395         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4396             ra = (byte) 0;
4397             for (int i = 0; i < a.length; i += SPECIES.length()) {
4398                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4399                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
4400             }
4401         }
4402 
4403         assertReductionArraysEquals(r, ra, a,
4404                 ByteMaxVectorTests::FIRST_NONZEROReduce, ByteMaxVectorTests::FIRST_NONZEROReduceAll);
4405     }
4406 
4407     static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) {
4408         byte res = (byte) 0;
4409         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4410             if (mask[i % SPECIES.length()])
4411                 res = firstNonZero(res, a[i]);
4412         }
4413 
4414         return res;
4415     }
4416 
4417     static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) {
4418         byte res = (byte) 0;
4419         for (int i = 0; i < a.length; i += SPECIES.length()) {
4420             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
4421         }
4422 
4423         return res;
4424     }
4425 
4426     @Test(dataProvider = "byteUnaryOpMaskProvider")
4427     static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4428         byte[] a = fa.apply(SPECIES.length());
4429         byte[] r = fr.apply(SPECIES.length());
4430         boolean[] mask = fm.apply(SPECIES.length());
4431         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4432         byte ra = (byte) 0;
4433 
4434         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4435             for (int i = 0; i < a.length; i += SPECIES.length()) {
4436                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4437                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
4438             }
4439         }
4440 
4441         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4442             ra = (byte) 0;
4443             for (int i = 0; i < a.length; i += SPECIES.length()) {
4444                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4445                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
4446             }
4447         }
4448 
4449         assertReductionArraysEqualsMasked(r, ra, a, mask,
4450                 ByteMaxVectorTests::FIRST_NONZEROReduceMasked, ByteMaxVectorTests::FIRST_NONZEROReduceAllMasked);
4451     }
4452 
4453     static boolean anyTrue(boolean[] a, int idx) {
4454         boolean res = false;
4455         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4456             res |= a[i];
4457         }
4458 
4459         return res;
4460     }
4461 
4462     @Test(dataProvider = "boolUnaryOpProvider")
4463     static void anyTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
4464         boolean[] mask = fm.apply(SPECIES.length());
4465         boolean[] r = fmr.apply(SPECIES.length());
4466 
4467         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4468             for (int i = 0; i < mask.length; i += SPECIES.length()) {
4469                 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
4470                 r[i] = vmask.anyTrue();
4471             }
4472         }
4473 
4474         assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::anyTrue);
4475     }
4476 
4477     static boolean allTrue(boolean[] a, int idx) {
4478         boolean res = true;
4479         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4480             res &= a[i];
4481         }
4482 
4483         return res;
4484     }
4485 
4486     @Test(dataProvider = "boolUnaryOpProvider")
4487     static void allTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
4488         boolean[] mask = fm.apply(SPECIES.length());
4489         boolean[] r = fmr.apply(SPECIES.length());
4490 
4491         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4492             for (int i = 0; i < mask.length; i += SPECIES.length()) {
4493                 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
4494                 r[i] = vmask.allTrue();
4495             }
4496         }
4497 
4498         assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue);
4499     }
4500 
4501     static byte SUADDReduce(byte[] a, int idx) {
4502         byte res = 0;
4503         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4504             res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
4505         }
4506 
4507         return res;
4508     }
4509 
4510     static byte SUADDReduceAll(byte[] a) {
4511         byte res = 0;
4512         for (int i = 0; i < a.length; i += SPECIES.length()) {
4513             res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
4514         }
4515 
4516         return res;
4517     }
4518 
4519     @Test(dataProvider = "byteSaturatingUnaryOpProvider")
4520     static void SUADDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
4521         byte[] a = fa.apply(SPECIES.length());
4522         byte[] r = fr.apply(SPECIES.length());
4523         byte ra = 0;
4524 
4525         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4526             for (int i = 0; i < a.length; i += SPECIES.length()) {
4527                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4528                 r[i] = av.reduceLanes(VectorOperators.SUADD);
4529             }
4530         }
4531 
4532         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4533             ra = 0;
4534             for (int i = 0; i < a.length; i += SPECIES.length()) {
4535                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4536                 ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
4537             }
4538         }
4539 
4540         assertReductionArraysEquals(r, ra, a,
4541                 ByteMaxVectorTests::SUADDReduce, ByteMaxVectorTests::SUADDReduceAll);
4542     }
4543 
4544     static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) {
4545         byte res = 0;
4546         for (int i = idx; i < (idx + SPECIES.length()); i++) {
4547             if (mask[i % SPECIES.length()])
4548                 res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]);
4549         }
4550 
4551         return res;
4552     }
4553 
4554     static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) {
4555         byte res = 0;
4556         for (int i = 0; i < a.length; i += SPECIES.length()) {
4557             res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
4558         }
4559 
4560         return res;
4561     }
4562     @Test(dataProvider = "byteSaturatingUnaryOpMaskProvider")
4563     static void SUADDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
4564         byte[] a = fa.apply(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         byte ra = 0;
4569 
4570         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4571             for (int i = 0; i < a.length; i += SPECIES.length()) {
4572                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4573                 r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
4574             }
4575         }
4576 
4577         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4578             ra = 0;
4579             for (int i = 0; i < a.length; i += SPECIES.length()) {
4580                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4581                 ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
4582             }
4583         }
4584 
4585         assertReductionArraysEqualsMasked(r, ra, a, mask,
4586                 ByteMaxVectorTests::SUADDReduceMasked, ByteMaxVectorTests::SUADDReduceAllMasked);
4587     }
4588 
4589     @Test(dataProvider = "byteBinaryOpProvider")
4590     static void withByteMaxVectorTests(IntFunction<byte []> fa, IntFunction<byte []> fb) {
4591         byte[] a = fa.apply(SPECIES.length());
4592         byte[] b = fb.apply(SPECIES.length());
4593         byte[] r = fr.apply(SPECIES.length());
4594 
4595         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4596             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
4597                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4598                 av.withLane(j, b[i + j]).intoArray(r, i);
4599                 a[i + j] = b[i + j];
4600                 j = (j + 1) & (SPECIES.length() - 1);
4601             }
4602         }
4603 
4604 
4605         assertArraysStrictlyEquals(r, a);
4606     }
4607 
4608     static boolean testIS_DEFAULT(byte a) {
4609         return bits(a)==0;
4610     }
4611 
4612     @Test(dataProvider = "byteTestOpProvider")
4613     static void IS_DEFAULTByteMaxVectorTests(IntFunction<byte[]> fa) {
4614         byte[] a = fa.apply(SPECIES.length());
4615 
4616         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4617             for (int i = 0; i < a.length; i += SPECIES.length()) {
4618                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4619                 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT);
4620 
4621                 // Check results as part of computation.
4622                 for (int j = 0; j < SPECIES.length(); j++) {
4623                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
4624                 }
4625             }
4626         }
4627     }
4628 
4629     @Test(dataProvider = "byteTestOpMaskProvider")
4630     static void IS_DEFAULTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
4631                                           IntFunction<boolean[]> fm) {
4632         byte[] a = fa.apply(SPECIES.length());
4633         boolean[] mask = fm.apply(SPECIES.length());
4634         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4635 
4636         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4637             for (int i = 0; i < a.length; i += SPECIES.length()) {
4638                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4639                 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
4640 
4641                 // Check results as part of computation.
4642                 for (int j = 0; j < SPECIES.length(); j++) {
4643                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
4644                 }
4645             }
4646         }
4647     }
4648 
4649     static boolean testIS_NEGATIVE(byte a) {
4650         return bits(a)<0;
4651     }
4652 
4653     @Test(dataProvider = "byteTestOpProvider")
4654     static void IS_NEGATIVEByteMaxVectorTests(IntFunction<byte[]> fa) {
4655         byte[] a = fa.apply(SPECIES.length());
4656 
4657         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4658             for (int i = 0; i < a.length; i += SPECIES.length()) {
4659                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4660                 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE);
4661 
4662                 // Check results as part of computation.
4663                 for (int j = 0; j < SPECIES.length(); j++) {
4664                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
4665                 }
4666             }
4667         }
4668     }
4669 
4670     @Test(dataProvider = "byteTestOpMaskProvider")
4671     static void IS_NEGATIVEMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
4672                                           IntFunction<boolean[]> fm) {
4673         byte[] a = fa.apply(SPECIES.length());
4674         boolean[] mask = fm.apply(SPECIES.length());
4675         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4676 
4677         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4678             for (int i = 0; i < a.length; i += SPECIES.length()) {
4679                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4680                 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
4681 
4682                 // Check results as part of computation.
4683                 for (int j = 0; j < SPECIES.length(); j++) {
4684                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
4685                 }
4686             }
4687         }
4688     }
4689 
4690     @Test(dataProvider = "byteCompareOpProvider")
4691     static void LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4692         byte[] a = fa.apply(SPECIES.length());
4693         byte[] b = fb.apply(SPECIES.length());
4694 
4695         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4696             for (int i = 0; i < a.length; i += SPECIES.length()) {
4697                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4698                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4699                 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv);
4700 
4701                 // Check results as part of computation.
4702                 for (int j = 0; j < SPECIES.length(); j++) {
4703                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4704                 }
4705             }
4706         }
4707     }
4708 
4709     @Test(dataProvider = "byteCompareOpProvider")
4710     static void ltByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4711         byte[] a = fa.apply(SPECIES.length());
4712         byte[] b = fb.apply(SPECIES.length());
4713 
4714         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4715             for (int i = 0; i < a.length; i += SPECIES.length()) {
4716                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4717                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4718                 VectorMask<Byte> mv = av.lt(bv);
4719 
4720                 // Check results as part of computation.
4721                 for (int j = 0; j < SPECIES.length(); j++) {
4722                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4723                 }
4724             }
4725         }
4726     }
4727 
4728     @Test(dataProvider = "byteCompareOpMaskProvider")
4729     static void LTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4730                                                 IntFunction<boolean[]> fm) {
4731         byte[] a = fa.apply(SPECIES.length());
4732         byte[] b = fb.apply(SPECIES.length());
4733         boolean[] mask = fm.apply(SPECIES.length());
4734 
4735         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4736 
4737         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4738             for (int i = 0; i < a.length; i += SPECIES.length()) {
4739                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4740                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4741                 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv, vmask);
4742 
4743                 // Check results as part of computation.
4744                 for (int j = 0; j < SPECIES.length(); j++) {
4745                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
4746                 }
4747             }
4748         }
4749     }
4750 
4751     @Test(dataProvider = "byteCompareOpProvider")
4752     static void GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4753         byte[] a = fa.apply(SPECIES.length());
4754         byte[] b = fb.apply(SPECIES.length());
4755 
4756         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4757             for (int i = 0; i < a.length; i += SPECIES.length()) {
4758                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4759                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4760                 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv);
4761 
4762                 // Check results as part of computation.
4763                 for (int j = 0; j < SPECIES.length(); j++) {
4764                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
4765                 }
4766             }
4767         }
4768     }
4769 
4770     @Test(dataProvider = "byteCompareOpMaskProvider")
4771     static void GTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4772                                                 IntFunction<boolean[]> fm) {
4773         byte[] a = fa.apply(SPECIES.length());
4774         byte[] b = fb.apply(SPECIES.length());
4775         boolean[] mask = fm.apply(SPECIES.length());
4776 
4777         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4778 
4779         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4780             for (int i = 0; i < a.length; i += SPECIES.length()) {
4781                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4782                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4783                 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv, vmask);
4784 
4785                 // Check results as part of computation.
4786                 for (int j = 0; j < SPECIES.length(); j++) {
4787                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
4788                 }
4789             }
4790         }
4791     }
4792 
4793     @Test(dataProvider = "byteCompareOpProvider")
4794     static void EQByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4795         byte[] a = fa.apply(SPECIES.length());
4796         byte[] b = fb.apply(SPECIES.length());
4797 
4798         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4799             for (int i = 0; i < a.length; i += SPECIES.length()) {
4800                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4801                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4802                 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv);
4803 
4804                 // Check results as part of computation.
4805                 for (int j = 0; j < SPECIES.length(); j++) {
4806                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4807                 }
4808             }
4809         }
4810     }
4811 
4812     @Test(dataProvider = "byteCompareOpProvider")
4813     static void eqByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4814         byte[] a = fa.apply(SPECIES.length());
4815         byte[] b = fb.apply(SPECIES.length());
4816 
4817         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4818             for (int i = 0; i < a.length; i += SPECIES.length()) {
4819                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4820                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4821                 VectorMask<Byte> mv = av.eq(bv);
4822 
4823                 // Check results as part of computation.
4824                 for (int j = 0; j < SPECIES.length(); j++) {
4825                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4826                 }
4827             }
4828         }
4829     }
4830 
4831     @Test(dataProvider = "byteCompareOpMaskProvider")
4832     static void EQByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4833                                                 IntFunction<boolean[]> fm) {
4834         byte[] a = fa.apply(SPECIES.length());
4835         byte[] b = fb.apply(SPECIES.length());
4836         boolean[] mask = fm.apply(SPECIES.length());
4837 
4838         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4839 
4840         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4841             for (int i = 0; i < a.length; i += SPECIES.length()) {
4842                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4843                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4844                 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv, vmask);
4845 
4846                 // Check results as part of computation.
4847                 for (int j = 0; j < SPECIES.length(); j++) {
4848                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4849                 }
4850             }
4851         }
4852     }
4853 
4854     @Test(dataProvider = "byteCompareOpProvider")
4855     static void NEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4856         byte[] a = fa.apply(SPECIES.length());
4857         byte[] b = fb.apply(SPECIES.length());
4858 
4859         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4860             for (int i = 0; i < a.length; i += SPECIES.length()) {
4861                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4862                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4863                 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv);
4864 
4865                 // Check results as part of computation.
4866                 for (int j = 0; j < SPECIES.length(); j++) {
4867                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4868                 }
4869             }
4870         }
4871     }
4872 
4873     @Test(dataProvider = "byteCompareOpMaskProvider")
4874     static void NEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4875                                                 IntFunction<boolean[]> fm) {
4876         byte[] a = fa.apply(SPECIES.length());
4877         byte[] b = fb.apply(SPECIES.length());
4878         boolean[] mask = fm.apply(SPECIES.length());
4879 
4880         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4881 
4882         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4883             for (int i = 0; i < a.length; i += SPECIES.length()) {
4884                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4885                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4886                 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv, vmask);
4887 
4888                 // Check results as part of computation.
4889                 for (int j = 0; j < SPECIES.length(); j++) {
4890                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4891                 }
4892             }
4893         }
4894     }
4895 
4896     @Test(dataProvider = "byteCompareOpProvider")
4897     static void LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4898         byte[] a = fa.apply(SPECIES.length());
4899         byte[] b = fb.apply(SPECIES.length());
4900 
4901         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4902             for (int i = 0; i < a.length; i += SPECIES.length()) {
4903                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4904                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4905                 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv);
4906 
4907                 // Check results as part of computation.
4908                 for (int j = 0; j < SPECIES.length(); j++) {
4909                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4910                 }
4911             }
4912         }
4913     }
4914 
4915     @Test(dataProvider = "byteCompareOpMaskProvider")
4916     static void LEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4917                                                 IntFunction<boolean[]> fm) {
4918         byte[] a = fa.apply(SPECIES.length());
4919         byte[] b = fb.apply(SPECIES.length());
4920         boolean[] mask = fm.apply(SPECIES.length());
4921 
4922         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4923 
4924         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4925             for (int i = 0; i < a.length; i += SPECIES.length()) {
4926                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4927                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4928                 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv, vmask);
4929 
4930                 // Check results as part of computation.
4931                 for (int j = 0; j < SPECIES.length(); j++) {
4932                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4933                 }
4934             }
4935         }
4936     }
4937 
4938     @Test(dataProvider = "byteCompareOpProvider")
4939     static void GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4940         byte[] a = fa.apply(SPECIES.length());
4941         byte[] b = fb.apply(SPECIES.length());
4942 
4943         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4944             for (int i = 0; i < a.length; i += SPECIES.length()) {
4945                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4946                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4947                 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv);
4948 
4949                 // Check results as part of computation.
4950                 for (int j = 0; j < SPECIES.length(); j++) {
4951                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4952                 }
4953             }
4954         }
4955     }
4956 
4957     @Test(dataProvider = "byteCompareOpMaskProvider")
4958     static void GEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4959                                                 IntFunction<boolean[]> fm) {
4960         byte[] a = fa.apply(SPECIES.length());
4961         byte[] b = fb.apply(SPECIES.length());
4962         boolean[] mask = fm.apply(SPECIES.length());
4963 
4964         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4965 
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                 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv, vmask);
4971 
4972                 // Check results as part of computation.
4973                 for (int j = 0; j < SPECIES.length(); j++) {
4974                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4975                 }
4976             }
4977         }
4978     }
4979 
4980     @Test(dataProvider = "byteCompareOpProvider")
4981     static void ULTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4982         byte[] a = fa.apply(SPECIES.length());
4983         byte[] b = fb.apply(SPECIES.length());
4984 
4985         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4986             for (int i = 0; i < a.length; i += SPECIES.length()) {
4987                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4988                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4989                 VectorMask<Byte> mv = av.compare(VectorOperators.ULT, bv);
4990 
4991                 // Check results as part of computation.
4992                 for (int j = 0; j < SPECIES.length(); j++) {
4993                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4994                 }
4995             }
4996         }
4997     }
4998 
4999     @Test(dataProvider = "byteCompareOpMaskProvider")
5000     static void ULTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5001                                                 IntFunction<boolean[]> fm) {
5002         byte[] a = fa.apply(SPECIES.length());
5003         byte[] b = fb.apply(SPECIES.length());
5004         boolean[] mask = fm.apply(SPECIES.length());
5005 
5006         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5007 
5008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5009             for (int i = 0; i < a.length; i += SPECIES.length()) {
5010                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5011                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5012                 VectorMask<Byte> mv = av.compare(VectorOperators.ULT, bv, vmask);
5013 
5014                 // Check results as part of computation.
5015                 for (int j = 0; j < SPECIES.length(); j++) {
5016                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
5017                 }
5018             }
5019         }
5020     }
5021 
5022     @Test(dataProvider = "byteCompareOpProvider")
5023     static void UGTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5024         byte[] a = fa.apply(SPECIES.length());
5025         byte[] b = fb.apply(SPECIES.length());
5026 
5027         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5028             for (int i = 0; i < a.length; i += SPECIES.length()) {
5029                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5030                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5031                 VectorMask<Byte> mv = av.compare(VectorOperators.UGT, bv);
5032 
5033                 // Check results as part of computation.
5034                 for (int j = 0; j < SPECIES.length(); j++) {
5035                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
5036                 }
5037             }
5038         }
5039     }
5040 
5041     @Test(dataProvider = "byteCompareOpMaskProvider")
5042     static void UGTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5043                                                 IntFunction<boolean[]> fm) {
5044         byte[] a = fa.apply(SPECIES.length());
5045         byte[] b = fb.apply(SPECIES.length());
5046         boolean[] mask = fm.apply(SPECIES.length());
5047 
5048         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5049 
5050         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5051             for (int i = 0; i < a.length; i += SPECIES.length()) {
5052                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5053                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5054                 VectorMask<Byte> mv = av.compare(VectorOperators.UGT, bv, vmask);
5055 
5056                 // Check results as part of computation.
5057                 for (int j = 0; j < SPECIES.length(); j++) {
5058                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
5059                 }
5060             }
5061         }
5062     }
5063 
5064     @Test(dataProvider = "byteCompareOpProvider")
5065     static void ULEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5066         byte[] a = fa.apply(SPECIES.length());
5067         byte[] b = fb.apply(SPECIES.length());
5068 
5069         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5070             for (int i = 0; i < a.length; i += SPECIES.length()) {
5071                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5072                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5073                 VectorMask<Byte> mv = av.compare(VectorOperators.ULE, bv);
5074 
5075                 // Check results as part of computation.
5076                 for (int j = 0; j < SPECIES.length(); j++) {
5077                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
5078                 }
5079             }
5080         }
5081     }
5082 
5083     @Test(dataProvider = "byteCompareOpMaskProvider")
5084     static void ULEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5085                                                 IntFunction<boolean[]> fm) {
5086         byte[] a = fa.apply(SPECIES.length());
5087         byte[] b = fb.apply(SPECIES.length());
5088         boolean[] mask = fm.apply(SPECIES.length());
5089 
5090         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5091 
5092         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5093             for (int i = 0; i < a.length; i += SPECIES.length()) {
5094                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5095                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5096                 VectorMask<Byte> mv = av.compare(VectorOperators.ULE, bv, vmask);
5097 
5098                 // Check results as part of computation.
5099                 for (int j = 0; j < SPECIES.length(); j++) {
5100                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
5101                 }
5102             }
5103         }
5104     }
5105 
5106     @Test(dataProvider = "byteCompareOpProvider")
5107     static void UGEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5108         byte[] a = fa.apply(SPECIES.length());
5109         byte[] b = fb.apply(SPECIES.length());
5110 
5111         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5112             for (int i = 0; i < a.length; i += SPECIES.length()) {
5113                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5114                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5115                 VectorMask<Byte> mv = av.compare(VectorOperators.UGE, bv);
5116 
5117                 // Check results as part of computation.
5118                 for (int j = 0; j < SPECIES.length(); j++) {
5119                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
5120                 }
5121             }
5122         }
5123     }
5124 
5125     @Test(dataProvider = "byteCompareOpMaskProvider")
5126     static void UGEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5127                                                 IntFunction<boolean[]> fm) {
5128         byte[] a = fa.apply(SPECIES.length());
5129         byte[] b = fb.apply(SPECIES.length());
5130         boolean[] mask = fm.apply(SPECIES.length());
5131 
5132         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5133 
5134         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5135             for (int i = 0; i < a.length; i += SPECIES.length()) {
5136                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5137                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5138                 VectorMask<Byte> mv = av.compare(VectorOperators.UGE, bv, vmask);
5139 
5140                 // Check results as part of computation.
5141                 for (int j = 0; j < SPECIES.length(); j++) {
5142                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
5143                 }
5144             }
5145         }
5146     }
5147 
5148     @Test(dataProvider = "byteCompareOpProvider")
5149     static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5150         byte[] a = fa.apply(SPECIES.length());
5151         byte[] b = fb.apply(SPECIES.length());
5152 
5153         for (int i = 0; i < a.length; i += SPECIES.length()) {
5154             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5155             VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i]);
5156 
5157             // Check results as part of computation.
5158             for (int j = 0; j < SPECIES.length(); j++) {
5159                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5160             }
5161         }
5162     }
5163 
5164     @Test(dataProvider = "byteCompareOpMaskProvider")
5165     static void LTByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
5166                                 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
5167         byte[] a = fa.apply(SPECIES.length());
5168         byte[] b = fb.apply(SPECIES.length());
5169         boolean[] mask = fm.apply(SPECIES.length());
5170 
5171         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5172 
5173         for (int i = 0; i < a.length; i += SPECIES.length()) {
5174             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5175             VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i], vmask);
5176 
5177             // Check results as part of computation.
5178             for (int j = 0; j < SPECIES.length(); j++) {
5179                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
5180             }
5181         }
5182     }
5183 
5184     @Test(dataProvider = "byteCompareOpProvider")
5185     static void LTByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5186         byte[] a = fa.apply(SPECIES.length());
5187         byte[] b = fb.apply(SPECIES.length());
5188 
5189         for (int i = 0; i < a.length; i += SPECIES.length()) {
5190             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5191             VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i]);
5192 
5193             // Check results as part of computation.
5194             for (int j = 0; j < SPECIES.length(); j++) {
5195                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i]));
5196             }
5197         }
5198     }
5199 
5200     @Test(dataProvider = "byteCompareOpMaskProvider")
5201     static void LTByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
5202                                 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
5203         byte[] a = fa.apply(SPECIES.length());
5204         byte[] b = fb.apply(SPECIES.length());
5205         boolean[] mask = fm.apply(SPECIES.length());
5206 
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             VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
5212 
5213             // Check results as part of computation.
5214             for (int j = 0; j < SPECIES.length(); j++) {
5215                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i])));
5216             }
5217         }
5218     }
5219 
5220     @Test(dataProvider = "byteCompareOpProvider")
5221     static void EQByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5222         byte[] a = fa.apply(SPECIES.length());
5223         byte[] b = fb.apply(SPECIES.length());
5224 
5225         for (int i = 0; i < a.length; i += SPECIES.length()) {
5226             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5227             VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i]);
5228 
5229             // Check results as part of computation.
5230             for (int j = 0; j < SPECIES.length(); j++) {
5231                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5232             }
5233         }
5234     }
5235 
5236     @Test(dataProvider = "byteCompareOpMaskProvider")
5237     static void EQByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
5238                                 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
5239         byte[] a = fa.apply(SPECIES.length());
5240         byte[] b = fb.apply(SPECIES.length());
5241         boolean[] mask = fm.apply(SPECIES.length());
5242 
5243         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5244 
5245         for (int i = 0; i < a.length; i += SPECIES.length()) {
5246             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5247             VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i], vmask);
5248 
5249             // Check results as part of computation.
5250             for (int j = 0; j < SPECIES.length(); j++) {
5251                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
5252             }
5253         }
5254     }
5255 
5256     @Test(dataProvider = "byteCompareOpProvider")
5257     static void EQByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5258         byte[] a = fa.apply(SPECIES.length());
5259         byte[] b = fb.apply(SPECIES.length());
5260 
5261         for (int i = 0; i < a.length; i += SPECIES.length()) {
5262             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5263             VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i]);
5264 
5265             // Check results as part of computation.
5266             for (int j = 0; j < SPECIES.length(); j++) {
5267                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i]));
5268             }
5269         }
5270     }
5271 
5272     @Test(dataProvider = "byteCompareOpMaskProvider")
5273     static void EQByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
5274                                 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
5275         byte[] a = fa.apply(SPECIES.length());
5276         byte[] b = fb.apply(SPECIES.length());
5277         boolean[] mask = fm.apply(SPECIES.length());
5278 
5279         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5280 
5281         for (int i = 0; i < a.length; i += SPECIES.length()) {
5282             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5283             VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
5284 
5285             // Check results as part of computation.
5286             for (int j = 0; j < SPECIES.length(); j++) {
5287                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i])));
5288             }
5289         }
5290     }
5291 
5292     static byte blend(byte a, byte b, boolean mask) {
5293         return mask ? b : a;
5294     }
5295 
5296     @Test(dataProvider = "byteBinaryOpMaskProvider")
5297     static void blendByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5298                                           IntFunction<boolean[]> fm) {
5299         byte[] a = fa.apply(SPECIES.length());
5300         byte[] b = fb.apply(SPECIES.length());
5301         byte[] r = fr.apply(SPECIES.length());
5302         boolean[] mask = fm.apply(SPECIES.length());
5303         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5304 
5305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5306             for (int i = 0; i < a.length; i += SPECIES.length()) {
5307                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5308                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5309                 av.blend(bv, vmask).intoArray(r, i);
5310             }
5311         }
5312 
5313         assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend);
5314     }
5315 
5316     @Test(dataProvider = "byteUnaryOpShuffleProvider")
5317     static void RearrangeByteMaxVectorTests(IntFunction<byte[]> fa,
5318                                            BiFunction<Integer,Integer,int[]> fs) {
5319         byte[] a = fa.apply(SPECIES.length());
5320         int[] order = fs.apply(a.length, SPECIES.length());
5321         byte[] r = fr.apply(SPECIES.length());
5322 
5323         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5324             for (int i = 0; i < a.length; i += SPECIES.length()) {
5325                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5326                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
5327             }
5328         }
5329 
5330         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
5331     }
5332 
5333     @Test(dataProvider = "byteUnaryOpShuffleMaskProvider")
5334     static void RearrangeByteMaxVectorTestsMaskedSmokeTest(IntFunction<byte[]> fa,
5335                                                           BiFunction<Integer,Integer,int[]> fs,
5336                                                           IntFunction<boolean[]> fm) {
5337         byte[] a = fa.apply(SPECIES.length());
5338         int[] order = fs.apply(a.length, SPECIES.length());
5339         byte[] r = fr.apply(SPECIES.length());
5340         boolean[] mask = fm.apply(SPECIES.length());
5341         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5342 
5343         for (int i = 0; i < a.length; i += SPECIES.length()) {
5344             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5345             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
5346         }
5347 
5348         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
5349     }
5350 
5351     @Test(dataProvider = "byteUnaryOpMaskProvider")
5352     static void compressByteMaxVectorTests(IntFunction<byte[]> fa,
5353                                                 IntFunction<boolean[]> fm) {
5354         byte[] a = fa.apply(SPECIES.length());
5355         byte[] r = fr.apply(SPECIES.length());
5356         boolean[] mask = fm.apply(SPECIES.length());
5357         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5358 
5359         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5360             for (int i = 0; i < a.length; i += SPECIES.length()) {
5361                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5362                 av.compress(vmask).intoArray(r, i);
5363             }
5364         }
5365 
5366         assertcompressArraysEquals(r, a, mask, SPECIES.length());
5367     }
5368 
5369     @Test(dataProvider = "byteUnaryOpMaskProvider")
5370     static void expandByteMaxVectorTests(IntFunction<byte[]> fa,
5371                                                 IntFunction<boolean[]> fm) {
5372         byte[] a = fa.apply(SPECIES.length());
5373         byte[] r = fr.apply(SPECIES.length());
5374         boolean[] mask = fm.apply(SPECIES.length());
5375         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5376 
5377         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5378             for (int i = 0; i < a.length; i += SPECIES.length()) {
5379                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5380                 av.expand(vmask).intoArray(r, i);
5381             }
5382         }
5383 
5384         assertexpandArraysEquals(r, a, mask, SPECIES.length());
5385     }
5386 
5387     @Test(dataProvider = "byteUnaryOpProvider")
5388     static void getByteMaxVectorTests(IntFunction<byte[]> fa) {
5389         byte[] a = fa.apply(SPECIES.length());
5390         byte[] r = fr.apply(SPECIES.length());
5391 
5392         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5393             for (int i = 0; i < a.length; i += SPECIES.length()) {
5394                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5395                 int num_lanes = SPECIES.length();
5396                 // Manually unroll because full unroll happens after intrinsification.
5397                 // Unroll is needed because get intrinsic requires for index to be a known constant.
5398                 if (num_lanes == 1) {
5399                     r[i]=av.lane(0);
5400                 } else if (num_lanes == 2) {
5401                     r[i]=av.lane(0);
5402                     r[i+1]=av.lane(1);
5403                 } else if (num_lanes == 4) {
5404                     r[i]=av.lane(0);
5405                     r[i+1]=av.lane(1);
5406                     r[i+2]=av.lane(2);
5407                     r[i+3]=av.lane(3);
5408                 } else if (num_lanes == 8) {
5409                     r[i]=av.lane(0);
5410                     r[i+1]=av.lane(1);
5411                     r[i+2]=av.lane(2);
5412                     r[i+3]=av.lane(3);
5413                     r[i+4]=av.lane(4);
5414                     r[i+5]=av.lane(5);
5415                     r[i+6]=av.lane(6);
5416                     r[i+7]=av.lane(7);
5417                 } else if (num_lanes == 16) {
5418                     r[i]=av.lane(0);
5419                     r[i+1]=av.lane(1);
5420                     r[i+2]=av.lane(2);
5421                     r[i+3]=av.lane(3);
5422                     r[i+4]=av.lane(4);
5423                     r[i+5]=av.lane(5);
5424                     r[i+6]=av.lane(6);
5425                     r[i+7]=av.lane(7);
5426                     r[i+8]=av.lane(8);
5427                     r[i+9]=av.lane(9);
5428                     r[i+10]=av.lane(10);
5429                     r[i+11]=av.lane(11);
5430                     r[i+12]=av.lane(12);
5431                     r[i+13]=av.lane(13);
5432                     r[i+14]=av.lane(14);
5433                     r[i+15]=av.lane(15);
5434                 } else if (num_lanes == 32) {
5435                     r[i]=av.lane(0);
5436                     r[i+1]=av.lane(1);
5437                     r[i+2]=av.lane(2);
5438                     r[i+3]=av.lane(3);
5439                     r[i+4]=av.lane(4);
5440                     r[i+5]=av.lane(5);
5441                     r[i+6]=av.lane(6);
5442                     r[i+7]=av.lane(7);
5443                     r[i+8]=av.lane(8);
5444                     r[i+9]=av.lane(9);
5445                     r[i+10]=av.lane(10);
5446                     r[i+11]=av.lane(11);
5447                     r[i+12]=av.lane(12);
5448                     r[i+13]=av.lane(13);
5449                     r[i+14]=av.lane(14);
5450                     r[i+15]=av.lane(15);
5451                     r[i+16]=av.lane(16);
5452                     r[i+17]=av.lane(17);
5453                     r[i+18]=av.lane(18);
5454                     r[i+19]=av.lane(19);
5455                     r[i+20]=av.lane(20);
5456                     r[i+21]=av.lane(21);
5457                     r[i+22]=av.lane(22);
5458                     r[i+23]=av.lane(23);
5459                     r[i+24]=av.lane(24);
5460                     r[i+25]=av.lane(25);
5461                     r[i+26]=av.lane(26);
5462                     r[i+27]=av.lane(27);
5463                     r[i+28]=av.lane(28);
5464                     r[i+29]=av.lane(29);
5465                     r[i+30]=av.lane(30);
5466                     r[i+31]=av.lane(31);
5467                 } else if (num_lanes == 64) {
5468                     r[i]=av.lane(0);
5469                     r[i+1]=av.lane(1);
5470                     r[i+2]=av.lane(2);
5471                     r[i+3]=av.lane(3);
5472                     r[i+4]=av.lane(4);
5473                     r[i+5]=av.lane(5);
5474                     r[i+6]=av.lane(6);
5475                     r[i+7]=av.lane(7);
5476                     r[i+8]=av.lane(8);
5477                     r[i+9]=av.lane(9);
5478                     r[i+10]=av.lane(10);
5479                     r[i+11]=av.lane(11);
5480                     r[i+12]=av.lane(12);
5481                     r[i+13]=av.lane(13);
5482                     r[i+14]=av.lane(14);
5483                     r[i+15]=av.lane(15);
5484                     r[i+16]=av.lane(16);
5485                     r[i+17]=av.lane(17);
5486                     r[i+18]=av.lane(18);
5487                     r[i+19]=av.lane(19);
5488                     r[i+20]=av.lane(20);
5489                     r[i+21]=av.lane(21);
5490                     r[i+22]=av.lane(22);
5491                     r[i+23]=av.lane(23);
5492                     r[i+24]=av.lane(24);
5493                     r[i+25]=av.lane(25);
5494                     r[i+26]=av.lane(26);
5495                     r[i+27]=av.lane(27);
5496                     r[i+28]=av.lane(28);
5497                     r[i+29]=av.lane(29);
5498                     r[i+30]=av.lane(30);
5499                     r[i+31]=av.lane(31);
5500                     r[i+32]=av.lane(32);
5501                     r[i+33]=av.lane(33);
5502                     r[i+34]=av.lane(34);
5503                     r[i+35]=av.lane(35);
5504                     r[i+36]=av.lane(36);
5505                     r[i+37]=av.lane(37);
5506                     r[i+38]=av.lane(38);
5507                     r[i+39]=av.lane(39);
5508                     r[i+40]=av.lane(40);
5509                     r[i+41]=av.lane(41);
5510                     r[i+42]=av.lane(42);
5511                     r[i+43]=av.lane(43);
5512                     r[i+44]=av.lane(44);
5513                     r[i+45]=av.lane(45);
5514                     r[i+46]=av.lane(46);
5515                     r[i+47]=av.lane(47);
5516                     r[i+48]=av.lane(48);
5517                     r[i+49]=av.lane(49);
5518                     r[i+50]=av.lane(50);
5519                     r[i+51]=av.lane(51);
5520                     r[i+52]=av.lane(52);
5521                     r[i+53]=av.lane(53);
5522                     r[i+54]=av.lane(54);
5523                     r[i+55]=av.lane(55);
5524                     r[i+56]=av.lane(56);
5525                     r[i+57]=av.lane(57);
5526                     r[i+58]=av.lane(58);
5527                     r[i+59]=av.lane(59);
5528                     r[i+60]=av.lane(60);
5529                     r[i+61]=av.lane(61);
5530                     r[i+62]=av.lane(62);
5531                     r[i+63]=av.lane(63);
5532                 } else {
5533                     for (int j = 0; j < SPECIES.length(); j++) {
5534                         r[i+j]=av.lane(j);
5535                     }
5536                 }
5537             }
5538         }
5539 
5540         assertArraysStrictlyEquals(r, a);
5541     }
5542 
5543     @Test(dataProvider = "byteUnaryOpProvider")
5544     static void BroadcastByteMaxVectorTests(IntFunction<byte[]> fa) {
5545         byte[] a = fa.apply(SPECIES.length());
5546         byte[] r = new byte[a.length];
5547 
5548         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5549             for (int i = 0; i < a.length; i += SPECIES.length()) {
5550                 ByteVector.broadcast(SPECIES, a[i]).intoArray(r, i);
5551             }
5552         }
5553 
5554         assertBroadcastArraysEquals(r, a);
5555     }
5556 
5557     @Test(dataProvider = "byteUnaryOpProvider")
5558     static void ZeroByteMaxVectorTests(IntFunction<byte[]> fa) {
5559         byte[] a = fa.apply(SPECIES.length());
5560         byte[] r = new byte[a.length];
5561 
5562         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5563             for (int i = 0; i < a.length; i += SPECIES.length()) {
5564                 ByteVector.zero(SPECIES).intoArray(a, i);
5565             }
5566         }
5567 
5568         Assert.assertEquals(a, r);
5569     }
5570 
5571     static byte[] sliceUnary(byte[] a, int origin, int idx) {
5572         byte[] res = new byte[SPECIES.length()];
5573         for (int i = 0; i < SPECIES.length(); i++){
5574             if(i+origin < SPECIES.length())
5575                 res[i] = a[idx+i+origin];
5576             else
5577                 res[i] = (byte)0;
5578         }
5579         return res;
5580     }
5581 
5582     @Test(dataProvider = "byteUnaryOpProvider")
5583     static void sliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
5584         byte[] a = fa.apply(SPECIES.length());
5585         byte[] r = new byte[a.length];
5586         int origin = RAND.nextInt(SPECIES.length());
5587         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5588             for (int i = 0; i < a.length; i += SPECIES.length()) {
5589                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5590                 av.slice(origin).intoArray(r, i);
5591             }
5592         }
5593 
5594         assertArraysEquals(r, a, origin, ByteMaxVectorTests::sliceUnary);
5595     }
5596 
5597     static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) {
5598         byte[] res = new byte[SPECIES.length()];
5599         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5600             if(i+origin < SPECIES.length())
5601                 res[i] = a[idx+i+origin];
5602             else {
5603                 res[i] = b[idx+j];
5604                 j++;
5605             }
5606         }
5607         return res;
5608     }
5609 
5610     @Test(dataProvider = "byteBinaryOpProvider")
5611     static void sliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5612         byte[] a = fa.apply(SPECIES.length());
5613         byte[] b = fb.apply(SPECIES.length());
5614         byte[] r = new byte[a.length];
5615         int origin = RAND.nextInt(SPECIES.length());
5616         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5617             for (int i = 0; i < a.length; i += SPECIES.length()) {
5618                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5619                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5620                 av.slice(origin, bv).intoArray(r, i);
5621             }
5622         }
5623 
5624         assertArraysEquals(r, a, b, origin, ByteMaxVectorTests::sliceBinary);
5625     }
5626 
5627     static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) {
5628         byte[] res = new byte[SPECIES.length()];
5629         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5630             if(i+origin < SPECIES.length())
5631                 res[i] = mask[i] ? a[idx+i+origin] : (byte)0;
5632             else {
5633                 res[i] = mask[i] ? b[idx+j] : (byte)0;
5634                 j++;
5635             }
5636         }
5637         return res;
5638     }
5639 
5640     @Test(dataProvider = "byteBinaryOpMaskProvider")
5641     static void sliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5642     IntFunction<boolean[]> fm) {
5643         byte[] a = fa.apply(SPECIES.length());
5644         byte[] b = fb.apply(SPECIES.length());
5645         boolean[] mask = fm.apply(SPECIES.length());
5646         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5647 
5648         byte[] r = new byte[a.length];
5649         int origin = RAND.nextInt(SPECIES.length());
5650         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5651             for (int i = 0; i < a.length; i += SPECIES.length()) {
5652                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5653                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5654                 av.slice(origin, bv, vmask).intoArray(r, i);
5655             }
5656         }
5657 
5658         assertArraysEquals(r, a, b, origin, mask, ByteMaxVectorTests::slice);
5659     }
5660 
5661     static byte[] unsliceUnary(byte[] a, int origin, int idx) {
5662         byte[] res = new byte[SPECIES.length()];
5663         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5664             if(i < origin)
5665                 res[i] = (byte)0;
5666             else {
5667                 res[i] = a[idx+j];
5668                 j++;
5669             }
5670         }
5671         return res;
5672     }
5673 
5674     @Test(dataProvider = "byteUnaryOpProvider")
5675     static void unsliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
5676         byte[] a = fa.apply(SPECIES.length());
5677         byte[] r = new byte[a.length];
5678         int origin = RAND.nextInt(SPECIES.length());
5679         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5680             for (int i = 0; i < a.length; i += SPECIES.length()) {
5681                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5682                 av.unslice(origin).intoArray(r, i);
5683             }
5684         }
5685 
5686         assertArraysEquals(r, a, origin, ByteMaxVectorTests::unsliceUnary);
5687     }
5688 
5689     static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) {
5690         byte[] res = new byte[SPECIES.length()];
5691         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5692             if (part == 0) {
5693                 if (i < origin)
5694                     res[i] = b[idx+i];
5695                 else {
5696                     res[i] = a[idx+j];
5697                     j++;
5698                 }
5699             } else if (part == 1) {
5700                 if (i < origin)
5701                     res[i] = a[idx+SPECIES.length()-origin+i];
5702                 else {
5703                     res[i] = b[idx+origin+j];
5704                     j++;
5705                 }
5706             }
5707         }
5708         return res;
5709     }
5710 
5711     @Test(dataProvider = "byteBinaryOpProvider")
5712     static void unsliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5713         byte[] a = fa.apply(SPECIES.length());
5714         byte[] b = fb.apply(SPECIES.length());
5715         byte[] r = new byte[a.length];
5716         int origin = RAND.nextInt(SPECIES.length());
5717         int part = RAND.nextInt(2);
5718         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5719             for (int i = 0; i < a.length; i += SPECIES.length()) {
5720                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5721                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5722                 av.unslice(origin, bv, part).intoArray(r, i);
5723             }
5724         }
5725 
5726         assertArraysEquals(r, a, b, origin, part, ByteMaxVectorTests::unsliceBinary);
5727     }
5728 
5729     static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) {
5730         byte[] res = new byte[SPECIES.length()];
5731         for (int i = 0, j = 0; i < SPECIES.length(); i++){
5732             if(i+origin < SPECIES.length())
5733                 res[i] = b[idx+i+origin];
5734             else {
5735                 res[i] = b[idx+j];
5736                 j++;
5737             }
5738         }
5739         for (int i = 0; i < SPECIES.length(); i++){
5740             res[i] = mask[i] ? a[idx+i] : res[i];
5741         }
5742         byte[] res1 = new byte[SPECIES.length()];
5743         if (part == 0) {
5744             for (int i = 0, j = 0; i < SPECIES.length(); i++){
5745                 if (i < origin)
5746                     res1[i] = b[idx+i];
5747                 else {
5748                    res1[i] = res[j];
5749                    j++;
5750                 }
5751             }
5752         } else if (part == 1) {
5753             for (int i = 0, j = 0; i < SPECIES.length(); i++){
5754                 if (i < origin)
5755                     res1[i] = res[SPECIES.length()-origin+i];
5756                 else {
5757                     res1[i] = b[idx+origin+j];
5758                     j++;
5759                 }
5760             }
5761         }
5762         return res1;
5763     }
5764 
5765     @Test(dataProvider = "byteBinaryOpMaskProvider")
5766     static void unsliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5767     IntFunction<boolean[]> fm) {
5768         byte[] a = fa.apply(SPECIES.length());
5769         byte[] b = fb.apply(SPECIES.length());
5770         boolean[] mask = fm.apply(SPECIES.length());
5771         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5772         byte[] r = new byte[a.length];
5773         int origin = RAND.nextInt(SPECIES.length());
5774         int part = RAND.nextInt(2);
5775         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5776             for (int i = 0; i < a.length; i += SPECIES.length()) {
5777                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5778                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5779                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
5780             }
5781         }
5782 
5783         assertArraysEquals(r, a, b, origin, part, mask, ByteMaxVectorTests::unslice);
5784     }
5785 
5786     static byte BITWISE_BLEND(byte a, byte b, byte c) {
5787         return (byte)((a&~(c))|(b&c));
5788     }
5789 
5790     static byte bitwiseBlend(byte a, byte b, byte c) {
5791         return (byte)((a&~(c))|(b&c));
5792     }
5793 
5794     @Test(dataProvider = "byteTernaryOpProvider")
5795     static void BITWISE_BLENDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5796         byte[] a = fa.apply(SPECIES.length());
5797         byte[] b = fb.apply(SPECIES.length());
5798         byte[] c = fc.apply(SPECIES.length());
5799         byte[] r = fr.apply(SPECIES.length());
5800 
5801         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5802             for (int i = 0; i < a.length; i += SPECIES.length()) {
5803                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5804                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5805                 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5806                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5807             }
5808         }
5809 
5810         assertArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5811     }
5812 
5813     @Test(dataProvider = "byteTernaryOpProvider")
5814     static void bitwiseBlendByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5815         byte[] a = fa.apply(SPECIES.length());
5816         byte[] b = fb.apply(SPECIES.length());
5817         byte[] c = fc.apply(SPECIES.length());
5818         byte[] r = fr.apply(SPECIES.length());
5819 
5820         for (int i = 0; i < a.length; i += SPECIES.length()) {
5821             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5822             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5823             ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5824             av.bitwiseBlend(bv, cv).intoArray(r, i);
5825         }
5826 
5827         assertArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5828     }
5829 
5830     @Test(dataProvider = "byteTernaryOpMaskProvider")
5831     static void BITWISE_BLENDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5832                                           IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5833         byte[] a = fa.apply(SPECIES.length());
5834         byte[] b = fb.apply(SPECIES.length());
5835         byte[] c = fc.apply(SPECIES.length());
5836         byte[] r = fr.apply(SPECIES.length());
5837         boolean[] mask = fm.apply(SPECIES.length());
5838         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5839 
5840         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5841             for (int i = 0; i < a.length; i += SPECIES.length()) {
5842                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5843                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5844                 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5845                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5846             }
5847         }
5848 
5849         assertArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5850     }
5851 
5852     @Test(dataProvider = "byteTernaryOpProvider")
5853     static void BITWISE_BLENDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5854         byte[] a = fa.apply(SPECIES.length());
5855         byte[] b = fb.apply(SPECIES.length());
5856         byte[] c = fc.apply(SPECIES.length());
5857         byte[] r = fr.apply(SPECIES.length());
5858 
5859         for (int i = 0; i < a.length; i += SPECIES.length()) {
5860             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5861             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5862             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5863         }
5864         assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5865     }
5866 
5867     @Test(dataProvider = "byteTernaryOpProvider")
5868     static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5869         byte[] a = fa.apply(SPECIES.length());
5870         byte[] b = fb.apply(SPECIES.length());
5871         byte[] c = fc.apply(SPECIES.length());
5872         byte[] r = fr.apply(SPECIES.length());
5873 
5874         for (int i = 0; i < a.length; i += SPECIES.length()) {
5875             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5876             ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5877             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5878         }
5879         assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5880     }
5881 
5882     @Test(dataProvider = "byteTernaryOpProvider")
5883     static void bitwiseBlendByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5884         byte[] a = fa.apply(SPECIES.length());
5885         byte[] b = fb.apply(SPECIES.length());
5886         byte[] c = fc.apply(SPECIES.length());
5887         byte[] r = fr.apply(SPECIES.length());
5888 
5889         for (int i = 0; i < a.length; i += SPECIES.length()) {
5890             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5891             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5892             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5893         }
5894         assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5895     }
5896 
5897     @Test(dataProvider = "byteTernaryOpProvider")
5898     static void bitwiseBlendByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5899         byte[] a = fa.apply(SPECIES.length());
5900         byte[] b = fb.apply(SPECIES.length());
5901         byte[] c = fc.apply(SPECIES.length());
5902         byte[] r = fr.apply(SPECIES.length());
5903 
5904         for (int i = 0; i < a.length; i += SPECIES.length()) {
5905             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5906             ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5907             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5908         }
5909         assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5910     }
5911 
5912     @Test(dataProvider = "byteTernaryOpMaskProvider")
5913     static void BITWISE_BLENDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5914                                           IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5915         byte[] a = fa.apply(SPECIES.length());
5916         byte[] b = fb.apply(SPECIES.length());
5917         byte[] c = fc.apply(SPECIES.length());
5918         byte[] r = fr.apply(SPECIES.length());
5919         boolean[] mask = fm.apply(SPECIES.length());
5920         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5921 
5922         for (int i = 0; i < a.length; i += SPECIES.length()) {
5923             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5924             ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5925             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5926         }
5927 
5928         assertBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5929     }
5930 
5931     @Test(dataProvider = "byteTernaryOpMaskProvider")
5932     static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5933                                           IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5934         byte[] a = fa.apply(SPECIES.length());
5935         byte[] b = fb.apply(SPECIES.length());
5936         byte[] c = fc.apply(SPECIES.length());
5937         byte[] r = fr.apply(SPECIES.length());
5938         boolean[] mask = fm.apply(SPECIES.length());
5939         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5940 
5941         for (int i = 0; i < a.length; i += SPECIES.length()) {
5942             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5943             ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5944             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5945         }
5946 
5947         assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5948     }
5949 
5950     @Test(dataProvider = "byteTernaryOpProvider")
5951     static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5952         byte[] a = fa.apply(SPECIES.length());
5953         byte[] b = fb.apply(SPECIES.length());
5954         byte[] c = fc.apply(SPECIES.length());
5955         byte[] r = fr.apply(SPECIES.length());
5956 
5957         for (int i = 0; i < a.length; i += SPECIES.length()) {
5958             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5959             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5960         }
5961 
5962         assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5963     }
5964 
5965     @Test(dataProvider = "byteTernaryOpProvider")
5966     static void bitwiseBlendByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5967         byte[] a = fa.apply(SPECIES.length());
5968         byte[] b = fb.apply(SPECIES.length());
5969         byte[] c = fc.apply(SPECIES.length());
5970         byte[] r = fr.apply(SPECIES.length());
5971 
5972         for (int i = 0; i < a.length; i += SPECIES.length()) {
5973             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5974             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5975         }
5976 
5977         assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5978     }
5979 
5980     @Test(dataProvider = "byteTernaryOpMaskProvider")
5981     static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5982                                           IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5983         byte[] a = fa.apply(SPECIES.length());
5984         byte[] b = fb.apply(SPECIES.length());
5985         byte[] c = fc.apply(SPECIES.length());
5986         byte[] r = fr.apply(SPECIES.length());
5987         boolean[] mask = fm.apply(SPECIES.length());
5988         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5989 
5990         for (int i = 0; i < a.length; i += SPECIES.length()) {
5991             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5992             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5993         }
5994 
5995         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5996     }
5997 
5998     static byte NEG(byte a) {
5999         return (byte)(-((byte)a));
6000     }
6001 
6002     static byte neg(byte a) {
6003         return (byte)(-((byte)a));
6004     }
6005 
6006     @Test(dataProvider = "byteUnaryOpProvider")
6007     static void NEGByteMaxVectorTests(IntFunction<byte[]> fa) {
6008         byte[] a = fa.apply(SPECIES.length());
6009         byte[] r = fr.apply(SPECIES.length());
6010 
6011         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6012             for (int i = 0; i < a.length; i += SPECIES.length()) {
6013                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6014                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
6015             }
6016         }
6017 
6018         assertArraysEquals(r, a, ByteMaxVectorTests::NEG);
6019     }
6020 
6021     @Test(dataProvider = "byteUnaryOpProvider")
6022     static void negByteMaxVectorTests(IntFunction<byte[]> fa) {
6023         byte[] a = fa.apply(SPECIES.length());
6024         byte[] r = fr.apply(SPECIES.length());
6025 
6026         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6027             for (int i = 0; i < a.length; i += SPECIES.length()) {
6028                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6029                 av.neg().intoArray(r, i);
6030             }
6031         }
6032 
6033         assertArraysEquals(r, a, ByteMaxVectorTests::neg);
6034     }
6035 
6036     @Test(dataProvider = "byteUnaryOpMaskProvider")
6037     static void NEGMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6038                                                 IntFunction<boolean[]> fm) {
6039         byte[] a = fa.apply(SPECIES.length());
6040         byte[] r = fr.apply(SPECIES.length());
6041         boolean[] mask = fm.apply(SPECIES.length());
6042         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6043 
6044         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6045             for (int i = 0; i < a.length; i += SPECIES.length()) {
6046                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6047                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
6048             }
6049         }
6050 
6051         assertArraysEquals(r, a, mask, ByteMaxVectorTests::NEG);
6052     }
6053 
6054     static byte ABS(byte a) {
6055         return (byte)(Math.abs((byte)a));
6056     }
6057 
6058     static byte abs(byte a) {
6059         return (byte)(Math.abs((byte)a));
6060     }
6061 
6062     @Test(dataProvider = "byteUnaryOpProvider")
6063     static void ABSByteMaxVectorTests(IntFunction<byte[]> fa) {
6064         byte[] a = fa.apply(SPECIES.length());
6065         byte[] r = fr.apply(SPECIES.length());
6066 
6067         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6068             for (int i = 0; i < a.length; i += SPECIES.length()) {
6069                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6070                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
6071             }
6072         }
6073 
6074         assertArraysEquals(r, a, ByteMaxVectorTests::ABS);
6075     }
6076 
6077     @Test(dataProvider = "byteUnaryOpProvider")
6078     static void absByteMaxVectorTests(IntFunction<byte[]> fa) {
6079         byte[] a = fa.apply(SPECIES.length());
6080         byte[] r = fr.apply(SPECIES.length());
6081 
6082         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6083             for (int i = 0; i < a.length; i += SPECIES.length()) {
6084                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6085                 av.abs().intoArray(r, i);
6086             }
6087         }
6088 
6089         assertArraysEquals(r, a, ByteMaxVectorTests::abs);
6090     }
6091 
6092     @Test(dataProvider = "byteUnaryOpMaskProvider")
6093     static void ABSMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6094                                                 IntFunction<boolean[]> fm) {
6095         byte[] a = fa.apply(SPECIES.length());
6096         byte[] r = fr.apply(SPECIES.length());
6097         boolean[] mask = fm.apply(SPECIES.length());
6098         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6099 
6100         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6101             for (int i = 0; i < a.length; i += SPECIES.length()) {
6102                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6103                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
6104             }
6105         }
6106 
6107         assertArraysEquals(r, a, mask, ByteMaxVectorTests::ABS);
6108     }
6109 
6110     static byte NOT(byte a) {
6111         return (byte)(~((byte)a));
6112     }
6113 
6114     static byte not(byte a) {
6115         return (byte)(~((byte)a));
6116     }
6117 
6118     @Test(dataProvider = "byteUnaryOpProvider")
6119     static void NOTByteMaxVectorTests(IntFunction<byte[]> fa) {
6120         byte[] a = fa.apply(SPECIES.length());
6121         byte[] r = fr.apply(SPECIES.length());
6122 
6123         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6124             for (int i = 0; i < a.length; i += SPECIES.length()) {
6125                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6126                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
6127             }
6128         }
6129 
6130         assertArraysEquals(r, a, ByteMaxVectorTests::NOT);
6131     }
6132 
6133     @Test(dataProvider = "byteUnaryOpProvider")
6134     static void notByteMaxVectorTests(IntFunction<byte[]> fa) {
6135         byte[] a = fa.apply(SPECIES.length());
6136         byte[] r = fr.apply(SPECIES.length());
6137 
6138         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6139             for (int i = 0; i < a.length; i += SPECIES.length()) {
6140                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6141                 av.not().intoArray(r, i);
6142             }
6143         }
6144 
6145         assertArraysEquals(r, a, ByteMaxVectorTests::not);
6146     }
6147 
6148     @Test(dataProvider = "byteUnaryOpMaskProvider")
6149     static void NOTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6150                                                 IntFunction<boolean[]> fm) {
6151         byte[] a = fa.apply(SPECIES.length());
6152         byte[] r = fr.apply(SPECIES.length());
6153         boolean[] mask = fm.apply(SPECIES.length());
6154         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6155 
6156         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6157             for (int i = 0; i < a.length; i += SPECIES.length()) {
6158                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6159                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
6160             }
6161         }
6162 
6163         assertArraysEquals(r, a, mask, ByteMaxVectorTests::NOT);
6164     }
6165 
6166     static byte ZOMO(byte a) {
6167         return (byte)((a==0?0:-1));
6168     }
6169 
6170     @Test(dataProvider = "byteUnaryOpProvider")
6171     static void ZOMOByteMaxVectorTests(IntFunction<byte[]> fa) {
6172         byte[] a = fa.apply(SPECIES.length());
6173         byte[] r = fr.apply(SPECIES.length());
6174 
6175         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6176             for (int i = 0; i < a.length; i += SPECIES.length()) {
6177                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6178                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
6179             }
6180         }
6181 
6182         assertArraysEquals(r, a, ByteMaxVectorTests::ZOMO);
6183     }
6184 
6185     @Test(dataProvider = "byteUnaryOpMaskProvider")
6186     static void ZOMOMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6187                                                 IntFunction<boolean[]> fm) {
6188         byte[] a = fa.apply(SPECIES.length());
6189         byte[] r = fr.apply(SPECIES.length());
6190         boolean[] mask = fm.apply(SPECIES.length());
6191         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6192 
6193         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6194             for (int i = 0; i < a.length; i += SPECIES.length()) {
6195                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6196                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
6197             }
6198         }
6199 
6200         assertArraysEquals(r, a, mask, ByteMaxVectorTests::ZOMO);
6201     }
6202 
6203     static byte BIT_COUNT(byte a) {
6204         return (byte)(Integer.bitCount((int)a & 0xFF));
6205     }
6206 
6207     @Test(dataProvider = "byteUnaryOpProvider")
6208     static void BIT_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
6209         byte[] a = fa.apply(SPECIES.length());
6210         byte[] r = fr.apply(SPECIES.length());
6211 
6212         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6213             for (int i = 0; i < a.length; i += SPECIES.length()) {
6214                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6215                 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
6216             }
6217         }
6218 
6219         assertArraysEquals(r, a, ByteMaxVectorTests::BIT_COUNT);
6220     }
6221 
6222     @Test(dataProvider = "byteUnaryOpMaskProvider")
6223     static void BIT_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6224                                                 IntFunction<boolean[]> fm) {
6225         byte[] a = fa.apply(SPECIES.length());
6226         byte[] r = fr.apply(SPECIES.length());
6227         boolean[] mask = fm.apply(SPECIES.length());
6228         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6229 
6230         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6231             for (int i = 0; i < a.length; i += SPECIES.length()) {
6232                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6233                 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
6234             }
6235         }
6236 
6237         assertArraysEquals(r, a, mask, ByteMaxVectorTests::BIT_COUNT);
6238     }
6239 
6240     static byte TRAILING_ZEROS_COUNT(byte a) {
6241         return (byte)(TRAILING_ZEROS_COUNT_scalar(a));
6242     }
6243 
6244     @Test(dataProvider = "byteUnaryOpProvider")
6245     static void TRAILING_ZEROS_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
6246         byte[] a = fa.apply(SPECIES.length());
6247         byte[] r = fr.apply(SPECIES.length());
6248 
6249         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6250             for (int i = 0; i < a.length; i += SPECIES.length()) {
6251                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6252                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
6253             }
6254         }
6255 
6256         assertArraysEquals(r, a, ByteMaxVectorTests::TRAILING_ZEROS_COUNT);
6257     }
6258 
6259     @Test(dataProvider = "byteUnaryOpMaskProvider")
6260     static void TRAILING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6261                                                 IntFunction<boolean[]> fm) {
6262         byte[] a = fa.apply(SPECIES.length());
6263         byte[] r = fr.apply(SPECIES.length());
6264         boolean[] mask = fm.apply(SPECIES.length());
6265         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6266 
6267         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6268             for (int i = 0; i < a.length; i += SPECIES.length()) {
6269                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6270                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
6271             }
6272         }
6273 
6274         assertArraysEquals(r, a, mask, ByteMaxVectorTests::TRAILING_ZEROS_COUNT);
6275     }
6276 
6277     static byte LEADING_ZEROS_COUNT(byte a) {
6278         return (byte)(LEADING_ZEROS_COUNT_scalar(a));
6279     }
6280 
6281     @Test(dataProvider = "byteUnaryOpProvider")
6282     static void LEADING_ZEROS_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
6283         byte[] a = fa.apply(SPECIES.length());
6284         byte[] r = fr.apply(SPECIES.length());
6285 
6286         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6287             for (int i = 0; i < a.length; i += SPECIES.length()) {
6288                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6289                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
6290             }
6291         }
6292 
6293         assertArraysEquals(r, a, ByteMaxVectorTests::LEADING_ZEROS_COUNT);
6294     }
6295 
6296     @Test(dataProvider = "byteUnaryOpMaskProvider")
6297     static void LEADING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6298                                                 IntFunction<boolean[]> fm) {
6299         byte[] a = fa.apply(SPECIES.length());
6300         byte[] r = fr.apply(SPECIES.length());
6301         boolean[] mask = fm.apply(SPECIES.length());
6302         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6303 
6304         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6305             for (int i = 0; i < a.length; i += SPECIES.length()) {
6306                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6307                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
6308             }
6309         }
6310 
6311         assertArraysEquals(r, a, mask, ByteMaxVectorTests::LEADING_ZEROS_COUNT);
6312     }
6313 
6314     static byte REVERSE(byte a) {
6315         return (byte)(REVERSE_scalar(a));
6316     }
6317 
6318     @Test(dataProvider = "byteUnaryOpProvider")
6319     static void REVERSEByteMaxVectorTests(IntFunction<byte[]> fa) {
6320         byte[] a = fa.apply(SPECIES.length());
6321         byte[] r = fr.apply(SPECIES.length());
6322 
6323         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6324             for (int i = 0; i < a.length; i += SPECIES.length()) {
6325                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6326                 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
6327             }
6328         }
6329 
6330         assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE);
6331     }
6332 
6333     @Test(dataProvider = "byteUnaryOpMaskProvider")
6334     static void REVERSEMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6335                                                 IntFunction<boolean[]> fm) {
6336         byte[] a = fa.apply(SPECIES.length());
6337         byte[] r = fr.apply(SPECIES.length());
6338         boolean[] mask = fm.apply(SPECIES.length());
6339         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6340 
6341         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6342             for (int i = 0; i < a.length; i += SPECIES.length()) {
6343                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6344                 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
6345             }
6346         }
6347 
6348         assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE);
6349     }
6350 
6351     static byte REVERSE_BYTES(byte a) {
6352         return (byte)(a);
6353     }
6354 
6355     @Test(dataProvider = "byteUnaryOpProvider")
6356     static void REVERSE_BYTESByteMaxVectorTests(IntFunction<byte[]> fa) {
6357         byte[] a = fa.apply(SPECIES.length());
6358         byte[] r = fr.apply(SPECIES.length());
6359 
6360         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6361             for (int i = 0; i < a.length; i += SPECIES.length()) {
6362                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6363                 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
6364             }
6365         }
6366 
6367         assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE_BYTES);
6368     }
6369 
6370     @Test(dataProvider = "byteUnaryOpMaskProvider")
6371     static void REVERSE_BYTESMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
6372                                                 IntFunction<boolean[]> fm) {
6373         byte[] a = fa.apply(SPECIES.length());
6374         byte[] r = fr.apply(SPECIES.length());
6375         boolean[] mask = fm.apply(SPECIES.length());
6376         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6377 
6378         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6379             for (int i = 0; i < a.length; i += SPECIES.length()) {
6380                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6381                 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
6382             }
6383         }
6384 
6385         assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE_BYTES);
6386     }
6387 
6388     @Test(dataProvider = "byteCompareOpProvider")
6389     static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
6390         byte[] a = fa.apply(SPECIES.length());
6391         byte[] b = fb.apply(SPECIES.length());
6392 
6393         for (int i = 0; i < a.length; i += SPECIES.length()) {
6394             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6395             VectorMask<Byte> mv = av.lt(b[i]);
6396 
6397             // Check results as part of computation.
6398             for (int j = 0; j < SPECIES.length(); j++) {
6399                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
6400             }
6401         }
6402     }
6403 
6404     @Test(dataProvider = "byteCompareOpProvider")
6405     static void eqByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
6406         byte[] a = fa.apply(SPECIES.length());
6407         byte[] b = fb.apply(SPECIES.length());
6408 
6409         for (int i = 0; i < a.length; i += SPECIES.length()) {
6410             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6411             VectorMask<Byte> mv = av.eq(b[i]);
6412 
6413             // Check results as part of computation.
6414             for (int j = 0; j < SPECIES.length(); j++) {
6415                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
6416             }
6417         }
6418     }
6419 
6420     @Test(dataProvider = "byteUnaryOpProvider")
6421     static void toIntArrayByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6422         byte[] a = fa.apply(SPECIES.length());
6423 
6424         for (int i = 0; i < a.length; i += SPECIES.length()) {
6425             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6426             int[] r = av.toIntArray();
6427             assertArraysEquals(r, a, i);
6428         }
6429     }
6430 
6431     @Test(dataProvider = "byteUnaryOpProvider")
6432     static void toLongArrayByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6433         byte[] a = fa.apply(SPECIES.length());
6434 
6435         for (int i = 0; i < a.length; i += SPECIES.length()) {
6436             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6437             long[] r = av.toLongArray();
6438             assertArraysEquals(r, a, i);
6439         }
6440     }
6441 
6442     @Test(dataProvider = "byteUnaryOpProvider")
6443     static void toDoubleArrayByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6444         byte[] a = fa.apply(SPECIES.length());
6445 
6446         for (int i = 0; i < a.length; i += SPECIES.length()) {
6447             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6448             double[] r = av.toDoubleArray();
6449             assertArraysEquals(r, a, i);
6450         }
6451     }
6452 
6453     @Test(dataProvider = "byteUnaryOpProvider")
6454     static void toStringByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6455         byte[] a = fa.apply(SPECIES.length());
6456 
6457         for (int i = 0; i < a.length; i += SPECIES.length()) {
6458             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6459             String str = av.toString();
6460 
6461             byte subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6462             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6463         }
6464     }
6465 
6466     @Test(dataProvider = "byteUnaryOpProvider")
6467     static void hashCodeByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6468         byte[] a = fa.apply(SPECIES.length());
6469 
6470         for (int i = 0; i < a.length; i += SPECIES.length()) {
6471             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6472             int hash = av.hashCode();
6473 
6474             byte subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6475             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6476             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6477         }
6478     }
6479 
6480     @Test(dataProvider = "byteUnaryOpProvider")
6481     static void reinterpretAsBytesByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6482         byte[] a = fa.apply(SPECIES.length());
6483         byte[] r = new byte[a.length];
6484 
6485         for (int i = 0; i < a.length; i += SPECIES.length()) {
6486             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6487             av.reinterpretAsBytes().intoArray(r, i);
6488         }
6489         assertArraysEquals(r, a, 0);
6490     }
6491 
6492     static long ADDReduceLong(byte[] a, int idx) {
6493         byte res = 0;
6494         for (int i = idx; i < (idx + SPECIES.length()); i++) {
6495             res += a[i];
6496         }
6497 
6498         return (long)res;
6499     }
6500 
6501     static long ADDReduceAllLong(byte[] a) {
6502         long res = 0;
6503         for (int i = 0; i < a.length; i += SPECIES.length()) {
6504             res += ADDReduceLong(a, i);
6505         }
6506 
6507         return res;
6508     }
6509 
6510     @Test(dataProvider = "byteUnaryOpProvider")
6511     static void ADDReduceLongByteMaxVectorTests(IntFunction<byte[]> fa) {
6512         byte[] a = fa.apply(SPECIES.length());
6513         long[] r = lfr.apply(SPECIES.length());
6514         long ra = 0;
6515 
6516         for (int i = 0; i < a.length; i += SPECIES.length()) {
6517             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6518             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
6519         }
6520 
6521         ra = 0;
6522         for (int i = 0; i < a.length; i ++) {
6523             ra += r[i];
6524         }
6525 
6526         assertReductionLongArraysEquals(r, ra, a,
6527                 ByteMaxVectorTests::ADDReduceLong, ByteMaxVectorTests::ADDReduceAllLong);
6528     }
6529 
6530     static long ADDReduceLongMasked(byte[] a, int idx, boolean[] mask) {
6531         byte res = 0;
6532         for (int i = idx; i < (idx + SPECIES.length()); i++) {
6533             if(mask[i % SPECIES.length()])
6534                 res += a[i];
6535         }
6536 
6537         return (long)res;
6538     }
6539 
6540     static long ADDReduceAllLongMasked(byte[] a, boolean[] mask) {
6541         long res = 0;
6542         for (int i = 0; i < a.length; i += SPECIES.length()) {
6543             res += ADDReduceLongMasked(a, i, mask);
6544         }
6545 
6546         return res;
6547     }
6548 
6549     @Test(dataProvider = "byteUnaryOpMaskProvider")
6550     static void ADDReduceLongByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
6551         byte[] a = fa.apply(SPECIES.length());
6552         long[] r = lfr.apply(SPECIES.length());
6553         boolean[] mask = fm.apply(SPECIES.length());
6554         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6555         long ra = 0;
6556 
6557         for (int i = 0; i < a.length; i += SPECIES.length()) {
6558             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6559             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
6560         }
6561 
6562         ra = 0;
6563         for (int i = 0; i < a.length; i ++) {
6564             ra += r[i];
6565         }
6566 
6567         assertReductionLongArraysEqualsMasked(r, ra, a, mask,
6568                 ByteMaxVectorTests::ADDReduceLongMasked, ByteMaxVectorTests::ADDReduceAllLongMasked);
6569     }
6570 
6571     @Test(dataProvider = "byteUnaryOpProvider")
6572     static void BroadcastLongByteMaxVectorTestsSmokeTest(IntFunction<byte[]> fa) {
6573         byte[] a = fa.apply(SPECIES.length());
6574         byte[] r = new byte[a.length];
6575 
6576         for (int i = 0; i < a.length; i += SPECIES.length()) {
6577             ByteVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
6578         }
6579         assertBroadcastArraysEquals(r, a);
6580     }
6581 
6582     @Test(dataProvider = "byteBinaryOpMaskProvider")
6583     static void blendByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
6584                                           IntFunction<boolean[]> fm) {
6585         byte[] a = fa.apply(SPECIES.length());
6586         byte[] b = fb.apply(SPECIES.length());
6587         byte[] r = fr.apply(SPECIES.length());
6588         boolean[] mask = fm.apply(SPECIES.length());
6589         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6590 
6591         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6592             for (int i = 0; i < a.length; i += SPECIES.length()) {
6593                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6594                 av.blend((long)b[i], vmask).intoArray(r, i);
6595             }
6596         }
6597         assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::blend);
6598     }
6599 
6600 
6601     @Test(dataProvider = "byteUnaryOpSelectFromProvider")
6602     static void SelectFromByteMaxVectorTests(IntFunction<byte[]> fa,
6603                                            BiFunction<Integer,Integer,byte[]> fs) {
6604         byte[] a = fa.apply(SPECIES.length());
6605         byte[] order = fs.apply(a.length, SPECIES.length());
6606         byte[] r = fr.apply(SPECIES.length());
6607 
6608         for (int i = 0; i < a.length; i += SPECIES.length()) {
6609             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6610             ByteVector bv = ByteVector.fromArray(SPECIES, order, i);
6611             bv.selectFrom(av).intoArray(r, i);
6612         }
6613 
6614         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
6615     }
6616 
6617     @Test(dataProvider = "byteSelectFromTwoVectorOpProvider")
6618     static void SelectFromTwoVectorByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
6619         byte[] a = fa.apply(SPECIES.length());
6620         byte[] b = fb.apply(SPECIES.length());
6621         byte[] idx = fc.apply(SPECIES.length());
6622         byte[] r = fr.apply(SPECIES.length());
6623 
6624         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6625             for (int i = 0; i < idx.length; i += SPECIES.length()) {
6626                 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6627                 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
6628                 ByteVector idxv = ByteVector.fromArray(SPECIES, idx, i);
6629                 idxv.selectFrom(av, bv).intoArray(r, i);
6630             }
6631         }
6632         assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length());
6633     }
6634 
6635     @Test(dataProvider = "byteUnaryOpSelectFromMaskProvider")
6636     static void SelectFromByteMaxVectorTestsMaskedSmokeTest(IntFunction<byte[]> fa,
6637                                                            BiFunction<Integer,Integer,byte[]> fs,
6638                                                            IntFunction<boolean[]> fm) {
6639         byte[] a = fa.apply(SPECIES.length());
6640         byte[] order = fs.apply(a.length, SPECIES.length());
6641         byte[] r = fr.apply(SPECIES.length());
6642         boolean[] mask = fm.apply(SPECIES.length());
6643         VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6644 
6645         for (int i = 0; i < a.length; i += SPECIES.length()) {
6646             ByteVector av = ByteVector.fromArray(SPECIES, a, i);
6647             ByteVector bv = ByteVector.fromArray(SPECIES, order, i);
6648             bv.selectFrom(av, vmask).intoArray(r, i);
6649         }
6650 
6651         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
6652     }
6653 
6654     @Test(dataProvider = "shuffleProvider")
6655     static void shuffleMiscellaneousByteMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6656         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6657 
6658         for (int i = 0; i < a.length; i += SPECIES.length()) {
6659             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6660             int hash = shuffle.hashCode();
6661             int length = shuffle.length();
6662 
6663             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6664             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6665             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6666             Assert.assertEquals(length, SPECIES.length());
6667         }
6668     }
6669 
6670     @Test(dataProvider = "shuffleProvider")
6671     static void shuffleToStringByteMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6672         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6673 
6674         for (int i = 0; i < a.length; i += SPECIES.length()) {
6675             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6676             String str = shuffle.toString();
6677 
6678             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6679             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
6680                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6681         }
6682     }
6683 
6684     @Test(dataProvider = "shuffleCompareOpProvider")
6685     static void shuffleEqualsByteMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
6686         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6687         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6688 
6689         for (int i = 0; i < a.length; i += SPECIES.length()) {
6690             var av = VectorShuffle.fromArray(SPECIES, a, i);
6691             var bv = VectorShuffle.fromArray(SPECIES, b, i);
6692             boolean eq = av.equals(bv);
6693             int to = i + SPECIES.length();
6694             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
6695         }
6696     }
6697 
6698     @Test(dataProvider = "maskCompareOpProvider")
6699     static void maskEqualsByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6700         boolean[] a = fa.apply(SPECIES.length());
6701         boolean[] b = fb.apply(SPECIES.length());
6702 
6703         for (int i = 0; i < a.length; i += SPECIES.length()) {
6704             var av = SPECIES.loadMask(a, i);
6705             var bv = SPECIES.loadMask(b, i);
6706             boolean equals = av.equals(bv);
6707             int to = i + SPECIES.length();
6708             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
6709         }
6710     }
6711 
6712     static boolean band(boolean a, boolean b) {
6713         return a & b;
6714     }
6715 
6716     @Test(dataProvider = "maskCompareOpProvider")
6717     static void maskAndByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6718         boolean[] a = fa.apply(SPECIES.length());
6719         boolean[] b = fb.apply(SPECIES.length());
6720         boolean[] r = new boolean[a.length];
6721 
6722         for (int i = 0; i < a.length; i += SPECIES.length()) {
6723             var av = SPECIES.loadMask(a, i);
6724             var bv = SPECIES.loadMask(b, i);
6725             var cv = av.and(bv);
6726             cv.intoArray(r, i);
6727         }
6728         assertArraysEquals(r, a, b, ByteMaxVectorTests::band);
6729     }
6730 
6731     static boolean bor(boolean a, boolean b) {
6732         return a | b;
6733     }
6734 
6735     @Test(dataProvider = "maskCompareOpProvider")
6736     static void maskOrByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6737         boolean[] a = fa.apply(SPECIES.length());
6738         boolean[] b = fb.apply(SPECIES.length());
6739         boolean[] r = new boolean[a.length];
6740 
6741         for (int i = 0; i < a.length; i += SPECIES.length()) {
6742             var av = SPECIES.loadMask(a, i);
6743             var bv = SPECIES.loadMask(b, i);
6744             var cv = av.or(bv);
6745             cv.intoArray(r, i);
6746         }
6747         assertArraysEquals(r, a, b, ByteMaxVectorTests::bor);
6748     }
6749 
6750     static boolean bxor(boolean a, boolean b) {
6751         return a != b;
6752     }
6753 
6754     @Test(dataProvider = "maskCompareOpProvider")
6755     static void maskXorByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6756         boolean[] a = fa.apply(SPECIES.length());
6757         boolean[] b = fb.apply(SPECIES.length());
6758         boolean[] r = new boolean[a.length];
6759 
6760         for (int i = 0; i < a.length; i += SPECIES.length()) {
6761             var av = SPECIES.loadMask(a, i);
6762             var bv = SPECIES.loadMask(b, i);
6763             var cv = av.xor(bv);
6764             cv.intoArray(r, i);
6765         }
6766         assertArraysEquals(r, a, b, ByteMaxVectorTests::bxor);
6767     }
6768 
6769     static boolean bandNot(boolean a, boolean b) {
6770         return a & !b;
6771     }
6772 
6773     @Test(dataProvider = "maskCompareOpProvider")
6774     static void maskAndNotByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6775         boolean[] a = fa.apply(SPECIES.length());
6776         boolean[] b = fb.apply(SPECIES.length());
6777         boolean[] r = new boolean[a.length];
6778 
6779         for (int i = 0; i < a.length; i += SPECIES.length()) {
6780             var av = SPECIES.loadMask(a, i);
6781             var bv = SPECIES.loadMask(b, i);
6782             var cv = av.andNot(bv);
6783             cv.intoArray(r, i);
6784         }
6785         assertArraysEquals(r, a, b, ByteMaxVectorTests::bandNot);
6786     }
6787 
6788     static boolean beq(boolean a, boolean b) {
6789         return (a == b);
6790     }
6791 
6792     @Test(dataProvider = "maskCompareOpProvider")
6793     static void maskEqByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6794         boolean[] a = fa.apply(SPECIES.length());
6795         boolean[] b = fb.apply(SPECIES.length());
6796         boolean[] r = new boolean[a.length];
6797 
6798         for (int i = 0; i < a.length; i += SPECIES.length()) {
6799             var av = SPECIES.loadMask(a, i);
6800             var bv = SPECIES.loadMask(b, i);
6801             var cv = av.eq(bv);
6802             cv.intoArray(r, i);
6803         }
6804         assertArraysEquals(r, a, b, ByteMaxVectorTests::beq);
6805     }
6806 
6807     @Test(dataProvider = "maskProvider")
6808     static void maskHashCodeByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6809         boolean[] a = fa.apply(SPECIES.length());
6810 
6811         for (int i = 0; i < a.length; i += SPECIES.length()) {
6812             var vmask = SPECIES.loadMask(a, i);
6813             int hash = vmask.hashCode();
6814 
6815             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6816             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6817             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6818         }
6819     }
6820 
6821     static int maskTrueCount(boolean[] a, int idx) {
6822         int trueCount = 0;
6823         for (int i = idx; i < idx + SPECIES.length(); i++) {
6824             trueCount += a[i] ? 1 : 0;
6825         }
6826         return trueCount;
6827     }
6828 
6829     @Test(dataProvider = "maskProvider")
6830     static void maskTrueCountByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6831         boolean[] a = fa.apply(SPECIES.length());
6832         int[] r = new int[a.length];
6833 
6834         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6835             for (int i = 0; i < a.length; i += SPECIES.length()) {
6836                 var vmask = SPECIES.loadMask(a, i);
6837                 r[i] = vmask.trueCount();
6838             }
6839         }
6840 
6841         assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskTrueCount);
6842     }
6843 
6844     static int maskLastTrue(boolean[] a, int idx) {
6845         int i = idx + SPECIES.length() - 1;
6846         for (; i >= idx; i--) {
6847             if (a[i]) {
6848                 break;
6849             }
6850         }
6851         return i - idx;
6852     }
6853 
6854     @Test(dataProvider = "maskProvider")
6855     static void maskLastTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6856         boolean[] a = fa.apply(SPECIES.length());
6857         int[] r = new int[a.length];
6858 
6859         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6860             for (int i = 0; i < a.length; i += SPECIES.length()) {
6861                 var vmask = SPECIES.loadMask(a, i);
6862                 r[i] = vmask.lastTrue();
6863             }
6864         }
6865 
6866         assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskLastTrue);
6867     }
6868 
6869     static int maskFirstTrue(boolean[] a, int idx) {
6870         int i = idx;
6871         for (; i < idx + SPECIES.length(); i++) {
6872             if (a[i]) {
6873                 break;
6874             }
6875         }
6876         return i - idx;
6877     }
6878 
6879     @Test(dataProvider = "maskProvider")
6880     static void maskFirstTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6881         boolean[] a = fa.apply(SPECIES.length());
6882         int[] r = new int[a.length];
6883 
6884         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6885             for (int i = 0; i < a.length; i += SPECIES.length()) {
6886                 var vmask = SPECIES.loadMask(a, i);
6887                 r[i] = vmask.firstTrue();
6888             }
6889         }
6890 
6891         assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskFirstTrue);
6892     }
6893 
6894     @Test(dataProvider = "maskProvider")
6895     static void maskCompressByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6896         int trueCount = 0;
6897         boolean[] a = fa.apply(SPECIES.length());
6898 
6899         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6900             for (int i = 0; i < a.length; i += SPECIES.length()) {
6901                 var vmask = SPECIES.loadMask(a, i);
6902                 trueCount = vmask.trueCount();
6903                 var rmask = vmask.compress();
6904                 for (int j = 0; j < SPECIES.length(); j++)  {
6905                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
6906                 }
6907             }
6908         }
6909     }
6910 
6911 
6912     @DataProvider
6913     public static Object[][] offsetProvider() {
6914         return new Object[][]{
6915                 {0},
6916                 {-1},
6917                 {+1},
6918                 {+2},
6919                 {-2},
6920         };
6921     }
6922 
6923     @Test(dataProvider = "offsetProvider")
6924     static void indexInRangeByteMaxVectorTestsSmokeTest(int offset) {
6925         int limit = SPECIES.length() * BUFFER_REPS;
6926         for (int i = 0; i < limit; i += SPECIES.length()) {
6927             var actualMask = SPECIES.indexInRange(i + offset, limit);
6928             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6929             assert(actualMask.equals(expectedMask));
6930             for (int j = 0; j < SPECIES.length(); j++)  {
6931                 int index = i + j + offset;
6932                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6933             }
6934         }
6935     }
6936 
6937     @Test(dataProvider = "offsetProvider")
6938     static void indexInRangeLongByteMaxVectorTestsSmokeTest(int offset) {
6939         long limit = SPECIES.length() * BUFFER_REPS;
6940         for (long i = 0; i < limit; i += SPECIES.length()) {
6941             var actualMask = SPECIES.indexInRange(i + offset, limit);
6942             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6943             assert(actualMask.equals(expectedMask));
6944             for (int j = 0; j < SPECIES.length(); j++)  {
6945                 long index = i + j + offset;
6946                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6947             }
6948         }
6949     }
6950 
6951     @DataProvider
6952     public static Object[][] lengthProvider() {
6953         return new Object[][]{
6954                 {0},
6955                 {1},
6956                 {32},
6957                 {37},
6958                 {1024},
6959                 {1024+1},
6960                 {1024+5},
6961         };
6962     }
6963 
6964     @Test(dataProvider = "lengthProvider")
6965     static void loopBoundByteMaxVectorTestsSmokeTest(int length) {
6966         int actualLoopBound = SPECIES.loopBound(length);
6967         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6968         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6969     }
6970 
6971     @Test(dataProvider = "lengthProvider")
6972     static void loopBoundLongByteMaxVectorTestsSmokeTest(int _length) {
6973         long length = _length;
6974         long actualLoopBound = SPECIES.loopBound(length);
6975         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6976         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6977     }
6978 
6979     @Test
6980     static void ElementSizeByteMaxVectorTestsSmokeTest() {
6981         ByteVector av = ByteVector.zero(SPECIES);
6982         int elsize = av.elementSize();
6983         Assert.assertEquals(elsize, Byte.SIZE);
6984     }
6985 
6986     @Test
6987     static void VectorShapeByteMaxVectorTestsSmokeTest() {
6988         ByteVector av = ByteVector.zero(SPECIES);
6989         VectorShape vsh = av.shape();
6990         assert(vsh.equals(VectorShape.S_Max_BIT));
6991     }
6992 
6993     @Test
6994     static void ShapeWithLanesByteMaxVectorTestsSmokeTest() {
6995         ByteVector av = ByteVector.zero(SPECIES);
6996         VectorShape vsh = av.shape();
6997         VectorSpecies species = vsh.withLanes(byte.class);
6998         assert(species.equals(SPECIES));
6999     }
7000 
7001     @Test
7002     static void ElementTypeByteMaxVectorTestsSmokeTest() {
7003         ByteVector av = ByteVector.zero(SPECIES);
7004         assert(av.species().elementType() == byte.class);
7005     }
7006 
7007     @Test
7008     static void SpeciesElementSizeByteMaxVectorTestsSmokeTest() {
7009         ByteVector av = ByteVector.zero(SPECIES);
7010         assert(av.species().elementSize() == Byte.SIZE);
7011     }
7012 
7013     @Test
7014     static void VectorTypeByteMaxVectorTestsSmokeTest() {
7015         ByteVector av = ByteVector.zero(SPECIES);
7016         assert(av.species().vectorType() == av.getClass());
7017     }
7018 
7019     @Test
7020     static void WithLanesByteMaxVectorTestsSmokeTest() {
7021         ByteVector av = ByteVector.zero(SPECIES);
7022         VectorSpecies species = av.species().withLanes(byte.class);
7023         assert(species.equals(SPECIES));
7024     }
7025 
7026     @Test
7027     static void WithShapeByteMaxVectorTestsSmokeTest() {
7028         ByteVector av = ByteVector.zero(SPECIES);
7029         VectorShape vsh = av.shape();
7030         VectorSpecies species = av.species().withShape(vsh);
7031         assert(species.equals(SPECIES));
7032     }
7033 
7034     @Test
7035     static void MaskAllTrueByteMaxVectorTestsSmokeTest() {
7036         for (int ic = 0; ic < INVOC_COUNT; ic++) {
7037           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
7038         }
7039     }
7040 }