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