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, int start, int end) {
 192         int i = start;
 193         try {
 194             for (; i < end; 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, j = 0; i < a.length; i += SPECIES.length()) {
3489                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3490                 av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i);
3491             }
3492         }
3493 
3494 
3495         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3496             assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3497         }
3498     }
3499     static boolean testIS_DEFAULT(long a) {
3500         return bits(a)==0;
3501     }
3502 
3503     @Test(dataProvider = "longTestOpProvider")
3504     static void IS_DEFAULTLongMaxVectorTests(IntFunction<long[]> fa) {
3505         long[] a = fa.apply(SPECIES.length());
3506 
3507         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3508             for (int i = 0; i < a.length; i += SPECIES.length()) {
3509                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3510                 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);
3511 
3512                 // Check results as part of computation.
3513                 for (int j = 0; j < SPECIES.length(); j++) {
3514                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3515                 }
3516             }
3517         }
3518     }
3519 
3520     @Test(dataProvider = "longTestOpMaskProvider")
3521     static void IS_DEFAULTMaskedLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa,
3522                                           IntFunction<boolean[]> fm) {
3523         long[] a = fa.apply(SPECIES.length());
3524         boolean[] mask = fm.apply(SPECIES.length());
3525         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3526 
3527         for (int i = 0; i < a.length; i += SPECIES.length()) {
3528             LongVector av = LongVector.fromArray(SPECIES, a, i);
3529             VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3530 
3531             // Check results as part of computation.
3532             for (int j = 0; j < SPECIES.length(); j++) {
3533                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3534             }
3535         }
3536     }
3537     static boolean testIS_NEGATIVE(long a) {
3538         return bits(a)<0;
3539     }
3540 
3541     @Test(dataProvider = "longTestOpProvider")
3542     static void IS_NEGATIVELongMaxVectorTests(IntFunction<long[]> fa) {
3543         long[] a = fa.apply(SPECIES.length());
3544 
3545         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3546             for (int i = 0; i < a.length; i += SPECIES.length()) {
3547                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3548                 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);
3549 
3550                 // Check results as part of computation.
3551                 for (int j = 0; j < SPECIES.length(); j++) {
3552                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3553                 }
3554             }
3555         }
3556     }
3557 
3558     @Test(dataProvider = "longTestOpMaskProvider")
3559     static void IS_NEGATIVEMaskedLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa,
3560                                           IntFunction<boolean[]> fm) {
3561         long[] a = fa.apply(SPECIES.length());
3562         boolean[] mask = fm.apply(SPECIES.length());
3563         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3564 
3565         for (int i = 0; i < a.length; i += SPECIES.length()) {
3566             LongVector av = LongVector.fromArray(SPECIES, a, i);
3567             VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3568 
3569             // Check results as part of computation.
3570             for (int j = 0; j < SPECIES.length(); j++) {
3571                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3572             }
3573         }
3574     }
3575 
3576 
3577 
3578 
3579     @Test(dataProvider = "longCompareOpProvider")
3580     static void LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3581         long[] a = fa.apply(SPECIES.length());
3582         long[] b = fb.apply(SPECIES.length());
3583 
3584         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3585             for (int i = 0; i < a.length; i += SPECIES.length()) {
3586                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3587                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3588                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);
3589 
3590                 // Check results as part of computation.
3591                 for (int j = 0; j < SPECIES.length(); j++) {
3592                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3593                 }
3594             }
3595         }
3596     }
3597 
3598 
3599     @Test(dataProvider = "longCompareOpProvider")
3600     static void ltLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3601         long[] a = fa.apply(SPECIES.length());
3602         long[] b = fb.apply(SPECIES.length());
3603 
3604         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3605             for (int i = 0; i < a.length; i += SPECIES.length()) {
3606                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3607                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3608                 VectorMask<Long> mv = av.lt(bv);
3609 
3610                 // Check results as part of computation.
3611                 for (int j = 0; j < SPECIES.length(); j++) {
3612                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3613                 }
3614             }
3615         }
3616     }
3617 
3618     @Test(dataProvider = "longCompareOpMaskProvider")
3619     static void LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3620                                                 IntFunction<boolean[]> fm) {
3621         long[] a = fa.apply(SPECIES.length());
3622         long[] b = fb.apply(SPECIES.length());
3623         boolean[] mask = fm.apply(SPECIES.length());
3624 
3625         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3626 
3627         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3628             for (int i = 0; i < a.length; i += SPECIES.length()) {
3629                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3630                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3631                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);
3632 
3633                 // Check results as part of computation.
3634                 for (int j = 0; j < SPECIES.length(); j++) {
3635                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3636                 }
3637             }
3638         }
3639     }
3640 
3641 
3642     @Test(dataProvider = "longCompareOpProvider")
3643     static void GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3644         long[] a = fa.apply(SPECIES.length());
3645         long[] b = fb.apply(SPECIES.length());
3646 
3647         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3648             for (int i = 0; i < a.length; i += SPECIES.length()) {
3649                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3650                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3651                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);
3652 
3653                 // Check results as part of computation.
3654                 for (int j = 0; j < SPECIES.length(); j++) {
3655                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3656                 }
3657             }
3658         }
3659     }
3660 
3661     @Test(dataProvider = "longCompareOpMaskProvider")
3662     static void GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3663                                                 IntFunction<boolean[]> fm) {
3664         long[] a = fa.apply(SPECIES.length());
3665         long[] b = fb.apply(SPECIES.length());
3666         boolean[] mask = fm.apply(SPECIES.length());
3667 
3668         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3669 
3670         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3671             for (int i = 0; i < a.length; i += SPECIES.length()) {
3672                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3673                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3674                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);
3675 
3676                 // Check results as part of computation.
3677                 for (int j = 0; j < SPECIES.length(); j++) {
3678                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3679                 }
3680             }
3681         }
3682     }
3683 
3684 
3685     @Test(dataProvider = "longCompareOpProvider")
3686     static void EQLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3687         long[] a = fa.apply(SPECIES.length());
3688         long[] b = fb.apply(SPECIES.length());
3689 
3690         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3691             for (int i = 0; i < a.length; i += SPECIES.length()) {
3692                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3693                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3694                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);
3695 
3696                 // Check results as part of computation.
3697                 for (int j = 0; j < SPECIES.length(); j++) {
3698                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3699                 }
3700             }
3701         }
3702     }
3703 
3704 
3705     @Test(dataProvider = "longCompareOpProvider")
3706     static void eqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3707         long[] a = fa.apply(SPECIES.length());
3708         long[] b = fb.apply(SPECIES.length());
3709 
3710         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3711             for (int i = 0; i < a.length; i += SPECIES.length()) {
3712                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3713                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3714                 VectorMask<Long> mv = av.eq(bv);
3715 
3716                 // Check results as part of computation.
3717                 for (int j = 0; j < SPECIES.length(); j++) {
3718                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3719                 }
3720             }
3721         }
3722     }
3723 
3724     @Test(dataProvider = "longCompareOpMaskProvider")
3725     static void EQLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3726                                                 IntFunction<boolean[]> fm) {
3727         long[] a = fa.apply(SPECIES.length());
3728         long[] b = fb.apply(SPECIES.length());
3729         boolean[] mask = fm.apply(SPECIES.length());
3730 
3731         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3732 
3733         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3734             for (int i = 0; i < a.length; i += SPECIES.length()) {
3735                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3736                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3737                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);
3738 
3739                 // Check results as part of computation.
3740                 for (int j = 0; j < SPECIES.length(); j++) {
3741                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3742                 }
3743             }
3744         }
3745     }
3746 
3747 
3748     @Test(dataProvider = "longCompareOpProvider")
3749     static void NELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3750         long[] a = fa.apply(SPECIES.length());
3751         long[] b = fb.apply(SPECIES.length());
3752 
3753         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3754             for (int i = 0; i < a.length; i += SPECIES.length()) {
3755                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3756                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3757                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);
3758 
3759                 // Check results as part of computation.
3760                 for (int j = 0; j < SPECIES.length(); j++) {
3761                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3762                 }
3763             }
3764         }
3765     }
3766 
3767     @Test(dataProvider = "longCompareOpMaskProvider")
3768     static void NELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3769                                                 IntFunction<boolean[]> fm) {
3770         long[] a = fa.apply(SPECIES.length());
3771         long[] b = fb.apply(SPECIES.length());
3772         boolean[] mask = fm.apply(SPECIES.length());
3773 
3774         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3775 
3776         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3777             for (int i = 0; i < a.length; i += SPECIES.length()) {
3778                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3779                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3780                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);
3781 
3782                 // Check results as part of computation.
3783                 for (int j = 0; j < SPECIES.length(); j++) {
3784                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3785                 }
3786             }
3787         }
3788     }
3789 
3790 
3791     @Test(dataProvider = "longCompareOpProvider")
3792     static void LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3793         long[] a = fa.apply(SPECIES.length());
3794         long[] b = fb.apply(SPECIES.length());
3795 
3796         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3797             for (int i = 0; i < a.length; i += SPECIES.length()) {
3798                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3799                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3800                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);
3801 
3802                 // Check results as part of computation.
3803                 for (int j = 0; j < SPECIES.length(); j++) {
3804                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3805                 }
3806             }
3807         }
3808     }
3809 
3810     @Test(dataProvider = "longCompareOpMaskProvider")
3811     static void LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3812                                                 IntFunction<boolean[]> fm) {
3813         long[] a = fa.apply(SPECIES.length());
3814         long[] b = fb.apply(SPECIES.length());
3815         boolean[] mask = fm.apply(SPECIES.length());
3816 
3817         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3818 
3819         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3820             for (int i = 0; i < a.length; i += SPECIES.length()) {
3821                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3822                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3823                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);
3824 
3825                 // Check results as part of computation.
3826                 for (int j = 0; j < SPECIES.length(); j++) {
3827                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3828                 }
3829             }
3830         }
3831     }
3832 
3833 
3834     @Test(dataProvider = "longCompareOpProvider")
3835     static void GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3836         long[] a = fa.apply(SPECIES.length());
3837         long[] b = fb.apply(SPECIES.length());
3838 
3839         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3840             for (int i = 0; i < a.length; i += SPECIES.length()) {
3841                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3842                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3843                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);
3844 
3845                 // Check results as part of computation.
3846                 for (int j = 0; j < SPECIES.length(); j++) {
3847                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3848                 }
3849             }
3850         }
3851     }
3852 
3853     @Test(dataProvider = "longCompareOpMaskProvider")
3854     static void GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3855                                                 IntFunction<boolean[]> fm) {
3856         long[] a = fa.apply(SPECIES.length());
3857         long[] b = fb.apply(SPECIES.length());
3858         boolean[] mask = fm.apply(SPECIES.length());
3859 
3860         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3861 
3862         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3863             for (int i = 0; i < a.length; i += SPECIES.length()) {
3864                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3865                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3866                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);
3867 
3868                 // Check results as part of computation.
3869                 for (int j = 0; j < SPECIES.length(); j++) {
3870                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3871                 }
3872             }
3873         }
3874     }
3875 
3876 
3877 
3878     @Test(dataProvider = "longCompareOpProvider")
3879     static void UNSIGNED_LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3880         long[] a = fa.apply(SPECIES.length());
3881         long[] b = fb.apply(SPECIES.length());
3882 
3883         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3884             for (int i = 0; i < a.length; i += SPECIES.length()) {
3885                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3886                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3887                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
3888 
3889                 // Check results as part of computation.
3890                 for (int j = 0; j < SPECIES.length(); j++) {
3891                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
3892                 }
3893             }
3894         }
3895     }
3896 
3897 
3898 
3899     @Test(dataProvider = "longCompareOpMaskProvider")
3900     static void UNSIGNED_LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3901                                                 IntFunction<boolean[]> fm) {
3902         long[] a = fa.apply(SPECIES.length());
3903         long[] b = fb.apply(SPECIES.length());
3904         boolean[] mask = fm.apply(SPECIES.length());
3905 
3906         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3907 
3908         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3909             for (int i = 0; i < a.length; i += SPECIES.length()) {
3910                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3911                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3912                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
3913 
3914                 // Check results as part of computation.
3915                 for (int j = 0; j < SPECIES.length(); j++) {
3916                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
3917                 }
3918             }
3919         }
3920     }
3921 
3922 
3923 
3924 
3925     @Test(dataProvider = "longCompareOpProvider")
3926     static void UNSIGNED_GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3927         long[] a = fa.apply(SPECIES.length());
3928         long[] b = fb.apply(SPECIES.length());
3929 
3930         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3931             for (int i = 0; i < a.length; i += SPECIES.length()) {
3932                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3933                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3934                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
3935 
3936                 // Check results as part of computation.
3937                 for (int j = 0; j < SPECIES.length(); j++) {
3938                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
3939                 }
3940             }
3941         }
3942     }
3943 
3944 
3945 
3946     @Test(dataProvider = "longCompareOpMaskProvider")
3947     static void UNSIGNED_GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3948                                                 IntFunction<boolean[]> fm) {
3949         long[] a = fa.apply(SPECIES.length());
3950         long[] b = fb.apply(SPECIES.length());
3951         boolean[] mask = fm.apply(SPECIES.length());
3952 
3953         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3954 
3955         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3956             for (int i = 0; i < a.length; i += SPECIES.length()) {
3957                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3958                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3959                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
3960 
3961                 // Check results as part of computation.
3962                 for (int j = 0; j < SPECIES.length(); j++) {
3963                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
3964                 }
3965             }
3966         }
3967     }
3968 
3969 
3970 
3971 
3972     @Test(dataProvider = "longCompareOpProvider")
3973     static void UNSIGNED_LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3974         long[] a = fa.apply(SPECIES.length());
3975         long[] b = fb.apply(SPECIES.length());
3976 
3977         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3978             for (int i = 0; i < a.length; i += SPECIES.length()) {
3979                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3980                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3981                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
3982 
3983                 // Check results as part of computation.
3984                 for (int j = 0; j < SPECIES.length(); j++) {
3985                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
3986                 }
3987             }
3988         }
3989     }
3990 
3991 
3992 
3993     @Test(dataProvider = "longCompareOpMaskProvider")
3994     static void UNSIGNED_LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3995                                                 IntFunction<boolean[]> fm) {
3996         long[] a = fa.apply(SPECIES.length());
3997         long[] b = fb.apply(SPECIES.length());
3998         boolean[] mask = fm.apply(SPECIES.length());
3999 
4000         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4001 
4002         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4003             for (int i = 0; i < a.length; i += SPECIES.length()) {
4004                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4005                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4006                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4007 
4008                 // Check results as part of computation.
4009                 for (int j = 0; j < SPECIES.length(); j++) {
4010                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4011                 }
4012             }
4013         }
4014     }
4015 
4016 
4017 
4018 
4019     @Test(dataProvider = "longCompareOpProvider")
4020     static void UNSIGNED_GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4021         long[] a = fa.apply(SPECIES.length());
4022         long[] b = fb.apply(SPECIES.length());
4023 
4024         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4025             for (int i = 0; i < a.length; i += SPECIES.length()) {
4026                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4027                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4028                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4029 
4030                 // Check results as part of computation.
4031                 for (int j = 0; j < SPECIES.length(); j++) {
4032                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4033                 }
4034             }
4035         }
4036     }
4037 
4038 
4039 
4040     @Test(dataProvider = "longCompareOpMaskProvider")
4041     static void UNSIGNED_GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4042                                                 IntFunction<boolean[]> fm) {
4043         long[] a = fa.apply(SPECIES.length());
4044         long[] b = fb.apply(SPECIES.length());
4045         boolean[] mask = fm.apply(SPECIES.length());
4046 
4047         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4048 
4049         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4050             for (int i = 0; i < a.length; i += SPECIES.length()) {
4051                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4052                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4053                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4054 
4055                 // Check results as part of computation.
4056                 for (int j = 0; j < SPECIES.length(); j++) {
4057                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4058                 }
4059             }
4060         }
4061     }
4062 
4063 
4064 
4065     @Test(dataProvider = "longCompareOpProvider")
4066     static void LTLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4067         long[] a = fa.apply(SPECIES.length());
4068         long[] b = fb.apply(SPECIES.length());
4069 
4070         for (int i = 0; i < a.length; i += SPECIES.length()) {
4071             LongVector av = LongVector.fromArray(SPECIES, a, i);
4072             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);
4073 
4074             // Check results as part of computation.
4075             for (int j = 0; j < SPECIES.length(); j++) {
4076                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4077             }
4078         }
4079     }
4080 
4081 
4082     @Test(dataProvider = "longCompareOpMaskProvider")
4083     static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4084                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4085         long[] a = fa.apply(SPECIES.length());
4086         long[] b = fb.apply(SPECIES.length());
4087         boolean[] mask = fm.apply(SPECIES.length());
4088 
4089         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4090 
4091         for (int i = 0; i < a.length; i += SPECIES.length()) {
4092             LongVector av = LongVector.fromArray(SPECIES, a, i);
4093             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);
4094 
4095             // Check results as part of computation.
4096             for (int j = 0; j < SPECIES.length(); j++) {
4097                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4098             }
4099         }
4100     }
4101 
4102 
4103     @Test(dataProvider = "longCompareOpProvider")
4104     static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4105         long[] a = fa.apply(SPECIES.length());
4106         long[] b = fb.apply(SPECIES.length());
4107 
4108         for (int i = 0; i < a.length; i += SPECIES.length()) {
4109             LongVector av = LongVector.fromArray(SPECIES, a, i);
4110             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);
4111 
4112             // Check results as part of computation.
4113             for (int j = 0; j < SPECIES.length(); j++) {
4114                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4115             }
4116         }
4117     }
4118 
4119 
4120     @Test(dataProvider = "longCompareOpMaskProvider")
4121     static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4122                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4123         long[] a = fa.apply(SPECIES.length());
4124         long[] b = fb.apply(SPECIES.length());
4125         boolean[] mask = fm.apply(SPECIES.length());
4126 
4127         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4128 
4129         for (int i = 0; i < a.length; i += SPECIES.length()) {
4130             LongVector av = LongVector.fromArray(SPECIES, a, i);
4131             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4132 
4133             // Check results as part of computation.
4134             for (int j = 0; j < SPECIES.length(); j++) {
4135                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4136             }
4137         }
4138     }
4139 
4140 
4141     static long blend(long a, long b, boolean mask) {
4142         return mask ? b : a;
4143     }
4144 
4145     @Test(dataProvider = "longBinaryOpMaskProvider")
4146     static void blendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
4147                                           IntFunction<boolean[]> fm) {
4148         long[] a = fa.apply(SPECIES.length());
4149         long[] b = fb.apply(SPECIES.length());
4150         long[] r = fr.apply(SPECIES.length());
4151         boolean[] mask = fm.apply(SPECIES.length());
4152         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4153 
4154         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4155             for (int i = 0; i < a.length; i += SPECIES.length()) {
4156                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4157                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4158                 av.blend(bv, vmask).intoArray(r, i);
4159             }
4160         }
4161 
4162         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend);
4163     }
4164 
4165     @Test(dataProvider = "longUnaryOpShuffleProvider")
4166     static void RearrangeLongMaxVectorTests(IntFunction<long[]> fa,
4167                                            BiFunction<Integer,Integer,int[]> fs) {
4168         long[] a = fa.apply(SPECIES.length());
4169         int[] order = fs.apply(a.length, SPECIES.length());
4170         long[] r = fr.apply(SPECIES.length());
4171 
4172         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4173             for (int i = 0; i < a.length; i += SPECIES.length()) {
4174                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4175                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
4176             }
4177         }
4178 
4179         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4180     }
4181 
4182     @Test(dataProvider = "longUnaryOpShuffleMaskProvider")
4183     static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
4184                                                           BiFunction<Integer,Integer,int[]> fs,
4185                                                           IntFunction<boolean[]> fm) {
4186         long[] a = fa.apply(SPECIES.length());
4187         int[] order = fs.apply(a.length, SPECIES.length());
4188         long[] r = fr.apply(SPECIES.length());
4189         boolean[] mask = fm.apply(SPECIES.length());
4190         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4191 
4192         for (int i = 0; i < a.length; i += SPECIES.length()) {
4193             LongVector av = LongVector.fromArray(SPECIES, a, i);
4194             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4195         }
4196 
4197         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4198     }
4199 
4200     @Test(dataProvider = "longUnaryOpMaskProvider")
4201     static void compressLongMaxVectorTests(IntFunction<long[]> fa,
4202                                                 IntFunction<boolean[]> fm) {
4203         long[] a = fa.apply(SPECIES.length());
4204         long[] r = fr.apply(SPECIES.length());
4205         boolean[] mask = fm.apply(SPECIES.length());
4206         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4207 
4208         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4209             for (int i = 0; i < a.length; i += SPECIES.length()) {
4210                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4211                 av.compress(vmask).intoArray(r, i);
4212             }
4213         }
4214 
4215         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4216     }
4217 
4218     @Test(dataProvider = "longUnaryOpMaskProvider")
4219     static void expandLongMaxVectorTests(IntFunction<long[]> fa,
4220                                                 IntFunction<boolean[]> fm) {
4221         long[] a = fa.apply(SPECIES.length());
4222         long[] r = fr.apply(SPECIES.length());
4223         boolean[] mask = fm.apply(SPECIES.length());
4224         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4225 
4226         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4227             for (int i = 0; i < a.length; i += SPECIES.length()) {
4228                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4229                 av.expand(vmask).intoArray(r, i);
4230             }
4231         }
4232 
4233         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4234     }
4235     @Test(dataProvider = "longUnaryOpProvider")
4236     static void getLongMaxVectorTests(IntFunction<long[]> fa) {
4237         long[] a = fa.apply(SPECIES.length());
4238         long[] r = fr.apply(SPECIES.length());
4239 
4240         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4241             for (int i = 0; i < a.length; i += SPECIES.length()) {
4242                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4243                 int num_lanes = SPECIES.length();
4244                 // Manually unroll because full unroll happens after intrinsification.
4245                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4246                 if (num_lanes == 1) {
4247                     r[i]=av.lane(0);
4248                 } else if (num_lanes == 2) {
4249                     r[i]=av.lane(0);
4250                     r[i+1]=av.lane(1);
4251                 } else if (num_lanes == 4) {
4252                     r[i]=av.lane(0);
4253                     r[i+1]=av.lane(1);
4254                     r[i+2]=av.lane(2);
4255                     r[i+3]=av.lane(3);
4256                 } else if (num_lanes == 8) {
4257                     r[i]=av.lane(0);
4258                     r[i+1]=av.lane(1);
4259                     r[i+2]=av.lane(2);
4260                     r[i+3]=av.lane(3);
4261                     r[i+4]=av.lane(4);
4262                     r[i+5]=av.lane(5);
4263                     r[i+6]=av.lane(6);
4264                     r[i+7]=av.lane(7);
4265                 } else if (num_lanes == 16) {
4266                     r[i]=av.lane(0);
4267                     r[i+1]=av.lane(1);
4268                     r[i+2]=av.lane(2);
4269                     r[i+3]=av.lane(3);
4270                     r[i+4]=av.lane(4);
4271                     r[i+5]=av.lane(5);
4272                     r[i+6]=av.lane(6);
4273                     r[i+7]=av.lane(7);
4274                     r[i+8]=av.lane(8);
4275                     r[i+9]=av.lane(9);
4276                     r[i+10]=av.lane(10);
4277                     r[i+11]=av.lane(11);
4278                     r[i+12]=av.lane(12);
4279                     r[i+13]=av.lane(13);
4280                     r[i+14]=av.lane(14);
4281                     r[i+15]=av.lane(15);
4282                 } else if (num_lanes == 32) {
4283                     r[i]=av.lane(0);
4284                     r[i+1]=av.lane(1);
4285                     r[i+2]=av.lane(2);
4286                     r[i+3]=av.lane(3);
4287                     r[i+4]=av.lane(4);
4288                     r[i+5]=av.lane(5);
4289                     r[i+6]=av.lane(6);
4290                     r[i+7]=av.lane(7);
4291                     r[i+8]=av.lane(8);
4292                     r[i+9]=av.lane(9);
4293                     r[i+10]=av.lane(10);
4294                     r[i+11]=av.lane(11);
4295                     r[i+12]=av.lane(12);
4296                     r[i+13]=av.lane(13);
4297                     r[i+14]=av.lane(14);
4298                     r[i+15]=av.lane(15);
4299                     r[i+16]=av.lane(16);
4300                     r[i+17]=av.lane(17);
4301                     r[i+18]=av.lane(18);
4302                     r[i+19]=av.lane(19);
4303                     r[i+20]=av.lane(20);
4304                     r[i+21]=av.lane(21);
4305                     r[i+22]=av.lane(22);
4306                     r[i+23]=av.lane(23);
4307                     r[i+24]=av.lane(24);
4308                     r[i+25]=av.lane(25);
4309                     r[i+26]=av.lane(26);
4310                     r[i+27]=av.lane(27);
4311                     r[i+28]=av.lane(28);
4312                     r[i+29]=av.lane(29);
4313                     r[i+30]=av.lane(30);
4314                     r[i+31]=av.lane(31);
4315                 } else if (num_lanes == 64) {
4316                     r[i]=av.lane(0);
4317                     r[i+1]=av.lane(1);
4318                     r[i+2]=av.lane(2);
4319                     r[i+3]=av.lane(3);
4320                     r[i+4]=av.lane(4);
4321                     r[i+5]=av.lane(5);
4322                     r[i+6]=av.lane(6);
4323                     r[i+7]=av.lane(7);
4324                     r[i+8]=av.lane(8);
4325                     r[i+9]=av.lane(9);
4326                     r[i+10]=av.lane(10);
4327                     r[i+11]=av.lane(11);
4328                     r[i+12]=av.lane(12);
4329                     r[i+13]=av.lane(13);
4330                     r[i+14]=av.lane(14);
4331                     r[i+15]=av.lane(15);
4332                     r[i+16]=av.lane(16);
4333                     r[i+17]=av.lane(17);
4334                     r[i+18]=av.lane(18);
4335                     r[i+19]=av.lane(19);
4336                     r[i+20]=av.lane(20);
4337                     r[i+21]=av.lane(21);
4338                     r[i+22]=av.lane(22);
4339                     r[i+23]=av.lane(23);
4340                     r[i+24]=av.lane(24);
4341                     r[i+25]=av.lane(25);
4342                     r[i+26]=av.lane(26);
4343                     r[i+27]=av.lane(27);
4344                     r[i+28]=av.lane(28);
4345                     r[i+29]=av.lane(29);
4346                     r[i+30]=av.lane(30);
4347                     r[i+31]=av.lane(31);
4348                     r[i+32]=av.lane(32);
4349                     r[i+33]=av.lane(33);
4350                     r[i+34]=av.lane(34);
4351                     r[i+35]=av.lane(35);
4352                     r[i+36]=av.lane(36);
4353                     r[i+37]=av.lane(37);
4354                     r[i+38]=av.lane(38);
4355                     r[i+39]=av.lane(39);
4356                     r[i+40]=av.lane(40);
4357                     r[i+41]=av.lane(41);
4358                     r[i+42]=av.lane(42);
4359                     r[i+43]=av.lane(43);
4360                     r[i+44]=av.lane(44);
4361                     r[i+45]=av.lane(45);
4362                     r[i+46]=av.lane(46);
4363                     r[i+47]=av.lane(47);
4364                     r[i+48]=av.lane(48);
4365                     r[i+49]=av.lane(49);
4366                     r[i+50]=av.lane(50);
4367                     r[i+51]=av.lane(51);
4368                     r[i+52]=av.lane(52);
4369                     r[i+53]=av.lane(53);
4370                     r[i+54]=av.lane(54);
4371                     r[i+55]=av.lane(55);
4372                     r[i+56]=av.lane(56);
4373                     r[i+57]=av.lane(57);
4374                     r[i+58]=av.lane(58);
4375                     r[i+59]=av.lane(59);
4376                     r[i+60]=av.lane(60);
4377                     r[i+61]=av.lane(61);
4378                     r[i+62]=av.lane(62);
4379                     r[i+63]=av.lane(63);
4380                 } else {
4381                     for (int j = 0; j < SPECIES.length(); j++) {
4382                         r[i+j]=av.lane(j);
4383                     }
4384                 }
4385             }
4386         }
4387 
4388         assertArraysEquals(r, a, LongMaxVectorTests::get);
4389     }
4390 
4391     @Test(dataProvider = "longUnaryOpProvider")
4392     static void BroadcastLongMaxVectorTests(IntFunction<long[]> fa) {
4393         long[] a = fa.apply(SPECIES.length());
4394         long[] r = new long[a.length];
4395 
4396         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4397             for (int i = 0; i < a.length; i += SPECIES.length()) {
4398                 LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4399             }
4400         }
4401 
4402         assertBroadcastArraysEquals(r, a);
4403     }
4404 
4405 
4406 
4407 
4408 
4409     @Test(dataProvider = "longUnaryOpProvider")
4410     static void ZeroLongMaxVectorTests(IntFunction<long[]> fa) {
4411         long[] a = fa.apply(SPECIES.length());
4412         long[] r = new long[a.length];
4413 
4414         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4415             for (int i = 0; i < a.length; i += SPECIES.length()) {
4416                 LongVector.zero(SPECIES).intoArray(a, i);
4417             }
4418         }
4419 
4420         Assert.assertEquals(a, r);
4421     }
4422 
4423 
4424 
4425 
4426     static long[] sliceUnary(long[] a, int origin, int idx) {
4427         long[] res = new long[SPECIES.length()];
4428         for (int i = 0; i < SPECIES.length(); i++){
4429             if(i+origin < SPECIES.length())
4430                 res[i] = a[idx+i+origin];
4431             else
4432                 res[i] = (long)0;
4433         }
4434         return res;
4435     }
4436 
4437     @Test(dataProvider = "longUnaryOpProvider")
4438     static void sliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4439         long[] a = fa.apply(SPECIES.length());
4440         long[] r = new long[a.length];
4441         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4442         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4443             for (int i = 0; i < a.length; i += SPECIES.length()) {
4444                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4445                 av.slice(origin).intoArray(r, i);
4446             }
4447         }
4448 
4449         assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary);
4450     }
4451     static long[] sliceBinary(long[] a, long[] b, int origin, int idx) {
4452         long[] res = new long[SPECIES.length()];
4453         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4454             if(i+origin < SPECIES.length())
4455                 res[i] = a[idx+i+origin];
4456             else {
4457                 res[i] = b[idx+j];
4458                 j++;
4459             }
4460         }
4461         return res;
4462     }
4463 
4464     @Test(dataProvider = "longBinaryOpProvider")
4465     static void sliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4466         long[] a = fa.apply(SPECIES.length());
4467         long[] b = fb.apply(SPECIES.length());
4468         long[] r = new long[a.length];
4469         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4470         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4471             for (int i = 0; i < a.length; i += SPECIES.length()) {
4472                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4473                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4474                 av.slice(origin, bv).intoArray(r, i);
4475             }
4476         }
4477 
4478         assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary);
4479     }
4480     static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) {
4481         long[] res = new long[SPECIES.length()];
4482         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4483             if(i+origin < SPECIES.length())
4484                 res[i] = mask[i] ? a[idx+i+origin] : (long)0;
4485             else {
4486                 res[i] = mask[i] ? b[idx+j] : (long)0;
4487                 j++;
4488             }
4489         }
4490         return res;
4491     }
4492 
4493     @Test(dataProvider = "longBinaryOpMaskProvider")
4494     static void sliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4495     IntFunction<boolean[]> fm) {
4496         long[] a = fa.apply(SPECIES.length());
4497         long[] b = fb.apply(SPECIES.length());
4498         boolean[] mask = fm.apply(SPECIES.length());
4499         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4500 
4501         long[] r = new long[a.length];
4502         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4503         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4504             for (int i = 0; i < a.length; i += SPECIES.length()) {
4505                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4506                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4507                 av.slice(origin, bv, vmask).intoArray(r, i);
4508             }
4509         }
4510 
4511         assertArraysEquals(r, a, b, origin, mask, LongMaxVectorTests::slice);
4512     }
4513     static long[] unsliceUnary(long[] a, int origin, int idx) {
4514         long[] res = new long[SPECIES.length()];
4515         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4516             if(i < origin)
4517                 res[i] = (long)0;
4518             else {
4519                 res[i] = a[idx+j];
4520                 j++;
4521             }
4522         }
4523         return res;
4524     }
4525 
4526     @Test(dataProvider = "longUnaryOpProvider")
4527     static void unsliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4528         long[] a = fa.apply(SPECIES.length());
4529         long[] r = new long[a.length];
4530         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4531         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4532             for (int i = 0; i < a.length; i += SPECIES.length()) {
4533                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4534                 av.unslice(origin).intoArray(r, i);
4535             }
4536         }
4537 
4538         assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary);
4539     }
4540     static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) {
4541         long[] res = new long[SPECIES.length()];
4542         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4543             if (part == 0) {
4544                 if (i < origin)
4545                     res[i] = b[idx+i];
4546                 else {
4547                     res[i] = a[idx+j];
4548                     j++;
4549                 }
4550             } else if (part == 1) {
4551                 if (i < origin)
4552                     res[i] = a[idx+SPECIES.length()-origin+i];
4553                 else {
4554                     res[i] = b[idx+origin+j];
4555                     j++;
4556                 }
4557             }
4558         }
4559         return res;
4560     }
4561 
4562     @Test(dataProvider = "longBinaryOpProvider")
4563     static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4564         long[] a = fa.apply(SPECIES.length());
4565         long[] b = fb.apply(SPECIES.length());
4566         long[] r = new long[a.length];
4567         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4568         int part = (new java.util.Random()).nextInt(2);
4569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4570             for (int i = 0; i < a.length; i += SPECIES.length()) {
4571                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4572                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4573                 av.unslice(origin, bv, part).intoArray(r, i);
4574             }
4575         }
4576 
4577         assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary);
4578     }
4579     static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) {
4580         long[] res = new long[SPECIES.length()];
4581         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4582             if(i+origin < SPECIES.length())
4583                 res[i] = b[idx+i+origin];
4584             else {
4585                 res[i] = b[idx+j];
4586                 j++;
4587             }
4588         }
4589         for (int i = 0; i < SPECIES.length(); i++){
4590             res[i] = mask[i] ? a[idx+i] : res[i];
4591         }
4592         long[] res1 = new long[SPECIES.length()];
4593         if (part == 0) {
4594             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4595                 if (i < origin)
4596                     res1[i] = b[idx+i];
4597                 else {
4598                    res1[i] = res[j];
4599                    j++;
4600                 }
4601             }
4602         } else if (part == 1) {
4603             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4604                 if (i < origin)
4605                     res1[i] = res[SPECIES.length()-origin+i];
4606                 else {
4607                     res1[i] = b[idx+origin+j];
4608                     j++;
4609                 }
4610             }
4611         }
4612         return res1;
4613     }
4614 
4615     @Test(dataProvider = "longBinaryOpMaskProvider")
4616     static void unsliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4617     IntFunction<boolean[]> fm) {
4618         long[] a = fa.apply(SPECIES.length());
4619         long[] b = fb.apply(SPECIES.length());
4620         boolean[] mask = fm.apply(SPECIES.length());
4621         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4622         long[] r = new long[a.length];
4623         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4624         int part = (new java.util.Random()).nextInt(2);
4625         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4626             for (int i = 0; i < a.length; i += SPECIES.length()) {
4627                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4628                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4629                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4630             }
4631         }
4632 
4633         assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice);
4634     }
4635 
4636 
4637 
4638 
4639 
4640 
4641 
4642 
4643 
4644 
4645 
4646 
4647 
4648 
4649 
4650 
4651 
4652 
4653 
4654 
4655 
4656 
4657 
4658     static long BITWISE_BLEND(long a, long b, long c) {
4659         return (long)((a&~(c))|(b&c));
4660     }
4661     static long bitwiseBlend(long a, long b, long c) {
4662         return (long)((a&~(c))|(b&c));
4663     }
4664 
4665 
4666     @Test(dataProvider = "longTernaryOpProvider")
4667     static void BITWISE_BLENDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4668         long[] a = fa.apply(SPECIES.length());
4669         long[] b = fb.apply(SPECIES.length());
4670         long[] c = fc.apply(SPECIES.length());
4671         long[] r = fr.apply(SPECIES.length());
4672 
4673         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4674             for (int i = 0; i < a.length; i += SPECIES.length()) {
4675                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4676                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4677                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
4678                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4679             }
4680         }
4681 
4682         assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4683     }
4684     @Test(dataProvider = "longTernaryOpProvider")
4685     static void bitwiseBlendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4686         long[] a = fa.apply(SPECIES.length());
4687         long[] b = fb.apply(SPECIES.length());
4688         long[] c = fc.apply(SPECIES.length());
4689         long[] r = fr.apply(SPECIES.length());
4690 
4691         for (int i = 0; i < a.length; i += SPECIES.length()) {
4692             LongVector av = LongVector.fromArray(SPECIES, a, i);
4693             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4694             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4695             av.bitwiseBlend(bv, cv).intoArray(r, i);
4696         }
4697 
4698         assertArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4699     }
4700 
4701 
4702     @Test(dataProvider = "longTernaryOpMaskProvider")
4703     static void BITWISE_BLENDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4704                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4705         long[] a = fa.apply(SPECIES.length());
4706         long[] b = fb.apply(SPECIES.length());
4707         long[] c = fc.apply(SPECIES.length());
4708         long[] r = fr.apply(SPECIES.length());
4709         boolean[] mask = fm.apply(SPECIES.length());
4710         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4711 
4712         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4713             for (int i = 0; i < a.length; i += SPECIES.length()) {
4714                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4715                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4716                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
4717                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4718             }
4719         }
4720 
4721         assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4722     }
4723 
4724 
4725 
4726 
4727     @Test(dataProvider = "longTernaryOpProvider")
4728     static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4729         long[] a = fa.apply(SPECIES.length());
4730         long[] b = fb.apply(SPECIES.length());
4731         long[] c = fc.apply(SPECIES.length());
4732         long[] r = fr.apply(SPECIES.length());
4733 
4734         for (int i = 0; i < a.length; i += SPECIES.length()) {
4735             LongVector av = LongVector.fromArray(SPECIES, a, i);
4736             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4737             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
4738         }
4739         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4740     }
4741 
4742     @Test(dataProvider = "longTernaryOpProvider")
4743     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4744         long[] a = fa.apply(SPECIES.length());
4745         long[] b = fb.apply(SPECIES.length());
4746         long[] c = fc.apply(SPECIES.length());
4747         long[] r = fr.apply(SPECIES.length());
4748 
4749         for (int i = 0; i < a.length; i += SPECIES.length()) {
4750             LongVector av = LongVector.fromArray(SPECIES, a, i);
4751             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4752             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
4753         }
4754         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4755     }
4756     @Test(dataProvider = "longTernaryOpProvider")
4757     static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4758         long[] a = fa.apply(SPECIES.length());
4759         long[] b = fb.apply(SPECIES.length());
4760         long[] c = fc.apply(SPECIES.length());
4761         long[] r = fr.apply(SPECIES.length());
4762 
4763         for (int i = 0; i < a.length; i += SPECIES.length()) {
4764             LongVector av = LongVector.fromArray(SPECIES, a, i);
4765             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4766             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
4767         }
4768         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4769     }
4770 
4771     @Test(dataProvider = "longTernaryOpProvider")
4772     static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4773         long[] a = fa.apply(SPECIES.length());
4774         long[] b = fb.apply(SPECIES.length());
4775         long[] c = fc.apply(SPECIES.length());
4776         long[] r = fr.apply(SPECIES.length());
4777 
4778         for (int i = 0; i < a.length; i += SPECIES.length()) {
4779             LongVector av = LongVector.fromArray(SPECIES, a, i);
4780             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4781             av.bitwiseBlend(b[i], cv).intoArray(r, i);
4782         }
4783         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4784     }
4785 
4786 
4787     @Test(dataProvider = "longTernaryOpMaskProvider")
4788     static void BITWISE_BLENDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4789                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4790         long[] a = fa.apply(SPECIES.length());
4791         long[] b = fb.apply(SPECIES.length());
4792         long[] c = fc.apply(SPECIES.length());
4793         long[] r = fr.apply(SPECIES.length());
4794         boolean[] mask = fm.apply(SPECIES.length());
4795         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4796 
4797         for (int i = 0; i < a.length; i += SPECIES.length()) {
4798             LongVector av = LongVector.fromArray(SPECIES, a, i);
4799             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4800             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
4801         }
4802 
4803         assertBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4804     }
4805 
4806     @Test(dataProvider = "longTernaryOpMaskProvider")
4807     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4808                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4809         long[] a = fa.apply(SPECIES.length());
4810         long[] b = fb.apply(SPECIES.length());
4811         long[] c = fc.apply(SPECIES.length());
4812         long[] r = fr.apply(SPECIES.length());
4813         boolean[] mask = fm.apply(SPECIES.length());
4814         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4815 
4816         for (int i = 0; i < a.length; i += SPECIES.length()) {
4817             LongVector av = LongVector.fromArray(SPECIES, a, i);
4818             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4819             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
4820         }
4821 
4822         assertAltBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4823     }
4824 
4825 
4826 
4827 
4828     @Test(dataProvider = "longTernaryOpProvider")
4829     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4830         long[] a = fa.apply(SPECIES.length());
4831         long[] b = fb.apply(SPECIES.length());
4832         long[] c = fc.apply(SPECIES.length());
4833         long[] r = fr.apply(SPECIES.length());
4834 
4835         for (int i = 0; i < a.length; i += SPECIES.length()) {
4836             LongVector av = LongVector.fromArray(SPECIES, a, i);
4837             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
4838         }
4839 
4840         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4841     }
4842     @Test(dataProvider = "longTernaryOpProvider")
4843     static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4844         long[] a = fa.apply(SPECIES.length());
4845         long[] b = fb.apply(SPECIES.length());
4846         long[] c = fc.apply(SPECIES.length());
4847         long[] r = fr.apply(SPECIES.length());
4848 
4849         for (int i = 0; i < a.length; i += SPECIES.length()) {
4850             LongVector av = LongVector.fromArray(SPECIES, a, i);
4851             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
4852         }
4853 
4854         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4855     }
4856 
4857 
4858     @Test(dataProvider = "longTernaryOpMaskProvider")
4859     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4860                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4861         long[] a = fa.apply(SPECIES.length());
4862         long[] b = fb.apply(SPECIES.length());
4863         long[] c = fc.apply(SPECIES.length());
4864         long[] r = fr.apply(SPECIES.length());
4865         boolean[] mask = fm.apply(SPECIES.length());
4866         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4867 
4868         for (int i = 0; i < a.length; i += SPECIES.length()) {
4869             LongVector av = LongVector.fromArray(SPECIES, a, i);
4870             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
4871         }
4872 
4873         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4874     }
4875 
4876 
4877     static long NEG(long a) {
4878         return (long)(-((long)a));
4879     }
4880 
4881     static long neg(long a) {
4882         return (long)(-((long)a));
4883     }
4884 
4885     @Test(dataProvider = "longUnaryOpProvider")
4886     static void NEGLongMaxVectorTests(IntFunction<long[]> fa) {
4887         long[] a = fa.apply(SPECIES.length());
4888         long[] r = fr.apply(SPECIES.length());
4889 
4890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4891             for (int i = 0; i < a.length; i += SPECIES.length()) {
4892                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4893                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4894             }
4895         }
4896 
4897         assertArraysEquals(r, a, LongMaxVectorTests::NEG);
4898     }
4899 
4900     @Test(dataProvider = "longUnaryOpProvider")
4901     static void negLongMaxVectorTests(IntFunction<long[]> fa) {
4902         long[] a = fa.apply(SPECIES.length());
4903         long[] r = fr.apply(SPECIES.length());
4904 
4905         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4906             for (int i = 0; i < a.length; i += SPECIES.length()) {
4907                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4908                 av.neg().intoArray(r, i);
4909             }
4910         }
4911 
4912         assertArraysEquals(r, a, LongMaxVectorTests::neg);
4913     }
4914 
4915     @Test(dataProvider = "longUnaryOpMaskProvider")
4916     static void NEGMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4917                                                 IntFunction<boolean[]> fm) {
4918         long[] a = fa.apply(SPECIES.length());
4919         long[] r = fr.apply(SPECIES.length());
4920         boolean[] mask = fm.apply(SPECIES.length());
4921         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4922 
4923         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4924             for (int i = 0; i < a.length; i += SPECIES.length()) {
4925                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4926                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4927             }
4928         }
4929 
4930         assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG);
4931     }
4932 
4933     static long ABS(long a) {
4934         return (long)(Math.abs((long)a));
4935     }
4936 
4937     static long abs(long a) {
4938         return (long)(Math.abs((long)a));
4939     }
4940 
4941     @Test(dataProvider = "longUnaryOpProvider")
4942     static void ABSLongMaxVectorTests(IntFunction<long[]> fa) {
4943         long[] a = fa.apply(SPECIES.length());
4944         long[] r = fr.apply(SPECIES.length());
4945 
4946         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4947             for (int i = 0; i < a.length; i += SPECIES.length()) {
4948                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4949                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
4950             }
4951         }
4952 
4953         assertArraysEquals(r, a, LongMaxVectorTests::ABS);
4954     }
4955 
4956     @Test(dataProvider = "longUnaryOpProvider")
4957     static void absLongMaxVectorTests(IntFunction<long[]> fa) {
4958         long[] a = fa.apply(SPECIES.length());
4959         long[] r = fr.apply(SPECIES.length());
4960 
4961         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4962             for (int i = 0; i < a.length; i += SPECIES.length()) {
4963                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4964                 av.abs().intoArray(r, i);
4965             }
4966         }
4967 
4968         assertArraysEquals(r, a, LongMaxVectorTests::abs);
4969     }
4970 
4971     @Test(dataProvider = "longUnaryOpMaskProvider")
4972     static void ABSMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4973                                                 IntFunction<boolean[]> fm) {
4974         long[] a = fa.apply(SPECIES.length());
4975         long[] r = fr.apply(SPECIES.length());
4976         boolean[] mask = fm.apply(SPECIES.length());
4977         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4978 
4979         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4980             for (int i = 0; i < a.length; i += SPECIES.length()) {
4981                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4982                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4983             }
4984         }
4985 
4986         assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS);
4987     }
4988 
4989 
4990     static long NOT(long a) {
4991         return (long)(~((long)a));
4992     }
4993 
4994     static long not(long a) {
4995         return (long)(~((long)a));
4996     }
4997 
4998 
4999 
5000     @Test(dataProvider = "longUnaryOpProvider")
5001     static void NOTLongMaxVectorTests(IntFunction<long[]> fa) {
5002         long[] a = fa.apply(SPECIES.length());
5003         long[] r = fr.apply(SPECIES.length());
5004 
5005         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5006             for (int i = 0; i < a.length; i += SPECIES.length()) {
5007                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5008                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5009             }
5010         }
5011 
5012         assertArraysEquals(r, a, LongMaxVectorTests::NOT);
5013     }
5014 
5015     @Test(dataProvider = "longUnaryOpProvider")
5016     static void notLongMaxVectorTests(IntFunction<long[]> fa) {
5017         long[] a = fa.apply(SPECIES.length());
5018         long[] r = fr.apply(SPECIES.length());
5019 
5020         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5021             for (int i = 0; i < a.length; i += SPECIES.length()) {
5022                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5023                 av.not().intoArray(r, i);
5024             }
5025         }
5026 
5027         assertArraysEquals(r, a, LongMaxVectorTests::not);
5028     }
5029 
5030 
5031 
5032     @Test(dataProvider = "longUnaryOpMaskProvider")
5033     static void NOTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5034                                                 IntFunction<boolean[]> fm) {
5035         long[] a = fa.apply(SPECIES.length());
5036         long[] r = fr.apply(SPECIES.length());
5037         boolean[] mask = fm.apply(SPECIES.length());
5038         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5039 
5040         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5041             for (int i = 0; i < a.length; i += SPECIES.length()) {
5042                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5043                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5044             }
5045         }
5046 
5047         assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT);
5048     }
5049 
5050 
5051 
5052     static long ZOMO(long a) {
5053         return (long)((a==0?0:-1));
5054     }
5055 
5056 
5057 
5058     @Test(dataProvider = "longUnaryOpProvider")
5059     static void ZOMOLongMaxVectorTests(IntFunction<long[]> fa) {
5060         long[] a = fa.apply(SPECIES.length());
5061         long[] r = fr.apply(SPECIES.length());
5062 
5063         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5064             for (int i = 0; i < a.length; i += SPECIES.length()) {
5065                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5066                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5067             }
5068         }
5069 
5070         assertArraysEquals(r, a, LongMaxVectorTests::ZOMO);
5071     }
5072 
5073 
5074 
5075     @Test(dataProvider = "longUnaryOpMaskProvider")
5076     static void ZOMOMaskedLongMaxVectorTests(IntFunction<long[]> fa,
5077                                                 IntFunction<boolean[]> fm) {
5078         long[] a = fa.apply(SPECIES.length());
5079         long[] r = fr.apply(SPECIES.length());
5080         boolean[] mask = fm.apply(SPECIES.length());
5081         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5082 
5083         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5084             for (int i = 0; i < a.length; i += SPECIES.length()) {
5085                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5086                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5087             }
5088         }
5089 
5090         assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO);
5091     }
5092 
5093 
5094 
5095 
5096 
5097     @Test(dataProvider = "longCompareOpProvider")
5098     static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5099         long[] a = fa.apply(SPECIES.length());
5100         long[] b = fb.apply(SPECIES.length());
5101 
5102         for (int i = 0; i < a.length; i += SPECIES.length()) {
5103             LongVector av = LongVector.fromArray(SPECIES, a, i);
5104             VectorMask<Long> mv = av.lt(b[i]);
5105 
5106             // Check results as part of computation.
5107             for (int j = 0; j < SPECIES.length(); j++) {
5108                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5109             }
5110         }
5111     }
5112 
5113     @Test(dataProvider = "longCompareOpProvider")
5114     static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5115         long[] a = fa.apply(SPECIES.length());
5116         long[] b = fb.apply(SPECIES.length());
5117 
5118         for (int i = 0; i < a.length; i += SPECIES.length()) {
5119             LongVector av = LongVector.fromArray(SPECIES, a, i);
5120             VectorMask<Long> mv = av.eq(b[i]);
5121 
5122             // Check results as part of computation.
5123             for (int j = 0; j < SPECIES.length(); j++) {
5124                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5125             }
5126         }
5127     }
5128 
5129     @Test(dataProvider = "longtoIntUnaryOpProvider")
5130     static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5131         long[] a = fa.apply(SPECIES.length());
5132 
5133         for (int i = 0; i < a.length; i += SPECIES.length()) {
5134             LongVector av = LongVector.fromArray(SPECIES, a, i);
5135             int[] r = av.toIntArray();
5136             assertArraysEquals(r, a, i);
5137         }
5138     }
5139 
5140     @Test(dataProvider = "longUnaryOpProvider")
5141     static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5142         long[] a = fa.apply(SPECIES.length());
5143 
5144         for (int i = 0; i < a.length; i += SPECIES.length()) {
5145             LongVector av = LongVector.fromArray(SPECIES, a, i);
5146             long[] r = av.toLongArray();
5147             assertArraysEquals(r, a, i);
5148         }
5149     }
5150 
5151     @Test(dataProvider = "longUnaryOpProvider")
5152     static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5153         long[] a = fa.apply(SPECIES.length());
5154 
5155         for (int i = 0; i < a.length; i += SPECIES.length()) {
5156             LongVector av = LongVector.fromArray(SPECIES, a, i);
5157             double[] r = av.toDoubleArray();
5158             assertArraysEquals(r, a, i);
5159         }
5160     }
5161 
5162     @Test(dataProvider = "longUnaryOpProvider")
5163     static void toStringLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5164         long[] a = fa.apply(SPECIES.length());
5165 
5166         for (int i = 0; i < a.length; i += SPECIES.length()) {
5167             LongVector av = LongVector.fromArray(SPECIES, a, i);
5168             String str = av.toString();
5169 
5170             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5171             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5172         }
5173     }
5174 
5175     @Test(dataProvider = "longUnaryOpProvider")
5176     static void hashCodeLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5177         long[] a = fa.apply(SPECIES.length());
5178 
5179         for (int i = 0; i < a.length; i += SPECIES.length()) {
5180             LongVector av = LongVector.fromArray(SPECIES, a, i);
5181             int hash = av.hashCode();
5182 
5183             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5184             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5185             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5186         }
5187     }
5188 
5189 
5190 
5191     @Test(dataProvider = "longUnaryOpProvider")
5192     static void ADDReduceLongLongMaxVectorTests(IntFunction<long[]> fa) {
5193         long[] a = fa.apply(SPECIES.length());
5194         long[] r = fr.apply(SPECIES.length());
5195         long ra = 0;
5196 
5197         for (int i = 0; i < a.length; i += SPECIES.length()) {
5198             LongVector av = LongVector.fromArray(SPECIES, a, i);
5199             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5200         }
5201 
5202         ra = 0;
5203         for (int i = 0; i < a.length; i ++) {
5204             ra += r[i];
5205         }
5206 
5207         assertReductionArraysEquals(r, ra, a,
5208                 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll);
5209     }
5210 
5211     @Test(dataProvider = "longUnaryOpMaskProvider")
5212     static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
5213         long[] a = fa.apply(SPECIES.length());
5214         long[] r = fr.apply(SPECIES.length());
5215         boolean[] mask = fm.apply(SPECIES.length());
5216         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5217         long ra = 0;
5218 
5219         for (int i = 0; i < a.length; i += SPECIES.length()) {
5220             LongVector av = LongVector.fromArray(SPECIES, a, i);
5221             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5222         }
5223 
5224         ra = 0;
5225         for (int i = 0; i < a.length; i ++) {
5226             ra += r[i];
5227         }
5228 
5229         assertReductionArraysEqualsMasked(r, ra, a, mask,
5230                 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked);
5231     }
5232 
5233     @Test(dataProvider = "longUnaryOpSelectFromProvider")
5234     static void SelectFromLongMaxVectorTests(IntFunction<long[]> fa,
5235                                            BiFunction<Integer,Integer,long[]> fs) {
5236         long[] a = fa.apply(SPECIES.length());
5237         long[] order = fs.apply(a.length, SPECIES.length());
5238         long[] r = fr.apply(SPECIES.length());
5239 
5240         for (int i = 0; i < a.length; i += SPECIES.length()) {
5241             LongVector av = LongVector.fromArray(SPECIES, a, i);
5242             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5243             bv.selectFrom(av).intoArray(r, i);
5244         }
5245 
5246         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5247     }
5248 
5249     @Test(dataProvider = "longUnaryOpSelectFromMaskProvider")
5250     static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
5251                                                            BiFunction<Integer,Integer,long[]> fs,
5252                                                            IntFunction<boolean[]> fm) {
5253         long[] a = fa.apply(SPECIES.length());
5254         long[] order = fs.apply(a.length, SPECIES.length());
5255         long[] r = fr.apply(SPECIES.length());
5256         boolean[] mask = fm.apply(SPECIES.length());
5257         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5258 
5259         for (int i = 0; i < a.length; i += SPECIES.length()) {
5260             LongVector av = LongVector.fromArray(SPECIES, a, i);
5261             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5262             bv.selectFrom(av, vmask).intoArray(r, i);
5263         }
5264 
5265         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5266     }
5267 
5268     @Test(dataProvider = "shuffleProvider")
5269     static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5270         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5271 
5272         for (int i = 0; i < a.length; i += SPECIES.length()) {
5273             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5274             int hash = shuffle.hashCode();
5275             int length = shuffle.length();
5276 
5277             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5278             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5279             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5280             Assert.assertEquals(length, SPECIES.length());
5281         }
5282     }
5283 
5284     @Test(dataProvider = "shuffleProvider")
5285     static void shuffleToStringLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5286         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5287 
5288         for (int i = 0; i < a.length; i += SPECIES.length()) {
5289             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5290             String str = shuffle.toString();
5291 
5292             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5293             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5294                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5295         }
5296     }
5297 
5298     @Test(dataProvider = "shuffleCompareOpProvider")
5299     static void shuffleEqualsLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5300         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5301         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5302 
5303         for (int i = 0; i < a.length; i += SPECIES.length()) {
5304             var av = VectorShuffle.fromArray(SPECIES, a, i);
5305             var bv = VectorShuffle.fromArray(SPECIES, b, i);
5306             boolean eq = av.equals(bv);
5307             int to = i + SPECIES.length();
5308             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5309         }
5310     }
5311 
5312     @Test(dataProvider = "maskCompareOpProvider")
5313     static void maskEqualsLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5314         boolean[] a = fa.apply(SPECIES.length());
5315         boolean[] b = fb.apply(SPECIES.length());
5316 
5317         for (int i = 0; i < a.length; i += SPECIES.length()) {
5318             var av = SPECIES.loadMask(a, i);
5319             var bv = SPECIES.loadMask(b, i);
5320             boolean equals = av.equals(bv);
5321             int to = i + SPECIES.length();
5322             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5323         }
5324     }
5325 
5326     static boolean beq(boolean a, boolean b) {
5327         return (a == b);
5328     }
5329 
5330     @Test(dataProvider = "maskCompareOpProvider")
5331     static void maskEqLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5332         boolean[] a = fa.apply(SPECIES.length());
5333         boolean[] b = fb.apply(SPECIES.length());
5334         boolean[] r = new boolean[a.length];
5335 
5336         for (int i = 0; i < a.length; i += SPECIES.length()) {
5337             var av = SPECIES.loadMask(a, i);
5338             var bv = SPECIES.loadMask(b, i);
5339             var cv = av.eq(bv);
5340             cv.intoArray(r, i);
5341         }
5342         assertArraysEquals(r, a, b, LongMaxVectorTests::beq);
5343     }
5344 
5345     @Test(dataProvider = "maskProvider")
5346     static void maskHashCodeLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5347         boolean[] a = fa.apply(SPECIES.length());
5348 
5349         for (int i = 0; i < a.length; i += SPECIES.length()) {
5350             var vmask = SPECIES.loadMask(a, i);
5351             int hash = vmask.hashCode();
5352 
5353             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5354             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5355             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5356         }
5357     }
5358 
5359     static int maskTrueCount(boolean[] a, int idx) {
5360         int trueCount = 0;
5361         for (int i = idx; i < idx + SPECIES.length(); i++) {
5362             trueCount += a[i] ? 1 : 0;
5363         }
5364         return trueCount;
5365     }
5366 
5367     @Test(dataProvider = "maskProvider")
5368     static void maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5369         boolean[] a = fa.apply(SPECIES.length());
5370         int[] r = new int[a.length];
5371 
5372         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5373             for (int i = 0; i < a.length; i += SPECIES.length()) {
5374                 var vmask = SPECIES.loadMask(a, i);
5375                 r[i] = vmask.trueCount();
5376             }
5377         }
5378 
5379         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskTrueCount);
5380     }
5381 
5382     static int maskLastTrue(boolean[] a, int idx) {
5383         int i = idx + SPECIES.length() - 1;
5384         for (; i >= idx; i--) {
5385             if (a[i]) {
5386                 break;
5387             }
5388         }
5389         return i - idx;
5390     }
5391 
5392     @Test(dataProvider = "maskProvider")
5393     static void maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5394         boolean[] a = fa.apply(SPECIES.length());
5395         int[] r = new int[a.length];
5396 
5397         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5398             for (int i = 0; i < a.length; i += SPECIES.length()) {
5399                 var vmask = SPECIES.loadMask(a, i);
5400                 r[i] = vmask.lastTrue();
5401             }
5402         }
5403 
5404         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskLastTrue);
5405     }
5406 
5407     static int maskFirstTrue(boolean[] a, int idx) {
5408         int i = idx;
5409         for (; i < idx + SPECIES.length(); i++) {
5410             if (a[i]) {
5411                 break;
5412             }
5413         }
5414         return i - idx;
5415     }
5416 
5417     @Test(dataProvider = "maskProvider")
5418     static void maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5419         boolean[] a = fa.apply(SPECIES.length());
5420         int[] r = new int[a.length];
5421 
5422         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5423             for (int i = 0; i < a.length; i += SPECIES.length()) {
5424                 var vmask = SPECIES.loadMask(a, i);
5425                 r[i] = vmask.firstTrue();
5426             }
5427         }
5428 
5429         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue);
5430     }
5431 
5432     @Test(dataProvider = "maskProvider")
5433     static void maskCompressLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5434         int trueCount = 0;
5435         boolean[] a = fa.apply(SPECIES.length());
5436 
5437         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5438             for (int i = 0; i < a.length; i += SPECIES.length()) {
5439                 var vmask = SPECIES.loadMask(a, i);
5440                 trueCount = vmask.trueCount();
5441                 var rmask = vmask.compress();
5442                 for (int j = 0; j < SPECIES.length(); j++)  {
5443                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5444                 }
5445             }
5446         }
5447     }
5448 
5449 
5450     @DataProvider
5451     public static Object[][] offsetProvider() {
5452         return new Object[][]{
5453                 {0},
5454                 {-1},
5455                 {+1},
5456                 {+2},
5457                 {-2},
5458         };
5459     }
5460 
5461     @Test(dataProvider = "offsetProvider")
5462     static void indexInRangeLongMaxVectorTestsSmokeTest(int offset) {
5463         int limit = SPECIES.length() * BUFFER_REPS;
5464         for (int i = 0; i < limit; i += SPECIES.length()) {
5465             var actualMask = SPECIES.indexInRange(i + offset, limit);
5466             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5467             assert(actualMask.equals(expectedMask));
5468             for (int j = 0; j < SPECIES.length(); j++)  {
5469                 int index = i + j + offset;
5470                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5471             }
5472         }
5473     }
5474 
5475     @DataProvider
5476     public static Object[][] lengthProvider() {
5477         return new Object[][]{
5478                 {0},
5479                 {1},
5480                 {32},
5481                 {37},
5482                 {1024},
5483                 {1024+1},
5484                 {1024+5},
5485         };
5486     }
5487 
5488     @Test(dataProvider = "lengthProvider")
5489     static void loopBoundLongMaxVectorTestsSmokeTest(int length) {
5490         int actualLoopBound = SPECIES.loopBound(length);
5491         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5492         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5493     }
5494 
5495     @Test
5496     static void ElementSizeLongMaxVectorTestsSmokeTest() {
5497         LongVector av = LongVector.zero(SPECIES);
5498         int elsize = av.elementSize();
5499         Assert.assertEquals(elsize, Long.SIZE);
5500     }
5501 
5502     @Test
5503     static void VectorShapeLongMaxVectorTestsSmokeTest() {
5504         LongVector av = LongVector.zero(SPECIES);
5505         VectorShape vsh = av.shape();
5506         assert(vsh.equals(VectorShape.S_Max_BIT));
5507     }
5508 
5509     @Test
5510     static void ShapeWithLanesLongMaxVectorTestsSmokeTest() {
5511         LongVector av = LongVector.zero(SPECIES);
5512         VectorShape vsh = av.shape();
5513         VectorSpecies species = vsh.withLanes(long.class);
5514         assert(species.equals(SPECIES));
5515     }
5516 
5517     @Test
5518     static void ElementTypeLongMaxVectorTestsSmokeTest() {
5519         LongVector av = LongVector.zero(SPECIES);
5520         assert(av.species().elementType() == long.class);
5521     }
5522 
5523     @Test
5524     static void SpeciesElementSizeLongMaxVectorTestsSmokeTest() {
5525         LongVector av = LongVector.zero(SPECIES);
5526         assert(av.species().elementSize() == Long.SIZE);
5527     }
5528 
5529     @Test
5530     static void VectorTypeLongMaxVectorTestsSmokeTest() {
5531         LongVector av = LongVector.zero(SPECIES);
5532         assert(av.species().vectorType() == av.getClass());
5533     }
5534 
5535     @Test
5536     static void WithLanesLongMaxVectorTestsSmokeTest() {
5537         LongVector av = LongVector.zero(SPECIES);
5538         VectorSpecies species = av.species().withLanes(long.class);
5539         assert(species.equals(SPECIES));
5540     }
5541 
5542     @Test
5543     static void WithShapeLongMaxVectorTestsSmokeTest() {
5544         LongVector av = LongVector.zero(SPECIES);
5545         VectorShape vsh = av.shape();
5546         VectorSpecies species = av.species().withShape(vsh);
5547         assert(species.equals(SPECIES));
5548     }
5549 
5550     @Test
5551     static void MaskAllTrueLongMaxVectorTestsSmokeTest() {
5552         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5553           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5554         }
5555     }
5556 }
5557 
--- EOF ---