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