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