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