1 /*
   2  * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation LongMaxVectorTests
  28  */
  29 
  30 // -- This file was mechanically generated: Do not edit! -- //
  31 
  32 import jdk.incubator.vector.VectorShape;
  33 import jdk.incubator.vector.VectorSpecies;
  34 import jdk.incubator.vector.VectorShuffle;
  35 import jdk.incubator.vector.VectorMask;
  36 import jdk.incubator.vector.VectorOperators;
  37 import jdk.incubator.vector.Vector;
  38 
  39 import jdk.incubator.vector.LongVector;
  40 
  41 import org.testng.Assert;
  42 import org.testng.annotations.DataProvider;
  43 import org.testng.annotations.Test;
  44 
  45 import java.lang.Integer;
  46 import java.util.List;
  47 import java.util.Arrays;
  48 import java.util.function.BiFunction;
  49 import java.util.function.IntFunction;
  50 import java.util.Objects;
  51 import java.util.stream.Collectors;
  52 import java.util.stream.Stream;
  53 
  54 @Test
  55 public class LongMaxVectorTests extends AbstractVectorTest {
  56 
  57     static final VectorSpecies<Long> SPECIES =
  58                 LongVector.SPECIES_MAX;
  59 
  60     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  61 
  62     static VectorShape getMaxBit() {
  63         return VectorShape.S_Max_BIT;
  64     }
  65 
  66     private static final int Max = 256;  // juts so we can do N/Max
  67 
  68     static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
  69 
  70     interface FUnOp {
  71         long apply(long a);
  72     }
  73 
  74     static void assertArraysEquals(long[] r, long[] a, FUnOp f) {
  75         int i = 0;
  76         try {
  77             for (; i < a.length; i++) {
  78                 Assert.assertEquals(r[i], f.apply(a[i]));
  79             }
  80         } catch (AssertionError e) {
  81             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  82         }
  83     }
  84 
  85     interface FUnArrayOp {
  86         long[] apply(long a);
  87     }
  88 
  89     static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) {
  90         int i = 0;
  91         try {
  92             for (; i < a.length; i += SPECIES.length()) {
  93                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
  94                   f.apply(a[i]));
  95             }
  96         } catch (AssertionError e) {
  97             long[] ref = f.apply(a[i]);
  98             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
  99             Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
 100               + ", res: " + Arrays.toString(res)
 101               + "), at index #" + i);
 102         }
 103     }
 104 
 105     static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) {
 106         int i = 0;
 107         try {
 108             for (; i < a.length; i++) {
 109                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
 110             }
 111         } catch (AssertionError e) {
 112             Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
 113         }
 114     }
 115 
 116     interface FReductionOp {
 117         long apply(long[] a, int idx);
 118     }
 119 
 120     interface FReductionAllOp {
 121         long apply(long[] a);
 122     }
 123 
 124     static void assertReductionArraysEquals(long[] r, long rc, long[] a,
 125                                             FReductionOp f, FReductionAllOp fa) {
 126         int i = 0;
 127         try {
 128             Assert.assertEquals(rc, fa.apply(a));
 129             for (; i < a.length; i += SPECIES.length()) {
 130                 Assert.assertEquals(r[i], f.apply(a, i));
 131             }
 132         } catch (AssertionError e) {
 133             Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
 134             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 135         }
 136     }
 137 
 138     interface FReductionMaskedOp {
 139         long apply(long[] a, int idx, boolean[] mask);
 140     }
 141 
 142     interface FReductionAllMaskedOp {
 143         long apply(long[] a, boolean[] mask);
 144     }
 145 
 146     static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask,
 147                                             FReductionMaskedOp f, FReductionAllMaskedOp fa) {
 148         int i = 0;
 149         try {
 150             Assert.assertEquals(rc, fa.apply(a, mask));
 151             for (; i < a.length; i += SPECIES.length()) {
 152                 Assert.assertEquals(r[i], f.apply(a, i, mask));
 153             }
 154         } catch (AssertionError e) {
 155             Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
 156             Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
 157         }
 158     }
 159 
 160 
 161     interface FBoolReductionOp {
 162         boolean apply(boolean[] a, int idx);
 163     }
 164 
 165     static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
 166         int i = 0;
 167         try {
 168             for (; i < a.length; i += SPECIES.length()) {
 169                 Assert.assertEquals(r[i], f.apply(a, i));
 170             }
 171         } catch (AssertionError e) {
 172             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 173         }
 174     }
 175 
 176     interface FMaskReductionOp {
 177         int apply(boolean[] a, int idx);
 178     }
 179 
 180     static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
 181         int i = 0;
 182         try {
 183             for (; i < a.length; i += SPECIES.length()) {
 184                 Assert.assertEquals(r[i], f.apply(a, i));
 185             }
 186         } catch (AssertionError e) {
 187             Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
 188         }
 189     }
 190 
 191     static void assertInsertArraysEquals(long[] r, long[] a, long element, int index, int start, int end) {
 192         int i = start;
 193         try {
 194             for (; i < end; i += 1) {
 195                 if(i%SPECIES.length() == index) {
 196                     Assert.assertEquals(r[i], element);
 197                 } else {
 198                     Assert.assertEquals(r[i], a[i]);
 199                 }
 200             }
 201         } catch (AssertionError e) {
 202             if (i%SPECIES.length() == index) {
 203                 Assert.assertEquals(r[i], element, "at index #" + i);
 204             } else {
 205                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 206             }
 207         }
 208     }
 209 
 210     static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) {
 211         int i = 0, j = 0;
 212         try {
 213             for (; i < a.length; i += vector_len) {
 214                 for (j = 0; j < vector_len; j++) {
 215                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 216                 }
 217             }
 218         } catch (AssertionError e) {
 219             int idx = i + j;
 220             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 221         }
 222     }
 223 

















































 224     static void 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, j = 0; i < a.length; i += SPECIES.length()) {
3440                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3441                 av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i);
3442             }
3443         }
3444 
3445 
3446         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3447             assertInsertArraysEquals(r, a, (long)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3448         }
3449     }
3450     static boolean testIS_DEFAULT(long a) {
3451         return bits(a)==0;
3452     }
3453 
3454     @Test(dataProvider = "longTestOpProvider")
3455     static void IS_DEFAULTLongMaxVectorTests(IntFunction<long[]> fa) {
3456         long[] a = fa.apply(SPECIES.length());
3457 
3458         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3459             for (int i = 0; i < a.length; i += SPECIES.length()) {
3460                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3461                 VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);
3462 
3463                 // Check results as part of computation.
3464                 for (int j = 0; j < SPECIES.length(); j++) {
3465                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3466                 }
3467             }
3468         }
3469     }
3470 
3471     @Test(dataProvider = "longTestOpMaskProvider")
3472     static void IS_DEFAULTMaskedLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa,
3473                                           IntFunction<boolean[]> fm) {
3474         long[] a = fa.apply(SPECIES.length());
3475         boolean[] mask = fm.apply(SPECIES.length());
3476         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3477 
3478         for (int i = 0; i < a.length; i += SPECIES.length()) {
3479             LongVector av = LongVector.fromArray(SPECIES, a, i);
3480             VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3481 
3482             // Check results as part of computation.
3483             for (int j = 0; j < SPECIES.length(); j++) {
3484                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3485             }
3486         }
3487     }
3488     static boolean testIS_NEGATIVE(long a) {
3489         return bits(a)<0;
3490     }
3491 
3492     @Test(dataProvider = "longTestOpProvider")
3493     static void IS_NEGATIVELongMaxVectorTests(IntFunction<long[]> fa) {
3494         long[] a = fa.apply(SPECIES.length());
3495 
3496         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3497             for (int i = 0; i < a.length; i += SPECIES.length()) {
3498                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3499                 VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);
3500 
3501                 // Check results as part of computation.
3502                 for (int j = 0; j < SPECIES.length(); j++) {
3503                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3504                 }
3505             }
3506         }
3507     }
3508 
3509     @Test(dataProvider = "longTestOpMaskProvider")
3510     static void IS_NEGATIVEMaskedLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa,
3511                                           IntFunction<boolean[]> fm) {
3512         long[] a = fa.apply(SPECIES.length());
3513         boolean[] mask = fm.apply(SPECIES.length());
3514         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3515 
3516         for (int i = 0; i < a.length; i += SPECIES.length()) {
3517             LongVector av = LongVector.fromArray(SPECIES, a, i);
3518             VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3519 
3520             // Check results as part of computation.
3521             for (int j = 0; j < SPECIES.length(); j++) {
3522                 Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3523             }
3524         }
3525     }
3526 
3527 
3528 
3529 
3530     @Test(dataProvider = "longCompareOpProvider")
3531     static void LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3532         long[] a = fa.apply(SPECIES.length());
3533         long[] b = fb.apply(SPECIES.length());
3534 
3535         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3536             for (int i = 0; i < a.length; i += SPECIES.length()) {
3537                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3538                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3539                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);
3540 
3541                 // Check results as part of computation.
3542                 for (int j = 0; j < SPECIES.length(); j++) {
3543                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3544                 }
3545             }
3546         }
3547     }
3548 
3549 
3550     @Test(dataProvider = "longCompareOpProvider")
3551     static void ltLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3552         long[] a = fa.apply(SPECIES.length());
3553         long[] b = fb.apply(SPECIES.length());
3554 
3555         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3556             for (int i = 0; i < a.length; i += SPECIES.length()) {
3557                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3558                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3559                 VectorMask<Long> mv = av.lt(bv);
3560 
3561                 // Check results as part of computation.
3562                 for (int j = 0; j < SPECIES.length(); j++) {
3563                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3564                 }
3565             }
3566         }
3567     }
3568 
3569     @Test(dataProvider = "longCompareOpMaskProvider")
3570     static void LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3571                                                 IntFunction<boolean[]> fm) {
3572         long[] a = fa.apply(SPECIES.length());
3573         long[] b = fb.apply(SPECIES.length());
3574         boolean[] mask = fm.apply(SPECIES.length());
3575 
3576         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3577 
3578         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3579             for (int i = 0; i < a.length; i += SPECIES.length()) {
3580                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3581                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3582                 VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);
3583 
3584                 // Check results as part of computation.
3585                 for (int j = 0; j < SPECIES.length(); j++) {
3586                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3587                 }
3588             }
3589         }
3590     }
3591 
3592 
3593     @Test(dataProvider = "longCompareOpProvider")
3594     static void GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3595         long[] a = fa.apply(SPECIES.length());
3596         long[] b = fb.apply(SPECIES.length());
3597 
3598         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3599             for (int i = 0; i < a.length; i += SPECIES.length()) {
3600                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3601                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3602                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);
3603 
3604                 // Check results as part of computation.
3605                 for (int j = 0; j < SPECIES.length(); j++) {
3606                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3607                 }
3608             }
3609         }
3610     }
3611 
3612     @Test(dataProvider = "longCompareOpMaskProvider")
3613     static void GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3614                                                 IntFunction<boolean[]> fm) {
3615         long[] a = fa.apply(SPECIES.length());
3616         long[] b = fb.apply(SPECIES.length());
3617         boolean[] mask = fm.apply(SPECIES.length());
3618 
3619         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3620 
3621         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3622             for (int i = 0; i < a.length; i += SPECIES.length()) {
3623                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3624                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3625                 VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);
3626 
3627                 // Check results as part of computation.
3628                 for (int j = 0; j < SPECIES.length(); j++) {
3629                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3630                 }
3631             }
3632         }
3633     }
3634 
3635 
3636     @Test(dataProvider = "longCompareOpProvider")
3637     static void EQLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3638         long[] a = fa.apply(SPECIES.length());
3639         long[] b = fb.apply(SPECIES.length());
3640 
3641         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3642             for (int i = 0; i < a.length; i += SPECIES.length()) {
3643                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3644                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3645                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);
3646 
3647                 // Check results as part of computation.
3648                 for (int j = 0; j < SPECIES.length(); j++) {
3649                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3650                 }
3651             }
3652         }
3653     }
3654 
3655 
3656     @Test(dataProvider = "longCompareOpProvider")
3657     static void eqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3658         long[] a = fa.apply(SPECIES.length());
3659         long[] b = fb.apply(SPECIES.length());
3660 
3661         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3662             for (int i = 0; i < a.length; i += SPECIES.length()) {
3663                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3664                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3665                 VectorMask<Long> mv = av.eq(bv);
3666 
3667                 // Check results as part of computation.
3668                 for (int j = 0; j < SPECIES.length(); j++) {
3669                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3670                 }
3671             }
3672         }
3673     }
3674 
3675     @Test(dataProvider = "longCompareOpMaskProvider")
3676     static void EQLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3677                                                 IntFunction<boolean[]> fm) {
3678         long[] a = fa.apply(SPECIES.length());
3679         long[] b = fb.apply(SPECIES.length());
3680         boolean[] mask = fm.apply(SPECIES.length());
3681 
3682         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3683 
3684         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3685             for (int i = 0; i < a.length; i += SPECIES.length()) {
3686                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3687                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3688                 VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);
3689 
3690                 // Check results as part of computation.
3691                 for (int j = 0; j < SPECIES.length(); j++) {
3692                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3693                 }
3694             }
3695         }
3696     }
3697 
3698 
3699     @Test(dataProvider = "longCompareOpProvider")
3700     static void NELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3701         long[] a = fa.apply(SPECIES.length());
3702         long[] b = fb.apply(SPECIES.length());
3703 
3704         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3705             for (int i = 0; i < a.length; i += SPECIES.length()) {
3706                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3707                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3708                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);
3709 
3710                 // Check results as part of computation.
3711                 for (int j = 0; j < SPECIES.length(); j++) {
3712                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
3713                 }
3714             }
3715         }
3716     }
3717 
3718     @Test(dataProvider = "longCompareOpMaskProvider")
3719     static void NELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3720                                                 IntFunction<boolean[]> fm) {
3721         long[] a = fa.apply(SPECIES.length());
3722         long[] b = fb.apply(SPECIES.length());
3723         boolean[] mask = fm.apply(SPECIES.length());
3724 
3725         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3726 
3727         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3728             for (int i = 0; i < a.length; i += SPECIES.length()) {
3729                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3730                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3731                 VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);
3732 
3733                 // Check results as part of computation.
3734                 for (int j = 0; j < SPECIES.length(); j++) {
3735                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
3736                 }
3737             }
3738         }
3739     }
3740 
3741 
3742     @Test(dataProvider = "longCompareOpProvider")
3743     static void LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3744         long[] a = fa.apply(SPECIES.length());
3745         long[] b = fb.apply(SPECIES.length());
3746 
3747         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3748             for (int i = 0; i < a.length; i += SPECIES.length()) {
3749                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3750                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3751                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);
3752 
3753                 // Check results as part of computation.
3754                 for (int j = 0; j < SPECIES.length(); j++) {
3755                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
3756                 }
3757             }
3758         }
3759     }
3760 
3761     @Test(dataProvider = "longCompareOpMaskProvider")
3762     static void LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3763                                                 IntFunction<boolean[]> fm) {
3764         long[] a = fa.apply(SPECIES.length());
3765         long[] b = fb.apply(SPECIES.length());
3766         boolean[] mask = fm.apply(SPECIES.length());
3767 
3768         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3769 
3770         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3771             for (int i = 0; i < a.length; i += SPECIES.length()) {
3772                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3773                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3774                 VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);
3775 
3776                 // Check results as part of computation.
3777                 for (int j = 0; j < SPECIES.length(); j++) {
3778                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
3779                 }
3780             }
3781         }
3782     }
3783 
3784 
3785     @Test(dataProvider = "longCompareOpProvider")
3786     static void GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3787         long[] a = fa.apply(SPECIES.length());
3788         long[] b = fb.apply(SPECIES.length());
3789 
3790         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3791             for (int i = 0; i < a.length; i += SPECIES.length()) {
3792                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3793                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3794                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);
3795 
3796                 // Check results as part of computation.
3797                 for (int j = 0; j < SPECIES.length(); j++) {
3798                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
3799                 }
3800             }
3801         }
3802     }
3803 
3804     @Test(dataProvider = "longCompareOpMaskProvider")
3805     static void GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3806                                                 IntFunction<boolean[]> fm) {
3807         long[] a = fa.apply(SPECIES.length());
3808         long[] b = fb.apply(SPECIES.length());
3809         boolean[] mask = fm.apply(SPECIES.length());
3810 
3811         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3812 
3813         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3814             for (int i = 0; i < a.length; i += SPECIES.length()) {
3815                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3816                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3817                 VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);
3818 
3819                 // Check results as part of computation.
3820                 for (int j = 0; j < SPECIES.length(); j++) {
3821                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
3822                 }
3823             }
3824         }
3825     }
3826 
3827 
3828 
3829     @Test(dataProvider = "longCompareOpProvider")
3830     static void UNSIGNED_LTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3831         long[] a = fa.apply(SPECIES.length());
3832         long[] b = fb.apply(SPECIES.length());
3833 
3834         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3835             for (int i = 0; i < a.length; i += SPECIES.length()) {
3836                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3837                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3838                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
3839 
3840                 // Check results as part of computation.
3841                 for (int j = 0; j < SPECIES.length(); j++) {
3842                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
3843                 }
3844             }
3845         }
3846     }
3847 
3848 
3849 
3850     @Test(dataProvider = "longCompareOpMaskProvider")
3851     static void UNSIGNED_LTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3852                                                 IntFunction<boolean[]> fm) {
3853         long[] a = fa.apply(SPECIES.length());
3854         long[] b = fb.apply(SPECIES.length());
3855         boolean[] mask = fm.apply(SPECIES.length());
3856 
3857         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3858 
3859         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3860             for (int i = 0; i < a.length; i += SPECIES.length()) {
3861                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3862                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3863                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
3864 
3865                 // Check results as part of computation.
3866                 for (int j = 0; j < SPECIES.length(); j++) {
3867                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
3868                 }
3869             }
3870         }
3871     }
3872 
3873 
3874 
3875 
3876     @Test(dataProvider = "longCompareOpProvider")
3877     static void UNSIGNED_GTLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3878         long[] a = fa.apply(SPECIES.length());
3879         long[] b = fb.apply(SPECIES.length());
3880 
3881         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3882             for (int i = 0; i < a.length; i += SPECIES.length()) {
3883                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3884                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3885                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
3886 
3887                 // Check results as part of computation.
3888                 for (int j = 0; j < SPECIES.length(); j++) {
3889                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
3890                 }
3891             }
3892         }
3893     }
3894 
3895 
3896 
3897     @Test(dataProvider = "longCompareOpMaskProvider")
3898     static void UNSIGNED_GTLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3899                                                 IntFunction<boolean[]> fm) {
3900         long[] a = fa.apply(SPECIES.length());
3901         long[] b = fb.apply(SPECIES.length());
3902         boolean[] mask = fm.apply(SPECIES.length());
3903 
3904         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3905 
3906         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3907             for (int i = 0; i < a.length; i += SPECIES.length()) {
3908                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3909                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3910                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
3911 
3912                 // Check results as part of computation.
3913                 for (int j = 0; j < SPECIES.length(); j++) {
3914                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
3915                 }
3916             }
3917         }
3918     }
3919 
3920 
3921 
3922 
3923     @Test(dataProvider = "longCompareOpProvider")
3924     static void UNSIGNED_LELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3925         long[] a = fa.apply(SPECIES.length());
3926         long[] b = fb.apply(SPECIES.length());
3927 
3928         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3929             for (int i = 0; i < a.length; i += SPECIES.length()) {
3930                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3931                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3932                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
3933 
3934                 // Check results as part of computation.
3935                 for (int j = 0; j < SPECIES.length(); j++) {
3936                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
3937                 }
3938             }
3939         }
3940     }
3941 
3942 
3943 
3944     @Test(dataProvider = "longCompareOpMaskProvider")
3945     static void UNSIGNED_LELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3946                                                 IntFunction<boolean[]> fm) {
3947         long[] a = fa.apply(SPECIES.length());
3948         long[] b = fb.apply(SPECIES.length());
3949         boolean[] mask = fm.apply(SPECIES.length());
3950 
3951         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3952 
3953         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3954             for (int i = 0; i < a.length; i += SPECIES.length()) {
3955                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3956                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3957                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
3958 
3959                 // Check results as part of computation.
3960                 for (int j = 0; j < SPECIES.length(); j++) {
3961                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
3962                 }
3963             }
3964         }
3965     }
3966 
3967 
3968 
3969 
3970     @Test(dataProvider = "longCompareOpProvider")
3971     static void UNSIGNED_GELongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
3972         long[] a = fa.apply(SPECIES.length());
3973         long[] b = fb.apply(SPECIES.length());
3974 
3975         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3976             for (int i = 0; i < a.length; i += SPECIES.length()) {
3977                 LongVector av = LongVector.fromArray(SPECIES, a, i);
3978                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
3979                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
3980 
3981                 // Check results as part of computation.
3982                 for (int j = 0; j < SPECIES.length(); j++) {
3983                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
3984                 }
3985             }
3986         }
3987     }
3988 
3989 
3990 
3991     @Test(dataProvider = "longCompareOpMaskProvider")
3992     static void UNSIGNED_GELongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
3993                                                 IntFunction<boolean[]> fm) {
3994         long[] a = fa.apply(SPECIES.length());
3995         long[] b = fb.apply(SPECIES.length());
3996         boolean[] mask = fm.apply(SPECIES.length());
3997 
3998         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3999 
4000         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4001             for (int i = 0; i < a.length; i += SPECIES.length()) {
4002                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4003                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4004                 VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4005 
4006                 // Check results as part of computation.
4007                 for (int j = 0; j < SPECIES.length(); j++) {
4008                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4009                 }
4010             }
4011         }
4012     }
4013 
4014 
4015 
4016     @Test(dataProvider = "longCompareOpProvider")
4017     static void LTLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4018         long[] a = fa.apply(SPECIES.length());
4019         long[] b = fb.apply(SPECIES.length());
4020 
4021         for (int i = 0; i < a.length; i += SPECIES.length()) {
4022             LongVector av = LongVector.fromArray(SPECIES, a, i);
4023             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);
4024 
4025             // Check results as part of computation.
4026             for (int j = 0; j < SPECIES.length(); j++) {
4027                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4028             }
4029         }
4030     }
4031 
4032 
4033     @Test(dataProvider = "longCompareOpMaskProvider")
4034     static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4035                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4036         long[] a = fa.apply(SPECIES.length());
4037         long[] b = fb.apply(SPECIES.length());
4038         boolean[] mask = fm.apply(SPECIES.length());
4039 
4040         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4041 
4042         for (int i = 0; i < a.length; i += SPECIES.length()) {
4043             LongVector av = LongVector.fromArray(SPECIES, a, i);
4044             VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);
4045 
4046             // Check results as part of computation.
4047             for (int j = 0; j < SPECIES.length(); j++) {
4048                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4049             }
4050         }
4051     }
4052 
4053 
4054     @Test(dataProvider = "longCompareOpProvider")
4055     static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4056         long[] a = fa.apply(SPECIES.length());
4057         long[] b = fb.apply(SPECIES.length());
4058 
4059         for (int i = 0; i < a.length; i += SPECIES.length()) {
4060             LongVector av = LongVector.fromArray(SPECIES, a, i);
4061             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);
4062 
4063             // Check results as part of computation.
4064             for (int j = 0; j < SPECIES.length(); j++) {
4065                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4066             }
4067         }
4068     }
4069 
4070 
4071     @Test(dataProvider = "longCompareOpMaskProvider")
4072     static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,
4073                                 IntFunction<long[]> fb, IntFunction<boolean[]> fm) {
4074         long[] a = fa.apply(SPECIES.length());
4075         long[] b = fb.apply(SPECIES.length());
4076         boolean[] mask = fm.apply(SPECIES.length());
4077 
4078         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4079 
4080         for (int i = 0; i < a.length; i += SPECIES.length()) {
4081             LongVector av = LongVector.fromArray(SPECIES, a, i);
4082             VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4083 
4084             // Check results as part of computation.
4085             for (int j = 0; j < SPECIES.length(); j++) {
4086                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4087             }
4088         }
4089     }
4090 
4091 
4092     static long blend(long a, long b, boolean mask) {
4093         return mask ? b : a;
4094     }
4095 
4096     @Test(dataProvider = "longBinaryOpMaskProvider")
4097     static void blendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
4098                                           IntFunction<boolean[]> fm) {
4099         long[] a = fa.apply(SPECIES.length());
4100         long[] b = fb.apply(SPECIES.length());
4101         long[] r = fr.apply(SPECIES.length());
4102         boolean[] mask = fm.apply(SPECIES.length());
4103         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4104 
4105         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4106             for (int i = 0; i < a.length; i += SPECIES.length()) {
4107                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4108                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4109                 av.blend(bv, vmask).intoArray(r, i);
4110             }
4111         }
4112 
4113         assertArraysEquals(r, a, b, mask, LongMaxVectorTests::blend);
4114     }
4115 
4116     @Test(dataProvider = "longUnaryOpShuffleProvider")
4117     static void RearrangeLongMaxVectorTests(IntFunction<long[]> fa,
4118                                            BiFunction<Integer,Integer,int[]> fs) {
4119         long[] a = fa.apply(SPECIES.length());
4120         int[] order = fs.apply(a.length, SPECIES.length());
4121         long[] r = fr.apply(SPECIES.length());
4122 
4123         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4124             for (int i = 0; i < a.length; i += SPECIES.length()) {
4125                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4126                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
4127             }
4128         }
4129 
4130         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4131     }
4132 
4133     @Test(dataProvider = "longUnaryOpShuffleMaskProvider")
4134     static void RearrangeLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
4135                                                           BiFunction<Integer,Integer,int[]> fs,
4136                                                           IntFunction<boolean[]> fm) {
4137         long[] a = fa.apply(SPECIES.length());
4138         int[] order = fs.apply(a.length, SPECIES.length());
4139         long[] r = fr.apply(SPECIES.length());
4140         boolean[] mask = fm.apply(SPECIES.length());
4141         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4142 
4143         for (int i = 0; i < a.length; i += SPECIES.length()) {
4144             LongVector av = LongVector.fromArray(SPECIES, a, i);
4145             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4146         }
4147 
4148         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4149     }




































4150     @Test(dataProvider = "longUnaryOpProvider")
4151     static void getLongMaxVectorTests(IntFunction<long[]> fa) {
4152         long[] a = fa.apply(SPECIES.length());
4153         long[] r = fr.apply(SPECIES.length());
4154 
4155         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4156             for (int i = 0; i < a.length; i += SPECIES.length()) {
4157                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4158                 int num_lanes = SPECIES.length();
4159                 // Manually unroll because full unroll happens after intrinsification.
4160                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4161                 if (num_lanes == 1) {
4162                     r[i]=av.lane(0);
4163                 } else if (num_lanes == 2) {
4164                     r[i]=av.lane(0);
4165                     r[i+1]=av.lane(1);
4166                 } else if (num_lanes == 4) {
4167                     r[i]=av.lane(0);
4168                     r[i+1]=av.lane(1);
4169                     r[i+2]=av.lane(2);
4170                     r[i+3]=av.lane(3);
4171                 } else if (num_lanes == 8) {
4172                     r[i]=av.lane(0);
4173                     r[i+1]=av.lane(1);
4174                     r[i+2]=av.lane(2);
4175                     r[i+3]=av.lane(3);
4176                     r[i+4]=av.lane(4);
4177                     r[i+5]=av.lane(5);
4178                     r[i+6]=av.lane(6);
4179                     r[i+7]=av.lane(7);
4180                 } else if (num_lanes == 16) {
4181                     r[i]=av.lane(0);
4182                     r[i+1]=av.lane(1);
4183                     r[i+2]=av.lane(2);
4184                     r[i+3]=av.lane(3);
4185                     r[i+4]=av.lane(4);
4186                     r[i+5]=av.lane(5);
4187                     r[i+6]=av.lane(6);
4188                     r[i+7]=av.lane(7);
4189                     r[i+8]=av.lane(8);
4190                     r[i+9]=av.lane(9);
4191                     r[i+10]=av.lane(10);
4192                     r[i+11]=av.lane(11);
4193                     r[i+12]=av.lane(12);
4194                     r[i+13]=av.lane(13);
4195                     r[i+14]=av.lane(14);
4196                     r[i+15]=av.lane(15);
4197                 } else if (num_lanes == 32) {
4198                     r[i]=av.lane(0);
4199                     r[i+1]=av.lane(1);
4200                     r[i+2]=av.lane(2);
4201                     r[i+3]=av.lane(3);
4202                     r[i+4]=av.lane(4);
4203                     r[i+5]=av.lane(5);
4204                     r[i+6]=av.lane(6);
4205                     r[i+7]=av.lane(7);
4206                     r[i+8]=av.lane(8);
4207                     r[i+9]=av.lane(9);
4208                     r[i+10]=av.lane(10);
4209                     r[i+11]=av.lane(11);
4210                     r[i+12]=av.lane(12);
4211                     r[i+13]=av.lane(13);
4212                     r[i+14]=av.lane(14);
4213                     r[i+15]=av.lane(15);
4214                     r[i+16]=av.lane(16);
4215                     r[i+17]=av.lane(17);
4216                     r[i+18]=av.lane(18);
4217                     r[i+19]=av.lane(19);
4218                     r[i+20]=av.lane(20);
4219                     r[i+21]=av.lane(21);
4220                     r[i+22]=av.lane(22);
4221                     r[i+23]=av.lane(23);
4222                     r[i+24]=av.lane(24);
4223                     r[i+25]=av.lane(25);
4224                     r[i+26]=av.lane(26);
4225                     r[i+27]=av.lane(27);
4226                     r[i+28]=av.lane(28);
4227                     r[i+29]=av.lane(29);
4228                     r[i+30]=av.lane(30);
4229                     r[i+31]=av.lane(31);
4230                 } else if (num_lanes == 64) {
4231                     r[i]=av.lane(0);
4232                     r[i+1]=av.lane(1);
4233                     r[i+2]=av.lane(2);
4234                     r[i+3]=av.lane(3);
4235                     r[i+4]=av.lane(4);
4236                     r[i+5]=av.lane(5);
4237                     r[i+6]=av.lane(6);
4238                     r[i+7]=av.lane(7);
4239                     r[i+8]=av.lane(8);
4240                     r[i+9]=av.lane(9);
4241                     r[i+10]=av.lane(10);
4242                     r[i+11]=av.lane(11);
4243                     r[i+12]=av.lane(12);
4244                     r[i+13]=av.lane(13);
4245                     r[i+14]=av.lane(14);
4246                     r[i+15]=av.lane(15);
4247                     r[i+16]=av.lane(16);
4248                     r[i+17]=av.lane(17);
4249                     r[i+18]=av.lane(18);
4250                     r[i+19]=av.lane(19);
4251                     r[i+20]=av.lane(20);
4252                     r[i+21]=av.lane(21);
4253                     r[i+22]=av.lane(22);
4254                     r[i+23]=av.lane(23);
4255                     r[i+24]=av.lane(24);
4256                     r[i+25]=av.lane(25);
4257                     r[i+26]=av.lane(26);
4258                     r[i+27]=av.lane(27);
4259                     r[i+28]=av.lane(28);
4260                     r[i+29]=av.lane(29);
4261                     r[i+30]=av.lane(30);
4262                     r[i+31]=av.lane(31);
4263                     r[i+32]=av.lane(32);
4264                     r[i+33]=av.lane(33);
4265                     r[i+34]=av.lane(34);
4266                     r[i+35]=av.lane(35);
4267                     r[i+36]=av.lane(36);
4268                     r[i+37]=av.lane(37);
4269                     r[i+38]=av.lane(38);
4270                     r[i+39]=av.lane(39);
4271                     r[i+40]=av.lane(40);
4272                     r[i+41]=av.lane(41);
4273                     r[i+42]=av.lane(42);
4274                     r[i+43]=av.lane(43);
4275                     r[i+44]=av.lane(44);
4276                     r[i+45]=av.lane(45);
4277                     r[i+46]=av.lane(46);
4278                     r[i+47]=av.lane(47);
4279                     r[i+48]=av.lane(48);
4280                     r[i+49]=av.lane(49);
4281                     r[i+50]=av.lane(50);
4282                     r[i+51]=av.lane(51);
4283                     r[i+52]=av.lane(52);
4284                     r[i+53]=av.lane(53);
4285                     r[i+54]=av.lane(54);
4286                     r[i+55]=av.lane(55);
4287                     r[i+56]=av.lane(56);
4288                     r[i+57]=av.lane(57);
4289                     r[i+58]=av.lane(58);
4290                     r[i+59]=av.lane(59);
4291                     r[i+60]=av.lane(60);
4292                     r[i+61]=av.lane(61);
4293                     r[i+62]=av.lane(62);
4294                     r[i+63]=av.lane(63);
4295                 } else {
4296                     for (int j = 0; j < SPECIES.length(); j++) {
4297                         r[i+j]=av.lane(j);
4298                     }
4299                 }
4300             }
4301         }
4302 
4303         assertArraysEquals(r, a, LongMaxVectorTests::get);
4304     }
4305 
4306     @Test(dataProvider = "longUnaryOpProvider")
4307     static void BroadcastLongMaxVectorTests(IntFunction<long[]> fa) {
4308         long[] a = fa.apply(SPECIES.length());
4309         long[] r = new long[a.length];
4310 
4311         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4312             for (int i = 0; i < a.length; i += SPECIES.length()) {
4313                 LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4314             }
4315         }
4316 
4317         assertBroadcastArraysEquals(r, a);
4318     }
4319 
4320 
4321 
4322 
4323 
4324     @Test(dataProvider = "longUnaryOpProvider")
4325     static void ZeroLongMaxVectorTests(IntFunction<long[]> fa) {
4326         long[] a = fa.apply(SPECIES.length());
4327         long[] r = new long[a.length];
4328 
4329         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4330             for (int i = 0; i < a.length; i += SPECIES.length()) {
4331                 LongVector.zero(SPECIES).intoArray(a, i);
4332             }
4333         }
4334 
4335         Assert.assertEquals(a, r);
4336     }
4337 
4338 
4339 
4340 
4341     static long[] sliceUnary(long[] a, int origin, int idx) {
4342         long[] res = new long[SPECIES.length()];
4343         for (int i = 0; i < SPECIES.length(); i++){
4344             if(i+origin < SPECIES.length())
4345                 res[i] = a[idx+i+origin];
4346             else
4347                 res[i] = (long)0;
4348         }
4349         return res;
4350     }
4351 
4352     @Test(dataProvider = "longUnaryOpProvider")
4353     static void sliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4354         long[] a = fa.apply(SPECIES.length());
4355         long[] r = new long[a.length];
4356         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4357         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4358             for (int i = 0; i < a.length; i += SPECIES.length()) {
4359                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4360                 av.slice(origin).intoArray(r, i);
4361             }
4362         }
4363 
4364         assertArraysEquals(r, a, origin, LongMaxVectorTests::sliceUnary);
4365     }
4366     static long[] sliceBinary(long[] a, long[] b, int origin, int idx) {
4367         long[] res = new long[SPECIES.length()];
4368         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4369             if(i+origin < SPECIES.length())
4370                 res[i] = a[idx+i+origin];
4371             else {
4372                 res[i] = b[idx+j];
4373                 j++;
4374             }
4375         }
4376         return res;
4377     }
4378 
4379     @Test(dataProvider = "longBinaryOpProvider")
4380     static void sliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4381         long[] a = fa.apply(SPECIES.length());
4382         long[] b = fb.apply(SPECIES.length());
4383         long[] r = new long[a.length];
4384         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4385         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4386             for (int i = 0; i < a.length; i += SPECIES.length()) {
4387                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4388                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4389                 av.slice(origin, bv).intoArray(r, i);
4390             }
4391         }
4392 
4393         assertArraysEquals(r, a, b, origin, LongMaxVectorTests::sliceBinary);
4394     }
4395     static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) {
4396         long[] res = new long[SPECIES.length()];
4397         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4398             if(i+origin < SPECIES.length())
4399                 res[i] = mask[i] ? a[idx+i+origin] : (long)0;
4400             else {
4401                 res[i] = mask[i] ? b[idx+j] : (long)0;
4402                 j++;
4403             }
4404         }
4405         return res;
4406     }
4407 
4408     @Test(dataProvider = "longBinaryOpMaskProvider")
4409     static void sliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4410     IntFunction<boolean[]> fm) {
4411         long[] a = fa.apply(SPECIES.length());
4412         long[] b = fb.apply(SPECIES.length());
4413         boolean[] mask = fm.apply(SPECIES.length());
4414         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4415 
4416         long[] r = new long[a.length];
4417         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4418         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4419             for (int i = 0; i < a.length; i += SPECIES.length()) {
4420                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4421                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4422                 av.slice(origin, bv, vmask).intoArray(r, i);
4423             }
4424         }
4425 
4426         assertArraysEquals(r, a, b, origin, mask, LongMaxVectorTests::slice);
4427     }
4428     static long[] unsliceUnary(long[] a, int origin, int idx) {
4429         long[] res = new long[SPECIES.length()];
4430         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4431             if(i < origin)
4432                 res[i] = (long)0;
4433             else {
4434                 res[i] = a[idx+j];
4435                 j++;
4436             }
4437         }
4438         return res;
4439     }
4440 
4441     @Test(dataProvider = "longUnaryOpProvider")
4442     static void unsliceUnaryLongMaxVectorTests(IntFunction<long[]> fa) {
4443         long[] a = fa.apply(SPECIES.length());
4444         long[] r = new long[a.length];
4445         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4446         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4447             for (int i = 0; i < a.length; i += SPECIES.length()) {
4448                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4449                 av.unslice(origin).intoArray(r, i);
4450             }
4451         }
4452 
4453         assertArraysEquals(r, a, origin, LongMaxVectorTests::unsliceUnary);
4454     }
4455     static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) {
4456         long[] res = new long[SPECIES.length()];
4457         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4458             if (part == 0) {
4459                 if (i < origin)
4460                     res[i] = b[idx+i];
4461                 else {
4462                     res[i] = a[idx+j];
4463                     j++;
4464                 }
4465             } else if (part == 1) {
4466                 if (i < origin)
4467                     res[i] = a[idx+SPECIES.length()-origin+i];
4468                 else {
4469                     res[i] = b[idx+origin+j];
4470                     j++;
4471                 }
4472             }
4473         }
4474         return res;
4475     }
4476 
4477     @Test(dataProvider = "longBinaryOpProvider")
4478     static void unsliceBinaryLongMaxVectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {
4479         long[] a = fa.apply(SPECIES.length());
4480         long[] b = fb.apply(SPECIES.length());
4481         long[] r = new long[a.length];
4482         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4483         int part = (new java.util.Random()).nextInt(2);
4484         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4485             for (int i = 0; i < a.length; i += SPECIES.length()) {
4486                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4487                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4488                 av.unslice(origin, bv, part).intoArray(r, i);
4489             }
4490         }
4491 
4492         assertArraysEquals(r, a, b, origin, part, LongMaxVectorTests::unsliceBinary);
4493     }
4494     static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) {
4495         long[] res = new long[SPECIES.length()];
4496         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4497             if(i+origin < SPECIES.length())
4498                 res[i] = b[idx+i+origin];
4499             else {
4500                 res[i] = b[idx+j];
4501                 j++;
4502             }
4503         }
4504         for (int i = 0; i < SPECIES.length(); i++){
4505             res[i] = mask[i] ? a[idx+i] : res[i];
4506         }
4507         long[] res1 = new long[SPECIES.length()];
4508         if (part == 0) {
4509             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4510                 if (i < origin)
4511                     res1[i] = b[idx+i];
4512                 else {
4513                    res1[i] = res[j];
4514                    j++;
4515                 }
4516             }
4517         } else if (part == 1) {
4518             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4519                 if (i < origin)
4520                     res1[i] = res[SPECIES.length()-origin+i];
4521                 else {
4522                     res1[i] = b[idx+origin+j];
4523                     j++;
4524                 }
4525             }
4526         }
4527         return res1;
4528     }
4529 
4530     @Test(dataProvider = "longBinaryOpMaskProvider")
4531     static void unsliceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4532     IntFunction<boolean[]> fm) {
4533         long[] a = fa.apply(SPECIES.length());
4534         long[] b = fb.apply(SPECIES.length());
4535         boolean[] mask = fm.apply(SPECIES.length());
4536         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4537         long[] r = new long[a.length];
4538         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4539         int part = (new java.util.Random()).nextInt(2);
4540         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4541             for (int i = 0; i < a.length; i += SPECIES.length()) {
4542                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4543                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4544                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4545             }
4546         }
4547 
4548         assertArraysEquals(r, a, b, origin, part, mask, LongMaxVectorTests::unslice);
4549     }
4550 
4551 
4552 
4553 
4554 
4555 
4556 
4557 
4558 
4559 
4560 
4561 
4562 
4563 
4564 
4565 
4566 
4567 
4568 
4569 
4570 
4571 
4572 
4573     static long BITWISE_BLEND(long a, long b, long c) {
4574         return (long)((a&~(c))|(b&c));
4575     }
4576     static long bitwiseBlend(long a, long b, long c) {
4577         return (long)((a&~(c))|(b&c));
4578     }
4579 
4580 
4581     @Test(dataProvider = "longTernaryOpProvider")
4582     static void BITWISE_BLENDLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4583         long[] a = fa.apply(SPECIES.length());
4584         long[] b = fb.apply(SPECIES.length());
4585         long[] c = fc.apply(SPECIES.length());
4586         long[] r = fr.apply(SPECIES.length());
4587 
4588         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4589             for (int i = 0; i < a.length; i += SPECIES.length()) {
4590                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4591                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4592                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
4593                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4594             }
4595         }
4596 
4597         assertArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4598     }
4599     @Test(dataProvider = "longTernaryOpProvider")
4600     static void bitwiseBlendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4601         long[] a = fa.apply(SPECIES.length());
4602         long[] b = fb.apply(SPECIES.length());
4603         long[] c = fc.apply(SPECIES.length());
4604         long[] r = fr.apply(SPECIES.length());
4605 
4606         for (int i = 0; i < a.length; i += SPECIES.length()) {
4607             LongVector av = LongVector.fromArray(SPECIES, a, i);
4608             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4609             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4610             av.bitwiseBlend(bv, cv).intoArray(r, i);
4611         }
4612 
4613         assertArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4614     }
4615 
4616 
4617     @Test(dataProvider = "longTernaryOpMaskProvider")
4618     static void BITWISE_BLENDLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
4619                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4620         long[] a = fa.apply(SPECIES.length());
4621         long[] b = fb.apply(SPECIES.length());
4622         long[] c = fc.apply(SPECIES.length());
4623         long[] r = fr.apply(SPECIES.length());
4624         boolean[] mask = fm.apply(SPECIES.length());
4625         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4626 
4627         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4628             for (int i = 0; i < a.length; i += SPECIES.length()) {
4629                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4630                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
4631                 LongVector cv = LongVector.fromArray(SPECIES, c, i);
4632                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4633             }
4634         }
4635 
4636         assertArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4637     }
4638 
4639 
4640 
4641 
4642     @Test(dataProvider = "longTernaryOpProvider")
4643     static void BITWISE_BLENDLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4644         long[] a = fa.apply(SPECIES.length());
4645         long[] b = fb.apply(SPECIES.length());
4646         long[] c = fc.apply(SPECIES.length());
4647         long[] r = fr.apply(SPECIES.length());
4648 
4649         for (int i = 0; i < a.length; i += SPECIES.length()) {
4650             LongVector av = LongVector.fromArray(SPECIES, a, i);
4651             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4652             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
4653         }
4654         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4655     }
4656 
4657     @Test(dataProvider = "longTernaryOpProvider")
4658     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4659         long[] a = fa.apply(SPECIES.length());
4660         long[] b = fb.apply(SPECIES.length());
4661         long[] c = fc.apply(SPECIES.length());
4662         long[] r = fr.apply(SPECIES.length());
4663 
4664         for (int i = 0; i < a.length; i += SPECIES.length()) {
4665             LongVector av = LongVector.fromArray(SPECIES, a, i);
4666             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4667             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
4668         }
4669         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4670     }
4671     @Test(dataProvider = "longTernaryOpProvider")
4672     static void bitwiseBlendLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4673         long[] a = fa.apply(SPECIES.length());
4674         long[] b = fb.apply(SPECIES.length());
4675         long[] c = fc.apply(SPECIES.length());
4676         long[] r = fr.apply(SPECIES.length());
4677 
4678         for (int i = 0; i < a.length; i += SPECIES.length()) {
4679             LongVector av = LongVector.fromArray(SPECIES, a, i);
4680             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4681             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
4682         }
4683         assertBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4684     }
4685 
4686     @Test(dataProvider = "longTernaryOpProvider")
4687     static void bitwiseBlendLongMaxVectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4688         long[] a = fa.apply(SPECIES.length());
4689         long[] b = fb.apply(SPECIES.length());
4690         long[] c = fc.apply(SPECIES.length());
4691         long[] r = fr.apply(SPECIES.length());
4692 
4693         for (int i = 0; i < a.length; i += SPECIES.length()) {
4694             LongVector av = LongVector.fromArray(SPECIES, a, i);
4695             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4696             av.bitwiseBlend(b[i], cv).intoArray(r, i);
4697         }
4698         assertAltBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4699     }
4700 
4701 
4702     @Test(dataProvider = "longTernaryOpMaskProvider")
4703     static void BITWISE_BLENDLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4704                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4705         long[] a = fa.apply(SPECIES.length());
4706         long[] b = fb.apply(SPECIES.length());
4707         long[] c = fc.apply(SPECIES.length());
4708         long[] r = fr.apply(SPECIES.length());
4709         boolean[] mask = fm.apply(SPECIES.length());
4710         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4711 
4712         for (int i = 0; i < a.length; i += SPECIES.length()) {
4713             LongVector av = LongVector.fromArray(SPECIES, a, i);
4714             LongVector bv = LongVector.fromArray(SPECIES, b, i);
4715             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
4716         }
4717 
4718         assertBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4719     }
4720 
4721     @Test(dataProvider = "longTernaryOpMaskProvider")
4722     static void BITWISE_BLENDLongMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4723                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4724         long[] a = fa.apply(SPECIES.length());
4725         long[] b = fb.apply(SPECIES.length());
4726         long[] c = fc.apply(SPECIES.length());
4727         long[] r = fr.apply(SPECIES.length());
4728         boolean[] mask = fm.apply(SPECIES.length());
4729         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4730 
4731         for (int i = 0; i < a.length; i += SPECIES.length()) {
4732             LongVector av = LongVector.fromArray(SPECIES, a, i);
4733             LongVector cv = LongVector.fromArray(SPECIES, c, i);
4734             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
4735         }
4736 
4737         assertAltBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4738     }
4739 
4740 
4741 
4742 
4743     @Test(dataProvider = "longTernaryOpProvider")
4744     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4745         long[] a = fa.apply(SPECIES.length());
4746         long[] b = fb.apply(SPECIES.length());
4747         long[] c = fc.apply(SPECIES.length());
4748         long[] r = fr.apply(SPECIES.length());
4749 
4750         for (int i = 0; i < a.length; i += SPECIES.length()) {
4751             LongVector av = LongVector.fromArray(SPECIES, a, i);
4752             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
4753         }
4754 
4755         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::BITWISE_BLEND);
4756     }
4757     @Test(dataProvider = "longTernaryOpProvider")
4758     static void bitwiseBlendLongMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {
4759         long[] a = fa.apply(SPECIES.length());
4760         long[] b = fb.apply(SPECIES.length());
4761         long[] c = fc.apply(SPECIES.length());
4762         long[] r = fr.apply(SPECIES.length());
4763 
4764         for (int i = 0; i < a.length; i += SPECIES.length()) {
4765             LongVector av = LongVector.fromArray(SPECIES, a, i);
4766             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
4767         }
4768 
4769         assertDoubleBroadcastArraysEquals(r, a, b, c, LongMaxVectorTests::bitwiseBlend);
4770     }
4771 
4772 
4773     @Test(dataProvider = "longTernaryOpMaskProvider")
4774     static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,
4775                                           IntFunction<long[]> fc, IntFunction<boolean[]> fm) {
4776         long[] a = fa.apply(SPECIES.length());
4777         long[] b = fb.apply(SPECIES.length());
4778         long[] c = fc.apply(SPECIES.length());
4779         long[] r = fr.apply(SPECIES.length());
4780         boolean[] mask = fm.apply(SPECIES.length());
4781         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4782 
4783         for (int i = 0; i < a.length; i += SPECIES.length()) {
4784             LongVector av = LongVector.fromArray(SPECIES, a, i);
4785             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
4786         }
4787 
4788         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, LongMaxVectorTests::BITWISE_BLEND);
4789     }
4790 
4791 
4792     static long NEG(long a) {
4793         return (long)(-((long)a));
4794     }
4795 
4796     static long neg(long a) {
4797         return (long)(-((long)a));
4798     }
4799 
4800     @Test(dataProvider = "longUnaryOpProvider")
4801     static void NEGLongMaxVectorTests(IntFunction<long[]> fa) {
4802         long[] a = fa.apply(SPECIES.length());
4803         long[] r = fr.apply(SPECIES.length());
4804 
4805         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4806             for (int i = 0; i < a.length; i += SPECIES.length()) {
4807                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4808                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
4809             }
4810         }
4811 
4812         assertArraysEquals(r, a, LongMaxVectorTests::NEG);
4813     }
4814 
4815     @Test(dataProvider = "longUnaryOpProvider")
4816     static void negLongMaxVectorTests(IntFunction<long[]> fa) {
4817         long[] a = fa.apply(SPECIES.length());
4818         long[] r = fr.apply(SPECIES.length());
4819 
4820         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4821             for (int i = 0; i < a.length; i += SPECIES.length()) {
4822                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4823                 av.neg().intoArray(r, i);
4824             }
4825         }
4826 
4827         assertArraysEquals(r, a, LongMaxVectorTests::neg);
4828     }
4829 
4830     @Test(dataProvider = "longUnaryOpMaskProvider")
4831     static void NEGMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4832                                                 IntFunction<boolean[]> fm) {
4833         long[] a = fa.apply(SPECIES.length());
4834         long[] r = fr.apply(SPECIES.length());
4835         boolean[] mask = fm.apply(SPECIES.length());
4836         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4837 
4838         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4839             for (int i = 0; i < a.length; i += SPECIES.length()) {
4840                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4841                 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
4842             }
4843         }
4844 
4845         assertArraysEquals(r, a, mask, LongMaxVectorTests::NEG);
4846     }
4847 
4848     static long ABS(long a) {
4849         return (long)(Math.abs((long)a));
4850     }
4851 
4852     static long abs(long a) {
4853         return (long)(Math.abs((long)a));
4854     }
4855 
4856     @Test(dataProvider = "longUnaryOpProvider")
4857     static void ABSLongMaxVectorTests(IntFunction<long[]> fa) {
4858         long[] a = fa.apply(SPECIES.length());
4859         long[] r = fr.apply(SPECIES.length());
4860 
4861         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4862             for (int i = 0; i < a.length; i += SPECIES.length()) {
4863                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4864                 av.lanewise(VectorOperators.ABS).intoArray(r, i);
4865             }
4866         }
4867 
4868         assertArraysEquals(r, a, LongMaxVectorTests::ABS);
4869     }
4870 
4871     @Test(dataProvider = "longUnaryOpProvider")
4872     static void absLongMaxVectorTests(IntFunction<long[]> fa) {
4873         long[] a = fa.apply(SPECIES.length());
4874         long[] r = fr.apply(SPECIES.length());
4875 
4876         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4877             for (int i = 0; i < a.length; i += SPECIES.length()) {
4878                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4879                 av.abs().intoArray(r, i);
4880             }
4881         }
4882 
4883         assertArraysEquals(r, a, LongMaxVectorTests::abs);
4884     }
4885 
4886     @Test(dataProvider = "longUnaryOpMaskProvider")
4887     static void ABSMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4888                                                 IntFunction<boolean[]> fm) {
4889         long[] a = fa.apply(SPECIES.length());
4890         long[] r = fr.apply(SPECIES.length());
4891         boolean[] mask = fm.apply(SPECIES.length());
4892         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4893 
4894         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4895             for (int i = 0; i < a.length; i += SPECIES.length()) {
4896                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4897                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
4898             }
4899         }
4900 
4901         assertArraysEquals(r, a, mask, LongMaxVectorTests::ABS);
4902     }
4903 
4904 
4905     static long NOT(long a) {
4906         return (long)(~((long)a));
4907     }
4908 
4909     static long not(long a) {
4910         return (long)(~((long)a));
4911     }
4912 
4913 
4914 
4915     @Test(dataProvider = "longUnaryOpProvider")
4916     static void NOTLongMaxVectorTests(IntFunction<long[]> fa) {
4917         long[] a = fa.apply(SPECIES.length());
4918         long[] r = fr.apply(SPECIES.length());
4919 
4920         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4921             for (int i = 0; i < a.length; i += SPECIES.length()) {
4922                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4923                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
4924             }
4925         }
4926 
4927         assertArraysEquals(r, a, LongMaxVectorTests::NOT);
4928     }
4929 
4930     @Test(dataProvider = "longUnaryOpProvider")
4931     static void notLongMaxVectorTests(IntFunction<long[]> fa) {
4932         long[] a = fa.apply(SPECIES.length());
4933         long[] r = fr.apply(SPECIES.length());
4934 
4935         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4936             for (int i = 0; i < a.length; i += SPECIES.length()) {
4937                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4938                 av.not().intoArray(r, i);
4939             }
4940         }
4941 
4942         assertArraysEquals(r, a, LongMaxVectorTests::not);
4943     }
4944 
4945 
4946 
4947     @Test(dataProvider = "longUnaryOpMaskProvider")
4948     static void NOTMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4949                                                 IntFunction<boolean[]> fm) {
4950         long[] a = fa.apply(SPECIES.length());
4951         long[] r = fr.apply(SPECIES.length());
4952         boolean[] mask = fm.apply(SPECIES.length());
4953         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4954 
4955         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4956             for (int i = 0; i < a.length; i += SPECIES.length()) {
4957                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4958                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
4959             }
4960         }
4961 
4962         assertArraysEquals(r, a, mask, LongMaxVectorTests::NOT);
4963     }
4964 
4965 
4966 
4967     static long ZOMO(long a) {
4968         return (long)((a==0?0:-1));
4969     }
4970 
4971 
4972 
4973     @Test(dataProvider = "longUnaryOpProvider")
4974     static void ZOMOLongMaxVectorTests(IntFunction<long[]> fa) {
4975         long[] a = fa.apply(SPECIES.length());
4976         long[] r = fr.apply(SPECIES.length());
4977 
4978         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4979             for (int i = 0; i < a.length; i += SPECIES.length()) {
4980                 LongVector av = LongVector.fromArray(SPECIES, a, i);
4981                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
4982             }
4983         }
4984 
4985         assertArraysEquals(r, a, LongMaxVectorTests::ZOMO);
4986     }
4987 
4988 
4989 
4990     @Test(dataProvider = "longUnaryOpMaskProvider")
4991     static void ZOMOMaskedLongMaxVectorTests(IntFunction<long[]> fa,
4992                                                 IntFunction<boolean[]> fm) {
4993         long[] a = fa.apply(SPECIES.length());
4994         long[] r = fr.apply(SPECIES.length());
4995         boolean[] mask = fm.apply(SPECIES.length());
4996         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4997 
4998         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4999             for (int i = 0; i < a.length; i += SPECIES.length()) {
5000                 LongVector av = LongVector.fromArray(SPECIES, a, i);
5001                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5002             }
5003         }
5004 
5005         assertArraysEquals(r, a, mask, LongMaxVectorTests::ZOMO);
5006     }
5007 
5008 
5009 
5010 
5011 
5012     @Test(dataProvider = "longCompareOpProvider")
5013     static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5014         long[] a = fa.apply(SPECIES.length());
5015         long[] b = fb.apply(SPECIES.length());
5016 
5017         for (int i = 0; i < a.length; i += SPECIES.length()) {
5018             LongVector av = LongVector.fromArray(SPECIES, a, i);
5019             VectorMask<Long> mv = av.lt(b[i]);
5020 
5021             // Check results as part of computation.
5022             for (int j = 0; j < SPECIES.length(); j++) {
5023                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5024             }
5025         }
5026     }
5027 
5028     @Test(dataProvider = "longCompareOpProvider")
5029     static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
5030         long[] a = fa.apply(SPECIES.length());
5031         long[] b = fb.apply(SPECIES.length());
5032 
5033         for (int i = 0; i < a.length; i += SPECIES.length()) {
5034             LongVector av = LongVector.fromArray(SPECIES, a, i);
5035             VectorMask<Long> mv = av.eq(b[i]);
5036 
5037             // Check results as part of computation.
5038             for (int j = 0; j < SPECIES.length(); j++) {
5039                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5040             }
5041         }
5042     }
5043 
5044     @Test(dataProvider = "longtoIntUnaryOpProvider")
5045     static void toIntArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5046         long[] a = fa.apply(SPECIES.length());
5047 
5048         for (int i = 0; i < a.length; i += SPECIES.length()) {
5049             LongVector av = LongVector.fromArray(SPECIES, a, i);
5050             int[] r = av.toIntArray();
5051             assertArraysEquals(r, a, i);
5052         }
5053     }
5054 
5055     @Test(dataProvider = "longUnaryOpProvider")
5056     static void toLongArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5057         long[] a = fa.apply(SPECIES.length());
5058 
5059         for (int i = 0; i < a.length; i += SPECIES.length()) {
5060             LongVector av = LongVector.fromArray(SPECIES, a, i);
5061             long[] r = av.toLongArray();
5062             assertArraysEquals(r, a, i);
5063         }
5064     }
5065 
5066     @Test(dataProvider = "longUnaryOpProvider")
5067     static void toDoubleArrayLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5068         long[] a = fa.apply(SPECIES.length());
5069 
5070         for (int i = 0; i < a.length; i += SPECIES.length()) {
5071             LongVector av = LongVector.fromArray(SPECIES, a, i);
5072             double[] r = av.toDoubleArray();
5073             assertArraysEquals(r, a, i);
5074         }
5075     }
5076 
5077     @Test(dataProvider = "longUnaryOpProvider")
5078     static void toStringLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5079         long[] a = fa.apply(SPECIES.length());
5080 
5081         for (int i = 0; i < a.length; i += SPECIES.length()) {
5082             LongVector av = LongVector.fromArray(SPECIES, a, i);
5083             String str = av.toString();
5084 
5085             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5086             Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5087         }
5088     }
5089 
5090     @Test(dataProvider = "longUnaryOpProvider")
5091     static void hashCodeLongMaxVectorTestsSmokeTest(IntFunction<long[]> fa) {
5092         long[] a = fa.apply(SPECIES.length());
5093 
5094         for (int i = 0; i < a.length; i += SPECIES.length()) {
5095             LongVector av = LongVector.fromArray(SPECIES, a, i);
5096             int hash = av.hashCode();
5097 
5098             long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5099             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5100             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5101         }
5102     }
5103 
5104 
5105 
5106     @Test(dataProvider = "longUnaryOpProvider")
5107     static void ADDReduceLongLongMaxVectorTests(IntFunction<long[]> fa) {
5108         long[] a = fa.apply(SPECIES.length());
5109         long[] r = fr.apply(SPECIES.length());
5110         long ra = 0;
5111 
5112         for (int i = 0; i < a.length; i += SPECIES.length()) {
5113             LongVector av = LongVector.fromArray(SPECIES, a, i);
5114             r[i] = av.reduceLanesToLong(VectorOperators.ADD);
5115         }
5116 
5117         ra = 0;
5118         for (int i = 0; i < a.length; i ++) {
5119             ra += r[i];
5120         }
5121 
5122         assertReductionArraysEquals(r, ra, a,
5123                 LongMaxVectorTests::ADDReduce, LongMaxVectorTests::ADDReduceAll);
5124     }
5125 
5126     @Test(dataProvider = "longUnaryOpMaskProvider")
5127     static void ADDReduceLongLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
5128         long[] a = fa.apply(SPECIES.length());
5129         long[] r = fr.apply(SPECIES.length());
5130         boolean[] mask = fm.apply(SPECIES.length());
5131         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5132         long ra = 0;
5133 
5134         for (int i = 0; i < a.length; i += SPECIES.length()) {
5135             LongVector av = LongVector.fromArray(SPECIES, a, i);
5136             r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
5137         }
5138 
5139         ra = 0;
5140         for (int i = 0; i < a.length; i ++) {
5141             ra += r[i];
5142         }
5143 
5144         assertReductionArraysEqualsMasked(r, ra, a, mask,
5145                 LongMaxVectorTests::ADDReduceMasked, LongMaxVectorTests::ADDReduceAllMasked);
5146     }
5147 
5148     @Test(dataProvider = "longUnaryOpSelectFromProvider")
5149     static void SelectFromLongMaxVectorTests(IntFunction<long[]> fa,
5150                                            BiFunction<Integer,Integer,long[]> fs) {
5151         long[] a = fa.apply(SPECIES.length());
5152         long[] order = fs.apply(a.length, SPECIES.length());
5153         long[] r = fr.apply(SPECIES.length());
5154 
5155         for (int i = 0; i < a.length; i += SPECIES.length()) {
5156             LongVector av = LongVector.fromArray(SPECIES, a, i);
5157             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5158             bv.selectFrom(av).intoArray(r, i);
5159         }
5160 
5161         assertSelectFromArraysEquals(r, a, order, SPECIES.length());
5162     }
5163 
5164     @Test(dataProvider = "longUnaryOpSelectFromMaskProvider")
5165     static void SelectFromLongMaxVectorTestsMaskedSmokeTest(IntFunction<long[]> fa,
5166                                                            BiFunction<Integer,Integer,long[]> fs,
5167                                                            IntFunction<boolean[]> fm) {
5168         long[] a = fa.apply(SPECIES.length());
5169         long[] order = fs.apply(a.length, SPECIES.length());
5170         long[] r = fr.apply(SPECIES.length());
5171         boolean[] mask = fm.apply(SPECIES.length());
5172         VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5173 
5174         for (int i = 0; i < a.length; i += SPECIES.length()) {
5175             LongVector av = LongVector.fromArray(SPECIES, a, i);
5176             LongVector bv = LongVector.fromArray(SPECIES, order, i);
5177             bv.selectFrom(av, vmask).intoArray(r, i);
5178         }
5179 
5180         assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
5181     }
5182 
5183     @Test(dataProvider = "shuffleProvider")
5184     static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5185         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5186 
5187         for (int i = 0; i < a.length; i += SPECIES.length()) {
5188             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5189             int hash = shuffle.hashCode();
5190             int length = shuffle.length();
5191 
5192             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5193             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5194             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5195             Assert.assertEquals(length, SPECIES.length());
5196         }
5197     }
5198 
5199     @Test(dataProvider = "shuffleProvider")
5200     static void shuffleToStringLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
5201         int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5202 
5203         for (int i = 0; i < a.length; i += SPECIES.length()) {
5204             var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
5205             String str = shuffle.toString();
5206 
5207             int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5208             Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
5209                 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
5210         }
5211     }
5212 
5213     @Test(dataProvider = "shuffleCompareOpProvider")
5214     static void shuffleEqualsLongMaxVectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
5215         int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5216         int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
5217 
5218         for (int i = 0; i < a.length; i += SPECIES.length()) {
5219             var av = VectorShuffle.fromArray(SPECIES, a, i);
5220             var bv = VectorShuffle.fromArray(SPECIES, b, i);
5221             boolean eq = av.equals(bv);
5222             int to = i + SPECIES.length();
5223             Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
5224         }
5225     }
5226 
5227     @Test(dataProvider = "maskCompareOpProvider")
5228     static void maskEqualsLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5229         boolean[] a = fa.apply(SPECIES.length());
5230         boolean[] b = fb.apply(SPECIES.length());
5231 
5232         for (int i = 0; i < a.length; i += SPECIES.length()) {
5233             var av = SPECIES.loadMask(a, i);
5234             var bv = SPECIES.loadMask(b, i);
5235             boolean equals = av.equals(bv);
5236             int to = i + SPECIES.length();
5237             Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
5238         }
5239     }
5240 
5241     static boolean beq(boolean a, boolean b) {
5242         return (a == b);
5243     }
5244 
5245     @Test(dataProvider = "maskCompareOpProvider")
5246     static void maskEqLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
5247         boolean[] a = fa.apply(SPECIES.length());
5248         boolean[] b = fb.apply(SPECIES.length());
5249         boolean[] r = new boolean[a.length];
5250 
5251         for (int i = 0; i < a.length; i += SPECIES.length()) {
5252             var av = SPECIES.loadMask(a, i);
5253             var bv = SPECIES.loadMask(b, i);
5254             var cv = av.eq(bv);
5255             cv.intoArray(r, i);
5256         }
5257         assertArraysEquals(r, a, b, LongMaxVectorTests::beq);
5258     }
5259 
5260     @Test(dataProvider = "maskProvider")
5261     static void maskHashCodeLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5262         boolean[] a = fa.apply(SPECIES.length());
5263 
5264         for (int i = 0; i < a.length; i += SPECIES.length()) {
5265             var vmask = SPECIES.loadMask(a, i);
5266             int hash = vmask.hashCode();
5267 
5268             boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
5269             int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
5270             Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
5271         }
5272     }
5273 
5274     static int maskTrueCount(boolean[] a, int idx) {
5275         int trueCount = 0;
5276         for (int i = idx; i < idx + SPECIES.length(); i++) {
5277             trueCount += a[i] ? 1 : 0;
5278         }
5279         return trueCount;
5280     }
5281 
5282     @Test(dataProvider = "maskProvider")
5283     static void maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5284         boolean[] a = fa.apply(SPECIES.length());
5285         int[] r = new int[a.length];
5286 
5287         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5288             for (int i = 0; i < a.length; i += SPECIES.length()) {
5289                 var vmask = SPECIES.loadMask(a, i);
5290                 r[i] = vmask.trueCount();
5291             }
5292         }
5293 
5294         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskTrueCount);
5295     }
5296 
5297     static int maskLastTrue(boolean[] a, int idx) {
5298         int i = idx + SPECIES.length() - 1;
5299         for (; i >= idx; i--) {
5300             if (a[i]) {
5301                 break;
5302             }
5303         }
5304         return i - idx;
5305     }
5306 
5307     @Test(dataProvider = "maskProvider")
5308     static void maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5309         boolean[] a = fa.apply(SPECIES.length());
5310         int[] r = new int[a.length];
5311 
5312         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5313             for (int i = 0; i < a.length; i += SPECIES.length()) {
5314                 var vmask = SPECIES.loadMask(a, i);
5315                 r[i] = vmask.lastTrue();
5316             }
5317         }
5318 
5319         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskLastTrue);
5320     }
5321 
5322     static int maskFirstTrue(boolean[] a, int idx) {
5323         int i = idx;
5324         for (; i < idx + SPECIES.length(); i++) {
5325             if (a[i]) {
5326                 break;
5327             }
5328         }
5329         return i - idx;
5330     }
5331 
5332     @Test(dataProvider = "maskProvider")
5333     static void maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5334         boolean[] a = fa.apply(SPECIES.length());
5335         int[] r = new int[a.length];
5336 
5337         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5338             for (int i = 0; i < a.length; i += SPECIES.length()) {
5339                 var vmask = SPECIES.loadMask(a, i);
5340                 r[i] = vmask.firstTrue();
5341             }
5342         }
5343 
5344         assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue);
5345     }
5346 

















5347 
5348     @DataProvider
5349     public static Object[][] offsetProvider() {
5350         return new Object[][]{
5351                 {0},
5352                 {-1},
5353                 {+1},
5354                 {+2},
5355                 {-2},
5356         };
5357     }
5358 
5359     @Test(dataProvider = "offsetProvider")
5360     static void indexInRangeLongMaxVectorTestsSmokeTest(int offset) {
5361         int limit = SPECIES.length() * BUFFER_REPS;
5362         for (int i = 0; i < limit; i += SPECIES.length()) {
5363             var actualMask = SPECIES.indexInRange(i + offset, limit);
5364             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5365             assert(actualMask.equals(expectedMask));
5366             for (int j = 0; j < SPECIES.length(); j++)  {
5367                 int index = i + j + offset;
5368                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5369             }
5370         }
5371     }
5372 
5373     @DataProvider
5374     public static Object[][] lengthProvider() {
5375         return new Object[][]{
5376                 {0},
5377                 {1},
5378                 {32},
5379                 {37},
5380                 {1024},
5381                 {1024+1},
5382                 {1024+5},
5383         };
5384     }
5385 
5386     @Test(dataProvider = "lengthProvider")
5387     static void loopBoundLongMaxVectorTestsSmokeTest(int length) {
5388         int actualLoopBound = SPECIES.loopBound(length);
5389         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5390         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5391     }
5392 
5393     @Test
5394     static void ElementSizeLongMaxVectorTestsSmokeTest() {
5395         LongVector av = LongVector.zero(SPECIES);
5396         int elsize = av.elementSize();
5397         Assert.assertEquals(elsize, Long.SIZE);
5398     }
5399 
5400     @Test
5401     static void VectorShapeLongMaxVectorTestsSmokeTest() {
5402         LongVector av = LongVector.zero(SPECIES);
5403         VectorShape vsh = av.shape();
5404         assert(vsh.equals(VectorShape.S_Max_BIT));
5405     }
5406 
5407     @Test
5408     static void ShapeWithLanesLongMaxVectorTestsSmokeTest() {
5409         LongVector av = LongVector.zero(SPECIES);
5410         VectorShape vsh = av.shape();
5411         VectorSpecies species = vsh.withLanes(long.class);
5412         assert(species.equals(SPECIES));
5413     }
5414 
5415     @Test
5416     static void ElementTypeLongMaxVectorTestsSmokeTest() {
5417         LongVector av = LongVector.zero(SPECIES);
5418         assert(av.species().elementType() == long.class);
5419     }
5420 
5421     @Test
5422     static void SpeciesElementSizeLongMaxVectorTestsSmokeTest() {
5423         LongVector av = LongVector.zero(SPECIES);
5424         assert(av.species().elementSize() == Long.SIZE);
5425     }
5426 
5427     @Test
5428     static void VectorTypeLongMaxVectorTestsSmokeTest() {
5429         LongVector av = LongVector.zero(SPECIES);
5430         assert(av.species().vectorType() == av.getClass());
5431     }
5432 
5433     @Test
5434     static void WithLanesLongMaxVectorTestsSmokeTest() {
5435         LongVector av = LongVector.zero(SPECIES);
5436         VectorSpecies species = av.species().withLanes(long.class);
5437         assert(species.equals(SPECIES));
5438     }
5439 
5440     @Test
5441     static void WithShapeLongMaxVectorTestsSmokeTest() {
5442         LongVector av = LongVector.zero(SPECIES);
5443         VectorShape vsh = av.shape();
5444         VectorSpecies species = av.species().withShape(vsh);
5445         assert(species.equals(SPECIES));
5446     }
5447 
5448     @Test
5449     static void MaskAllTrueLongMaxVectorTestsSmokeTest() {
5450         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5451           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5452         }
5453     }
5454 }
5455 
--- EOF ---