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