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