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