1 /*
   2  * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @key randomness
  27  *
  28  * @library /test/lib
  29  * @modules jdk.incubator.vector
  30  * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests
  31  */
  32 
  33 // -- This file was mechanically generated: Do not edit! -- //
  34 
  35 import jdk.incubator.vector.VectorShape;
  36 import jdk.incubator.vector.VectorSpecies;
  37 import jdk.incubator.vector.VectorShuffle;
  38 import jdk.incubator.vector.VectorMask;
  39 import jdk.incubator.vector.VectorOperators;
  40 import jdk.incubator.vector.Vector;
  41 import jdk.incubator.vector.VectorMath;
  42 
  43 import jdk.incubator.vector.LongVector;
  44 
  45 import org.testng.Assert;
  46 import org.testng.annotations.DataProvider;
  47 import org.testng.annotations.Test;
  48 
  49 import java.lang.Integer;
  50 import java.util.List;
  51 import java.util.Arrays;
  52 import java.util.function.BiFunction;
  53 import java.util.function.IntFunction;
  54 import java.util.Objects;
  55 import java.util.stream.Collectors;
  56 import java.util.stream.Stream;
  57 
  58 @Test
  59 public class LongMaxVectorTests extends AbstractVectorTest {
  60 
  61     static final VectorSpecies<Long> SPECIES =
  62                 LongVector.SPECIES_MAX;
  63 
  64     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  65 


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