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