rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level

   1 /*
   2  * Copyright (c) 2018, 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
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @modules jdk.incubator.vector
  27  * @run testng/othervm -ea -esa LongMaxVectorTests
  28  */
  29 
  30 import jdk.incubator.vector.VectorShape;
  31 import jdk.incubator.vector.VectorSpecies;
  32 import jdk.incubator.vector.VectorShuffle;
  33 import jdk.incubator.vector.VectorMask;
  34 import jdk.incubator.vector.Vector;
  35 
  36 import jdk.incubator.vector.LongVector;
  37 
  38 import org.testng.Assert;
  39 import org.testng.annotations.DataProvider;
  40 import org.testng.annotations.Test;
  41 
  42 import java.lang.Integer;
  43 import java.util.List;
  44 import java.util.Arrays;
  45 import java.util.function.BiFunction;
  46 import java.util.function.IntFunction;
  47 import java.util.stream.Collectors;
  48 import java.util.stream.Stream;
  49 
  50 @Test
  51 public class LongMaxVectorTests extends AbstractVectorTest {
  52 
  53     static final VectorSpecies<Long> SPECIES =
  54                 LongVector.SPECIES_MAX;
  55 
  56     static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
  57 
  58     static VectorShape getMaxBit() {
  59         return VectorShape.S_Max_BIT;
  60     }
  61 
  62     interface FUnOp {
  63         long apply(long a);
  64     }
  65 
  66     static void assertArraysEquals(long[] a, long[] r, FUnOp f) {
  67         int i = 0;
  68         try {
  69             for (; i < a.length; i++) {
  70                 Assert.assertEquals(r[i], f.apply(a[i]));
  71             }
  72         } catch (AssertionError e) {
  73             Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
  74         }
  75     }
  76 
  77     static void assertArraysEquals(long[] a, long[] r, boolean[] mask, FUnOp f) {
  78         int i = 0;
  79         try {
  80             for (; i < a.length; i++) {
  81                 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
  82             }
  83         } catch (AssertionError e) {
  84             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()]);
  85         }
  86     }
  87 
  88     interface FReductionOp {
  89         long apply(long[] a, int idx);
  90     }
  91 
  92     interface FReductionAllOp {
  93         long apply(long[] a);
  94     }
  95 
  96     static void assertReductionArraysEquals(long[] a, long[] b, long c,
  97                                             FReductionOp f, FReductionAllOp fa) {
  98         int i = 0;
  99         try {
 100             Assert.assertEquals(c, fa.apply(a));
 101             for (; i < a.length; i += SPECIES.length()) {
 102                 Assert.assertEquals(b[i], f.apply(a, i));
 103             }
 104         } catch (AssertionError e) {
 105             Assert.assertEquals(c, fa.apply(a), "Final result is incorrect!");
 106             Assert.assertEquals(b[i], f.apply(a, i), "at index #" + i);
 107         }
 108     }
 109 
 110     interface FBoolReductionOp {
 111         boolean apply(boolean[] a, int idx);
 112     }
 113 
 114     static void assertReductionBoolArraysEquals(boolean[] a, boolean[] b, FBoolReductionOp f) {
 115         int i = 0;
 116         try {
 117             for (; i < a.length; i += SPECIES.length()) {
 118                 Assert.assertEquals(f.apply(a, i), b[i]);
 119             }
 120         } catch (AssertionError e) {
 121             Assert.assertEquals(f.apply(a, i), b[i], "at index #" + i);
 122         }
 123     }
 124 
 125     static void assertInsertArraysEquals(long[] a, long[] b, long element, int index) {
 126         int i = 0;
 127         try {
 128             for (; i < a.length; i += 1) {
 129                 if(i%SPECIES.length() == index) {
 130                     Assert.assertEquals(b[i], element);
 131                 } else {
 132                     Assert.assertEquals(b[i], a[i]);
 133                 }
 134             }
 135         } catch (AssertionError e) {
 136             if (i%SPECIES.length() == index) {
 137                 Assert.assertEquals(b[i], element, "at index #" + i);
 138             } else {
 139                 Assert.assertEquals(b[i], a[i], "at index #" + i);
 140             }
 141         }
 142     }
 143 
 144     static void assertRearrangeArraysEquals(long[] a, long[] r, int[] order, int vector_len) {
 145         int i = 0, j = 0;
 146         try {
 147             for (; i < a.length; i += vector_len) {
 148                 for (j = 0; j < vector_len; j++) {
 149                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 150                 }
 151             }
 152         } catch (AssertionError e) {
 153             int idx = i + j;
 154             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 155         }
 156     }
 157 
 158     interface FBinOp {
 159         long apply(long a, long b);
 160     }
 161 
 162     interface FBinMaskOp {
 163         long apply(long a, long b, boolean m);
 164 
 165         static FBinMaskOp lift(FBinOp f) {
 166             return (a, b, m) -> m ? f.apply(a, b) : a;
 167         }
 168     }
 169 
 170     static void assertArraysEquals(long[] a, long[] b, long[] r, FBinOp f) {
 171         int i = 0;
 172         try {
 173             for (; i < a.length; i++) {
 174                 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
 175             }
 176         } catch (AssertionError e) {
 177             Assert.assertEquals(f.apply(a[i], b[i]), r[i], "(" + a[i] + ", " + b[i] + ") at index #" + i);
 178         }
 179     }
 180 
 181     static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) {
 182         assertArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 183     }
 184 
 185     static void assertArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) {
 186         int i = 0;
 187         try {
 188             for (; i < a.length; i++) {
 189                 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
 190             }
 191         } catch (AssertionError err) {
 192             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()]);
 193         }
 194     }
 195 
 196     static void assertShiftArraysEquals(long[] a, long[] b, long[] r, FBinOp f) {
 197         int i = 0;
 198         int j = 0;
 199         try {
 200             for (; j < a.length; j += SPECIES.length()) {
 201                 for (i = 0; i < SPECIES.length(); i++) {
 202                     Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j]);
 203                 }
 204             }
 205         } catch (AssertionError e) {
 206             Assert.assertEquals(f.apply(a[i+j], b[j]), r[i+j], "at index #" + i + ", " + j);
 207         }
 208     }
 209 
 210     static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinOp f) {
 211         assertShiftArraysEquals(a, b, r, mask, FBinMaskOp.lift(f));
 212     }
 213 
 214     static void assertShiftArraysEquals(long[] a, long[] b, long[] r, boolean[] mask, FBinMaskOp f) {
 215         int i = 0;
 216         int j = 0;
 217         try {
 218             for (; j < a.length; j += SPECIES.length()) {
 219                 for (i = 0; i < SPECIES.length(); i++) {
 220                     Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
 221                 }
 222             }
 223         } catch (AssertionError err) {
 224             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]);
 225         }
 226     }
 227 
 228 
 229     interface FBinArrayOp {
 230         long apply(long[] a, int b);
 231     }
 232 
 233     static void assertArraysEquals(long[] a, long[] r, FBinArrayOp f) {
 234         int i = 0;
 235         try {
 236             for (; i < a.length; i++) {
 237                 Assert.assertEquals(f.apply(a, i), r[i]);
 238             }
 239         } catch (AssertionError e) {
 240             Assert.assertEquals(f.apply(a,i), r[i], "at index #" + i);
 241         }
 242     }
 243     interface FGatherScatterOp {
 244         long[] apply(long[] a, int ix, int[] b, int iy);
 245     }
 246 
 247     static void assertArraysEquals(long[] a, int[] b, long[] r, FGatherScatterOp f) {
 248         int i = 0;
 249         try {
 250             for (; i < a.length; i += SPECIES.length()) {
 251                 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
 252                   f.apply(a, i, b, i));
 253             }
 254         } catch (AssertionError e) {
 255             long[] ref = f.apply(a, i, b, i);
 256             long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
 257             Assert.assertEquals(ref, res,
 258               "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
 259               + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
 260               + ", b: "
 261               + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
 262               + " at index #" + i);
 263         }
 264     }
 265 
 266 
 267     static final List<IntFunction<long[]>> LONG_GENERATORS = List.of(
 268             withToString("long[-i * 5]", (int s) -> {
 269                 return fill(s * 1000,
 270                             i -> (long)(-i * 5));
 271             }),
 272             withToString("long[i * 5]", (int s) -> {
 273                 return fill(s * 1000,
 274                             i -> (long)(i * 5));
 275             }),
 276             withToString("long[i + 1]", (int s) -> {
 277                 return fill(s * 1000,
 278                             i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));
 279             }),
 280             withToString("long[cornerCaseValue(i)]", (int s) -> {
 281                 return fill(s * 1000,
 282                             i -> cornerCaseValue(i));
 283             })
 284     );
 285 
 286     // Create combinations of pairs
 287     // @@@ Might be sensitive to order e.g. div by 0
 288     static final List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS =
 289         Stream.of(LONG_GENERATORS.get(0)).
 290                 flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
 291                 collect(Collectors.toList());
 292 
 293     @DataProvider
 294     public Object[][] boolUnaryOpProvider() {
 295         return BOOL_ARRAY_GENERATORS.stream().
 296                 map(f -> new Object[]{f}).
 297                 toArray(Object[][]::new);
 298     }
 299 
 300 
 301     @DataProvider
 302     public Object[][] longBinaryOpProvider() {
 303         return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
 304                 toArray(Object[][]::new);
 305     }
 306 
 307     @DataProvider
 308     public Object[][] longIndexedOpProvider() {
 309         return LONG_GENERATOR_PAIRS.stream().map(List::toArray).
 310                 toArray(Object[][]::new);
 311     }
 312 
 313     @DataProvider
 314     public Object[][] longBinaryOpMaskProvider() {
 315         return BOOLEAN_MASK_GENERATORS.stream().
 316                 flatMap(fm -> LONG_GENERATOR_PAIRS.stream().map(lfa -> {
 317                     return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
 318                 })).
 319                 toArray(Object[][]::new);
 320     }
 321 
 322 
 323     @DataProvider
 324     public Object[][] longUnaryOpProvider() {
 325         return LONG_GENERATORS.stream().
 326                 map(f -> new Object[]{f}).
 327                 toArray(Object[][]::new);
 328     }
 329 
 330     @DataProvider
 331     public Object[][] longUnaryOpMaskProvider() {
 332         return BOOLEAN_MASK_GENERATORS.stream().
 333                 flatMap(fm -> LONG_GENERATORS.stream().map(fa -> {
 334                     return new Object[] {fa, fm};
 335                 })).
 336                 toArray(Object[][]::new);
 337     }
 338 
 339     @DataProvider
 340     public Object[][] longUnaryOpShuffleProvider() {
 341         return INT_SHUFFLE_GENERATORS.stream().
 342                 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
 343                     return new Object[] {fa, fs};
 344                 })).
 345                 toArray(Object[][]::new);
 346     }
 347 
 348     @DataProvider
 349     public Object[][] longUnaryOpIndexProvider() {
 350         return INT_INDEX_GENERATORS.stream().
 351                 flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {
 352                     return new Object[] {fa, fs};
 353                 })).
 354                 toArray(Object[][]::new);
 355     }
 356 
 357 
 358     static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(
 359             withToString("long[i]", (int s) -> {
 360                 return fill(s * 1000,
 361                             i -> (long)i);
 362             }),
 363             withToString("long[i + 1]", (int s) -> {
 364                 return fill(s * 1000,
 365                             i -> (long)(i + 1));
 366             }),
 367             withToString("long[i - 2]", (int s) -> {
 368                 return fill(s * 1000,
 369                             i -> (long)(i - 2));
 370             }),
 371             withToString("long[zigZag(i)]", (int s) -> {
 372                 return fill(s * 1000,
 373                             i -> i%3 == 0 ? (long)i : (i%3 == 1 ? (long)(i + 1) : (long)(i - 2)));
 374             }),
 375             withToString("long[cornerCaseValue(i)]", (int s) -> {
 376                 return fill(s * 1000,
 377                             i -> cornerCaseValue(i));
 378             })
 379     );
 380 
 381     static final List<List<IntFunction<long[]>>> LONG_COMPARE_GENERATOR_PAIRS =
 382         LONG_COMPARE_GENERATORS.stream().
 383                 flatMap(fa -> LONG_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
 384                 collect(Collectors.toList());
 385 
 386     @DataProvider
 387     public Object[][] longCompareOpProvider() {
 388         return LONG_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 389                 toArray(Object[][]::new);
 390     }
 391 
 392     interface ToLongF {
 393         long apply(int i);
 394     }
 395 
 396     static long[] fill(int s , ToLongF f) {
 397         return fill(new long[s], f);
 398     }
 399 
 400     static long[] fill(long[] a, ToLongF f) {
 401         for (int i = 0; i < a.length; i++) {
 402             a[i] = f.apply(i);
 403         }
 404         return a;
 405     }
 406 
 407     static long cornerCaseValue(int i) {
 408         switch(i % 5) {
 409             case 0:
 410                 return Long.MAX_VALUE;
 411             case 1:
 412                 return Long.MIN_VALUE;
 413             case 2:
 414                 return Long.MIN_VALUE;
 415             case 3:
 416                 return Long.MAX_VALUE;
 417             default:
 418                 return (long)0;
 419         }
 420     }
 421    static long get(long[] a, int i) {
 422        return (long) a[i];
 423    }
 424 
 425    static final IntFunction<long[]> fr = (vl) -> {
 426         int length = 1000 * vl;
 427         return new long[length];
 428     };
 429 
 430     static final IntFunction<boolean[]> fmr = (vl) -> {
 431         int length = 1000 * vl;
 432         return new boolean[length];
 433     };
 434     static long add(long a, long b) {
 435         return (long)(a + b);
 436     }
 437 
 438     @Test(dataProvider = "longBinaryOpProvider")
 439     static void addLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 440         long[] a = fa.apply(SPECIES.length());
 441         long[] b = fb.apply(SPECIES.length());
 442         long[] r = fr.apply(SPECIES.length());
 443 
 444         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 445             for (int i = 0; i < a.length; i += SPECIES.length()) {
 446                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 447                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 448                 av.add(bv).intoArray(r, i);
 449             }
 450         }
 451 
 452         assertArraysEquals(a, b, r, LongMaxVectorTests::add);
 453     }
 454 
 455     @Test(dataProvider = "longBinaryOpMaskProvider")
 456     static void addLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 457                                           IntFunction<boolean[]> fm) {
 458         long[] a = fa.apply(SPECIES.length());
 459         long[] b = fb.apply(SPECIES.length());
 460         long[] r = fr.apply(SPECIES.length());
 461         boolean[] mask = fm.apply(SPECIES.length());
 462         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 463 
 464         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 465             for (int i = 0; i < a.length; i += SPECIES.length()) {
 466                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 467                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 468                 av.add(bv, vmask).intoArray(r, i);
 469             }
 470         }
 471 
 472         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::add);
 473     }
 474     static long sub(long a, long b) {
 475         return (long)(a - b);
 476     }
 477 
 478     @Test(dataProvider = "longBinaryOpProvider")
 479     static void subLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 480         long[] a = fa.apply(SPECIES.length());
 481         long[] b = fb.apply(SPECIES.length());
 482         long[] r = fr.apply(SPECIES.length());
 483 
 484         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 485             for (int i = 0; i < a.length; i += SPECIES.length()) {
 486                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 487                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 488                 av.sub(bv).intoArray(r, i);
 489             }
 490         }
 491 
 492         assertArraysEquals(a, b, r, LongMaxVectorTests::sub);
 493     }
 494 
 495     @Test(dataProvider = "longBinaryOpMaskProvider")
 496     static void subLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 497                                           IntFunction<boolean[]> fm) {
 498         long[] a = fa.apply(SPECIES.length());
 499         long[] b = fb.apply(SPECIES.length());
 500         long[] r = fr.apply(SPECIES.length());
 501         boolean[] mask = fm.apply(SPECIES.length());
 502         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 503 
 504         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 505             for (int i = 0; i < a.length; i += SPECIES.length()) {
 506                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 507                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 508                 av.sub(bv, vmask).intoArray(r, i);
 509             }
 510         }
 511 
 512         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::sub);
 513     }
 514 
 515 
 516     static long mul(long a, long b) {
 517         return (long)(a * b);
 518     }
 519 
 520     @Test(dataProvider = "longBinaryOpProvider")
 521     static void mulLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 522         long[] a = fa.apply(SPECIES.length());
 523         long[] b = fb.apply(SPECIES.length());
 524         long[] r = fr.apply(SPECIES.length());
 525 
 526         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 527             for (int i = 0; i < a.length; i += SPECIES.length()) {
 528                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 529                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 530                 av.mul(bv).intoArray(r, i);
 531             }
 532         }
 533 
 534         assertArraysEquals(a, b, r, LongMaxVectorTests::mul);
 535     }
 536 
 537     @Test(dataProvider = "longBinaryOpMaskProvider")
 538     static void mulLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 539                                           IntFunction<boolean[]> fm) {
 540         long[] a = fa.apply(SPECIES.length());
 541         long[] b = fb.apply(SPECIES.length());
 542         long[] r = fr.apply(SPECIES.length());
 543         boolean[] mask = fm.apply(SPECIES.length());
 544         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 545 
 546         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 547             for (int i = 0; i < a.length; i += SPECIES.length()) {
 548                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 549                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 550                 av.mul(bv, vmask).intoArray(r, i);
 551             }
 552         }
 553 
 554         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::mul);
 555     }
 556 
 557     static long and(long a, long b) {
 558         return (long)(a & b);
 559     }
 560 
 561     @Test(dataProvider = "longBinaryOpProvider")
 562     static void andLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 563         long[] a = fa.apply(SPECIES.length());
 564         long[] b = fb.apply(SPECIES.length());
 565         long[] r = fr.apply(SPECIES.length());
 566 
 567         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 568             for (int i = 0; i < a.length; i += SPECIES.length()) {
 569                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 570                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 571                 av.and(bv).intoArray(r, i);
 572             }
 573         }
 574 
 575         assertArraysEquals(a, b, r, LongMaxVectorTests::and);
 576     }
 577 
 578 
 579 
 580     @Test(dataProvider = "longBinaryOpMaskProvider")
 581     static void andLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 582                                           IntFunction<boolean[]> fm) {
 583         long[] a = fa.apply(SPECIES.length());
 584         long[] b = fb.apply(SPECIES.length());
 585         long[] r = fr.apply(SPECIES.length());
 586         boolean[] mask = fm.apply(SPECIES.length());
 587         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 588 
 589         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 590             for (int i = 0; i < a.length; i += SPECIES.length()) {
 591                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 592                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 593                 av.and(bv, vmask).intoArray(r, i);
 594             }
 595         }
 596 
 597         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::and);
 598     }
 599 
 600 
 601     static long or(long a, long b) {
 602         return (long)(a | b);
 603     }
 604 
 605     @Test(dataProvider = "longBinaryOpProvider")
 606     static void orLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 607         long[] a = fa.apply(SPECIES.length());
 608         long[] b = fb.apply(SPECIES.length());
 609         long[] r = fr.apply(SPECIES.length());
 610 
 611         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 612             for (int i = 0; i < a.length; i += SPECIES.length()) {
 613                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 614                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 615                 av.or(bv).intoArray(r, i);
 616             }
 617         }
 618 
 619         assertArraysEquals(a, b, r, LongMaxVectorTests::or);
 620     }
 621 
 622 
 623 
 624     @Test(dataProvider = "longBinaryOpMaskProvider")
 625     static void orLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 626                                           IntFunction<boolean[]> fm) {
 627         long[] a = fa.apply(SPECIES.length());
 628         long[] b = fb.apply(SPECIES.length());
 629         long[] r = fr.apply(SPECIES.length());
 630         boolean[] mask = fm.apply(SPECIES.length());
 631         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 632 
 633         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 634             for (int i = 0; i < a.length; i += SPECIES.length()) {
 635                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 636                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 637                 av.or(bv, vmask).intoArray(r, i);
 638             }
 639         }
 640 
 641         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::or);
 642     }
 643 
 644 
 645     static long xor(long a, long b) {
 646         return (long)(a ^ b);
 647     }
 648 
 649     @Test(dataProvider = "longBinaryOpProvider")
 650     static void xorLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 651         long[] a = fa.apply(SPECIES.length());
 652         long[] b = fb.apply(SPECIES.length());
 653         long[] r = fr.apply(SPECIES.length());
 654 
 655         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 656             for (int i = 0; i < a.length; i += SPECIES.length()) {
 657                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 658                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 659                 av.xor(bv).intoArray(r, i);
 660             }
 661         }
 662 
 663         assertArraysEquals(a, b, r, LongMaxVectorTests::xor);
 664     }
 665 
 666 
 667 
 668     @Test(dataProvider = "longBinaryOpMaskProvider")
 669     static void xorLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 670                                           IntFunction<boolean[]> fm) {
 671         long[] a = fa.apply(SPECIES.length());
 672         long[] b = fb.apply(SPECIES.length());
 673         long[] r = fr.apply(SPECIES.length());
 674         boolean[] mask = fm.apply(SPECIES.length());
 675         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 676 
 677         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 678             for (int i = 0; i < a.length; i += SPECIES.length()) {
 679                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 680                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 681                 av.xor(bv, vmask).intoArray(r, i);
 682             }
 683         }
 684 
 685         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::xor);
 686     }
 687 
 688 
 689     static long shiftR(long a, long b) {
 690         return (long)((a >>> b));
 691     }
 692 
 693     @Test(dataProvider = "longBinaryOpProvider")
 694     static void shiftRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 695         long[] a = fa.apply(SPECIES.length());
 696         long[] b = fb.apply(SPECIES.length());
 697         long[] r = fr.apply(SPECIES.length());
 698 
 699         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 700             for (int i = 0; i < a.length; i += SPECIES.length()) {
 701                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 702                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 703                 av.shiftR(bv).intoArray(r, i);
 704             }
 705         }
 706 
 707         assertArraysEquals(a, b, r, LongMaxVectorTests::shiftR);
 708     }
 709 
 710 
 711 
 712     @Test(dataProvider = "longBinaryOpMaskProvider")
 713     static void shiftRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 714                                           IntFunction<boolean[]> fm) {
 715         long[] a = fa.apply(SPECIES.length());
 716         long[] b = fb.apply(SPECIES.length());
 717         long[] r = fr.apply(SPECIES.length());
 718         boolean[] mask = fm.apply(SPECIES.length());
 719         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 720 
 721         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 722             for (int i = 0; i < a.length; i += SPECIES.length()) {
 723                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 724                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 725                 av.shiftR(bv, vmask).intoArray(r, i);
 726             }
 727         }
 728 
 729         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::shiftR);
 730     }
 731 
 732 
 733     static long shiftL(long a, long b) {
 734         return (long)((a << b));
 735     }
 736 
 737     @Test(dataProvider = "longBinaryOpProvider")
 738     static void shiftLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 739         long[] a = fa.apply(SPECIES.length());
 740         long[] b = fb.apply(SPECIES.length());
 741         long[] r = fr.apply(SPECIES.length());
 742 
 743         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 744             for (int i = 0; i < a.length; i += SPECIES.length()) {
 745                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 746                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 747                 av.shiftL(bv).intoArray(r, i);
 748             }
 749         }
 750 
 751         assertArraysEquals(a, b, r, LongMaxVectorTests::shiftL);
 752     }
 753 
 754 
 755 
 756     @Test(dataProvider = "longBinaryOpMaskProvider")
 757     static void shiftLLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 758                                           IntFunction<boolean[]> fm) {
 759         long[] a = fa.apply(SPECIES.length());
 760         long[] b = fb.apply(SPECIES.length());
 761         long[] r = fr.apply(SPECIES.length());
 762         boolean[] mask = fm.apply(SPECIES.length());
 763         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 764 
 765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 766             for (int i = 0; i < a.length; i += SPECIES.length()) {
 767                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 768                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 769                 av.shiftL(bv, vmask).intoArray(r, i);
 770             }
 771         }
 772 
 773         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::shiftL);
 774     }
 775 
 776 
 777     static long aShiftR(long a, long b) {
 778         return (long)((a >> b));
 779     }
 780 
 781     @Test(dataProvider = "longBinaryOpProvider")
 782     static void aShiftRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 783         long[] a = fa.apply(SPECIES.length());
 784         long[] b = fb.apply(SPECIES.length());
 785         long[] r = fr.apply(SPECIES.length());
 786 
 787         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 788             for (int i = 0; i < a.length; i += SPECIES.length()) {
 789                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 790                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 791                 av.aShiftR(bv).intoArray(r, i);
 792             }
 793         }
 794 
 795         assertArraysEquals(a, b, r, LongMaxVectorTests::aShiftR);
 796     }
 797 
 798 
 799 
 800     @Test(dataProvider = "longBinaryOpMaskProvider")
 801     static void aShiftRLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
 802                                           IntFunction<boolean[]> fm) {
 803         long[] a = fa.apply(SPECIES.length());
 804         long[] b = fb.apply(SPECIES.length());
 805         long[] r = fr.apply(SPECIES.length());
 806         boolean[] mask = fm.apply(SPECIES.length());
 807         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 808 
 809         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 810             for (int i = 0; i < a.length; i += SPECIES.length()) {
 811                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 812                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 813                 av.aShiftR(bv, vmask).intoArray(r, i);
 814             }
 815         }
 816 
 817         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::aShiftR);
 818     }
 819 
 820 
 821     static long aShiftR_unary(long a, long b) {
 822         return (long)((a >> b));
 823     }
 824 
 825     @Test(dataProvider = "longBinaryOpProvider")
 826     static void aShiftRLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 827         long[] a = fa.apply(SPECIES.length());
 828         long[] b = fb.apply(SPECIES.length());
 829         long[] r = fr.apply(SPECIES.length());
 830 
 831         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 832             for (int i = 0; i < a.length; i += SPECIES.length()) {
 833                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 834                 av.aShiftR((int)b[i]).intoArray(r, i);
 835             }
 836         }
 837 
 838         assertShiftArraysEquals(a, b, r, LongMaxVectorTests::aShiftR_unary);
 839     }
 840 
 841 
 842 
 843     @Test(dataProvider = "longBinaryOpMaskProvider")
 844     static void aShiftRLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 845                                           IntFunction<boolean[]> fm) {
 846         long[] a = fa.apply(SPECIES.length());
 847         long[] b = fb.apply(SPECIES.length());
 848         long[] r = fr.apply(SPECIES.length());
 849         boolean[] mask = fm.apply(SPECIES.length());
 850         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 851 
 852         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 853             for (int i = 0; i < a.length; i += SPECIES.length()) {
 854                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 855                 av.aShiftR((int)b[i], vmask).intoArray(r, i);
 856             }
 857         }
 858 
 859         assertShiftArraysEquals(a, b, r, mask, LongMaxVectorTests::aShiftR_unary);
 860     }
 861 
 862 
 863     static long shiftR_unary(long a, long b) {
 864         return (long)((a >>> b));
 865     }
 866 
 867     @Test(dataProvider = "longBinaryOpProvider")
 868     static void shiftRLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 869         long[] a = fa.apply(SPECIES.length());
 870         long[] b = fb.apply(SPECIES.length());
 871         long[] r = fr.apply(SPECIES.length());
 872 
 873         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 874             for (int i = 0; i < a.length; i += SPECIES.length()) {
 875                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 876                 av.shiftR((int)b[i]).intoArray(r, i);
 877             }
 878         }
 879 
 880         assertShiftArraysEquals(a, b, r, LongMaxVectorTests::shiftR_unary);
 881     }
 882 
 883 
 884 
 885     @Test(dataProvider = "longBinaryOpMaskProvider")
 886     static void shiftRLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 887                                           IntFunction<boolean[]> fm) {
 888         long[] a = fa.apply(SPECIES.length());
 889         long[] b = fb.apply(SPECIES.length());
 890         long[] r = fr.apply(SPECIES.length());
 891         boolean[] mask = fm.apply(SPECIES.length());
 892         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 893 
 894         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 895             for (int i = 0; i < a.length; i += SPECIES.length()) {
 896                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 897                 av.shiftR((int)b[i], vmask).intoArray(r, i);
 898             }
 899         }
 900 
 901         assertShiftArraysEquals(a, b, r, mask, LongMaxVectorTests::shiftR_unary);
 902     }
 903 
 904 
 905     static long shiftL_unary(long a, long b) {
 906         return (long)((a << b));
 907     }
 908 
 909     @Test(dataProvider = "longBinaryOpProvider")
 910     static void shiftLLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 911         long[] a = fa.apply(SPECIES.length());
 912         long[] b = fb.apply(SPECIES.length());
 913         long[] r = fr.apply(SPECIES.length());
 914 
 915         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 916             for (int i = 0; i < a.length; i += SPECIES.length()) {
 917                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 918                 av.shiftL((int)b[i]).intoArray(r, i);
 919             }
 920         }
 921 
 922         assertShiftArraysEquals(a, b, r, LongMaxVectorTests::shiftL_unary);
 923     }
 924 
 925 
 926 
 927     @Test(dataProvider = "longBinaryOpMaskProvider")
 928     static void shiftLLongMaxVectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,
 929                                           IntFunction<boolean[]> fm) {
 930         long[] a = fa.apply(SPECIES.length());
 931         long[] b = fb.apply(SPECIES.length());
 932         long[] r = fr.apply(SPECIES.length());
 933         boolean[] mask = fm.apply(SPECIES.length());
 934         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
 935 
 936         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 937             for (int i = 0; i < a.length; i += SPECIES.length()) {
 938                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 939                 av.shiftL((int)b[i], vmask).intoArray(r, i);
 940             }
 941         }
 942 
 943         assertShiftArraysEquals(a, b, r, mask, LongMaxVectorTests::shiftL_unary);
 944     }
 945 
 946 
 947 
 948 
 949 
 950 
 951 
 952 
 953 
 954 
 955 
 956 
 957 
 958     static long max(long a, long b) {
 959         return (long)(Math.max(a, b));
 960     }
 961 
 962     @Test(dataProvider = "longBinaryOpProvider")
 963     static void maxLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 964         long[] a = fa.apply(SPECIES.length());
 965         long[] b = fb.apply(SPECIES.length());
 966         long[] r = fr.apply(SPECIES.length());
 967 
 968         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 969             for (int i = 0; i < a.length; i += SPECIES.length()) {
 970                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 971                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 972                 av.max(bv).intoArray(r, i);
 973             }
 974         }
 975 
 976         assertArraysEquals(a, b, r, LongMaxVectorTests::max);
 977     }
 978     static long min(long a, long b) {
 979         return (long)(Math.min(a, b));
 980     }
 981 
 982     @Test(dataProvider = "longBinaryOpProvider")
 983     static void minLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
 984         long[] a = fa.apply(SPECIES.length());
 985         long[] b = fb.apply(SPECIES.length());
 986         long[] r = fr.apply(SPECIES.length());
 987 
 988         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 989             for (int i = 0; i < a.length; i += SPECIES.length()) {
 990                 LongVector av = LongVector.fromArray(SPECIES, a, i);
 991                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
 992                 av.min(bv).intoArray(r, i);
 993             }
 994         }
 995 
 996         assertArraysEquals(a, b, r, LongMaxVectorTests::min);
 997     }
 998 
 999     static long andAll(long[] a, int idx) {
1000         long res = -1;
1001         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1002             res &= a[i];
1003         }
1004 
1005         return res;
1006     }
1007 
1008     static long andAll(long[] a) {
1009         long res = -1;
1010         for (int i = 0; i < a.length; i += SPECIES.length()) {
1011             long tmp = -1;
1012             for (int j = 0; j < SPECIES.length(); j++) {
1013                 tmp &= a[i + j];
1014             }
1015             res &= tmp;
1016         }
1017 
1018         return res;
1019     }
1020 
1021 
1022     @Test(dataProvider = "longUnaryOpProvider")
1023     static void andAllLongMaxVectorTests(IntFunction<long[]> fa) {
1024         long[] a = fa.apply(SPECIES.length());
1025         long[] r = fr.apply(SPECIES.length());
1026         long ra = -1;
1027 
1028         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1029             for (int i = 0; i < a.length; i += SPECIES.length()) {
1030                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1031                 r[i] = av.andAll();
1032             }
1033         }
1034 
1035         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1036             ra = -1;
1037             for (int i = 0; i < a.length; i += SPECIES.length()) {
1038                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1039                 ra &= av.andAll();
1040             }
1041         }
1042 
1043         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::andAll, LongMaxVectorTests::andAll);
1044     }
1045 
1046 
1047     static long orAll(long[] a, int idx) {
1048         long res = 0;
1049         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1050             res |= a[i];
1051         }
1052 
1053         return res;
1054     }
1055 
1056     static long orAll(long[] a) {
1057         long res = 0;
1058         for (int i = 0; i < a.length; i += SPECIES.length()) {
1059             long tmp = 0;
1060             for (int j = 0; j < SPECIES.length(); j++) {
1061                 tmp |= a[i + j];
1062             }
1063             res |= tmp;
1064         }
1065 
1066         return res;
1067     }
1068 
1069 
1070     @Test(dataProvider = "longUnaryOpProvider")
1071     static void orAllLongMaxVectorTests(IntFunction<long[]> fa) {
1072         long[] a = fa.apply(SPECIES.length());
1073         long[] r = fr.apply(SPECIES.length());
1074         long ra = 0;
1075 
1076         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1077             for (int i = 0; i < a.length; i += SPECIES.length()) {
1078                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1079                 r[i] = av.orAll();
1080             }
1081         }
1082 
1083         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1084             ra = 0;
1085             for (int i = 0; i < a.length; i += SPECIES.length()) {
1086                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1087                 ra |= av.orAll();
1088             }
1089         }
1090 
1091         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::orAll, LongMaxVectorTests::orAll);
1092     }
1093 
1094 
1095     static long xorAll(long[] a, int idx) {
1096         long res = 0;
1097         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1098             res ^= a[i];
1099         }
1100 
1101         return res;
1102     }
1103 
1104     static long xorAll(long[] a) {
1105         long res = 0;
1106         for (int i = 0; i < a.length; i += SPECIES.length()) {
1107             long tmp = 0;
1108             for (int j = 0; j < SPECIES.length(); j++) {
1109                 tmp ^= a[i + j];
1110             }
1111             res ^= tmp;
1112         }
1113 
1114         return res;
1115     }
1116 
1117 
1118     @Test(dataProvider = "longUnaryOpProvider")
1119     static void xorAllLongMaxVectorTests(IntFunction<long[]> fa) {
1120         long[] a = fa.apply(SPECIES.length());
1121         long[] r = fr.apply(SPECIES.length());
1122         long ra = 0;
1123 
1124         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1125             for (int i = 0; i < a.length; i += SPECIES.length()) {
1126                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1127                 r[i] = av.xorAll();
1128             }
1129         }
1130 
1131         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1132             ra = 0;
1133             for (int i = 0; i < a.length; i += SPECIES.length()) {
1134                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1135                 ra ^= av.xorAll();
1136             }
1137         }
1138 
1139         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::xorAll, LongMaxVectorTests::xorAll);
1140     }
1141 
1142     static long addAll(long[] a, int idx) {
1143         long res = 0;
1144         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1145             res += a[i];
1146         }
1147 
1148         return res;
1149     }
1150 
1151     static long addAll(long[] a) {
1152         long res = 0;
1153         for (int i = 0; i < a.length; i += SPECIES.length()) {
1154             long tmp = 0;
1155             for (int j = 0; j < SPECIES.length(); j++) {
1156                 tmp += a[i + j];
1157             }
1158             res += tmp;
1159         }
1160 
1161         return res;
1162     }
1163     @Test(dataProvider = "longUnaryOpProvider")
1164     static void addAllLongMaxVectorTests(IntFunction<long[]> fa) {
1165         long[] a = fa.apply(SPECIES.length());
1166         long[] r = fr.apply(SPECIES.length());
1167         long ra = 0;
1168 
1169         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1170             for (int i = 0; i < a.length; i += SPECIES.length()) {
1171                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1172                 r[i] = av.addAll();
1173             }
1174         }
1175 
1176         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1177             ra = 0;
1178             for (int i = 0; i < a.length; i += SPECIES.length()) {
1179                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1180                 ra += av.addAll();
1181             }
1182         }
1183 
1184         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::addAll, LongMaxVectorTests::addAll);
1185     }
1186     static long mulAll(long[] a, int idx) {
1187         long res = 1;
1188         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1189             res *= a[i];
1190         }
1191 
1192         return res;
1193     }
1194 
1195     static long mulAll(long[] a) {
1196         long res = 1;
1197         for (int i = 0; i < a.length; i += SPECIES.length()) {
1198             long tmp = 1;
1199             for (int j = 0; j < SPECIES.length(); j++) {
1200                 tmp *= a[i + j];
1201             }
1202             res *= tmp;
1203         }
1204 
1205         return res;
1206     }
1207     @Test(dataProvider = "longUnaryOpProvider")
1208     static void mulAllLongMaxVectorTests(IntFunction<long[]> fa) {
1209         long[] a = fa.apply(SPECIES.length());
1210         long[] r = fr.apply(SPECIES.length());
1211         long ra = 1;
1212 
1213         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1214             for (int i = 0; i < a.length; i += SPECIES.length()) {
1215                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1216                 r[i] = av.mulAll();
1217             }
1218         }
1219 
1220         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1221             ra = 1;
1222             for (int i = 0; i < a.length; i += SPECIES.length()) {
1223                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1224                 ra *= av.mulAll();
1225             }
1226         }
1227 
1228         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::mulAll, LongMaxVectorTests::mulAll);
1229     }
1230     static long minAll(long[] a, int idx) {
1231         long res = Long.MAX_VALUE;
1232         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1233             res = (long)Math.min(res, a[i]);
1234         }
1235 
1236         return res;
1237     }
1238 
1239     static long minAll(long[] a) {
1240         long res = Long.MAX_VALUE;
1241         for (int i = 0; i < a.length; i++) {
1242             res = (long)Math.min(res, a[i]);
1243         }
1244 
1245         return res;
1246     }
1247     @Test(dataProvider = "longUnaryOpProvider")
1248     static void minAllLongMaxVectorTests(IntFunction<long[]> fa) {
1249         long[] a = fa.apply(SPECIES.length());
1250         long[] r = fr.apply(SPECIES.length());
1251         long ra = Long.MAX_VALUE;
1252 
1253         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1254             for (int i = 0; i < a.length; i += SPECIES.length()) {
1255                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1256                 r[i] = av.minAll();
1257             }
1258         }
1259 
1260         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1261             ra = Long.MAX_VALUE;
1262             for (int i = 0; i < a.length; i += SPECIES.length()) {
1263                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1264                 ra = (long)Math.min(ra, av.minAll());
1265             }
1266         }
1267 
1268         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::minAll, LongMaxVectorTests::minAll);
1269     }
1270     static long maxAll(long[] a, int idx) {
1271         long res = Long.MIN_VALUE;
1272         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1273             res = (long)Math.max(res, a[i]);
1274         }
1275 
1276         return res;
1277     }
1278 
1279     static long maxAll(long[] a) {
1280         long res = Long.MIN_VALUE;
1281         for (int i = 0; i < a.length; i++) {
1282             res = (long)Math.max(res, a[i]);
1283         }
1284 
1285         return res;
1286     }
1287     @Test(dataProvider = "longUnaryOpProvider")
1288     static void maxAllLongMaxVectorTests(IntFunction<long[]> fa) {
1289         long[] a = fa.apply(SPECIES.length());
1290         long[] r = fr.apply(SPECIES.length());
1291         long ra = Long.MIN_VALUE;
1292 
1293         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1294             for (int i = 0; i < a.length; i += SPECIES.length()) {
1295                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1296                 r[i] = av.maxAll();
1297             }
1298         }
1299 
1300         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1301             ra = Long.MIN_VALUE;
1302             for (int i = 0; i < a.length; i += SPECIES.length()) {
1303                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1304                 ra = (long)Math.max(ra, av.maxAll());
1305             }
1306         }
1307 
1308         assertReductionArraysEquals(a, r, ra, LongMaxVectorTests::maxAll, LongMaxVectorTests::maxAll);
1309     }
1310 
1311     static boolean anyTrue(boolean[] a, int idx) {
1312         boolean res = false;
1313         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1314             res |= a[i];
1315         }
1316 
1317         return res;
1318     }
1319 
1320 
1321     @Test(dataProvider = "boolUnaryOpProvider")
1322     static void anyTrueLongMaxVectorTests(IntFunction<boolean[]> fm) {
1323         boolean[] mask = fm.apply(SPECIES.length());
1324         boolean[] r = fmr.apply(SPECIES.length());
1325 
1326         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1327             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1328                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
1329                 r[i] = vmask.anyTrue();
1330             }
1331         }
1332 
1333         assertReductionBoolArraysEquals(mask, r, LongMaxVectorTests::anyTrue);
1334     }
1335 
1336 
1337     static boolean allTrue(boolean[] a, int idx) {
1338         boolean res = true;
1339         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1340             res &= a[i];
1341         }
1342 
1343         return res;
1344     }
1345 
1346 
1347     @Test(dataProvider = "boolUnaryOpProvider")
1348     static void allTrueLongMaxVectorTests(IntFunction<boolean[]> fm) {
1349         boolean[] mask = fm.apply(SPECIES.length());
1350         boolean[] r = fmr.apply(SPECIES.length());
1351 
1352         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1353             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1354                 VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);
1355                 r[i] = vmask.allTrue();
1356             }
1357         }
1358 
1359         assertReductionBoolArraysEquals(mask, r, LongMaxVectorTests::allTrue);
1360     }
1361 
1362 
1363     @Test(dataProvider = "longUnaryOpProvider")
1364     static void withLongMaxVectorTests(IntFunction<long []> fa) {
1365         long[] a = fa.apply(SPECIES.length());
1366         long[] r = fr.apply(SPECIES.length());
1367 
1368         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1369             for (int i = 0; i < a.length; i += SPECIES.length()) {
1370                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1371                 av.with(0, (long)4).intoArray(r, i);
1372             }
1373         }
1374 
1375         assertInsertArraysEquals(a, r, (long)4, 0);
1376     }
1377 
1378     @Test(dataProvider = "longCompareOpProvider")
1379     static void lessThanLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1380         long[] a = fa.apply(SPECIES.length());
1381         long[] b = fb.apply(SPECIES.length());
1382 
1383         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1384             for (int i = 0; i < a.length; i += SPECIES.length()) {
1385                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1386                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1387                 VectorMask<Long> mv = av.lessThan(bv);
1388 
1389                 // Check results as part of computation.
1390                 for (int j = 0; j < SPECIES.length(); j++) {
1391                     Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
1392                 }
1393             }
1394         }
1395     }
1396 
1397 
1398     @Test(dataProvider = "longCompareOpProvider")
1399     static void greaterThanLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1400         long[] a = fa.apply(SPECIES.length());
1401         long[] b = fb.apply(SPECIES.length());
1402 
1403         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1404             for (int i = 0; i < a.length; i += SPECIES.length()) {
1405                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1406                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1407                 VectorMask<Long> mv = av.greaterThan(bv);
1408 
1409                 // Check results as part of computation.
1410                 for (int j = 0; j < SPECIES.length(); j++) {
1411                     Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
1412                 }
1413             }
1414         }
1415     }
1416 
1417 
1418     @Test(dataProvider = "longCompareOpProvider")
1419     static void equalLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1420         long[] a = fa.apply(SPECIES.length());
1421         long[] b = fb.apply(SPECIES.length());
1422 
1423         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1424             for (int i = 0; i < a.length; i += SPECIES.length()) {
1425                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1426                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1427                 VectorMask<Long> mv = av.equal(bv);
1428 
1429                 // Check results as part of computation.
1430                 for (int j = 0; j < SPECIES.length(); j++) {
1431                     Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
1432                 }
1433             }
1434         }
1435     }
1436 
1437 
1438     @Test(dataProvider = "longCompareOpProvider")
1439     static void notEqualLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1440         long[] a = fa.apply(SPECIES.length());
1441         long[] b = fb.apply(SPECIES.length());
1442 
1443         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1444             for (int i = 0; i < a.length; i += SPECIES.length()) {
1445                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1446                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1447                 VectorMask<Long> mv = av.notEqual(bv);
1448 
1449                 // Check results as part of computation.
1450                 for (int j = 0; j < SPECIES.length(); j++) {
1451                     Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
1452                 }
1453             }
1454         }
1455     }
1456 
1457 
1458     @Test(dataProvider = "longCompareOpProvider")
1459     static void lessThanEqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1460         long[] a = fa.apply(SPECIES.length());
1461         long[] b = fb.apply(SPECIES.length());
1462 
1463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1464             for (int i = 0; i < a.length; i += SPECIES.length()) {
1465                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1466                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1467                 VectorMask<Long> mv = av.lessThanEq(bv);
1468 
1469                 // Check results as part of computation.
1470                 for (int j = 0; j < SPECIES.length(); j++) {
1471                     Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
1472                 }
1473             }
1474         }
1475     }
1476 
1477 
1478     @Test(dataProvider = "longCompareOpProvider")
1479     static void greaterThanEqLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
1480         long[] a = fa.apply(SPECIES.length());
1481         long[] b = fb.apply(SPECIES.length());
1482 
1483         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1484             for (int i = 0; i < a.length; i += SPECIES.length()) {
1485                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1486                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1487                 VectorMask<Long> mv = av.greaterThanEq(bv);
1488 
1489                 // Check results as part of computation.
1490                 for (int j = 0; j < SPECIES.length(); j++) {
1491                     Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
1492                 }
1493             }
1494         }
1495     }
1496 
1497 
1498     static long blend(long a, long b, boolean mask) {
1499         return mask ? b : a;
1500     }
1501 
1502     @Test(dataProvider = "longBinaryOpMaskProvider")
1503     static void blendLongMaxVectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,
1504                                           IntFunction<boolean[]> fm) {
1505         long[] a = fa.apply(SPECIES.length());
1506         long[] b = fb.apply(SPECIES.length());
1507         long[] r = fr.apply(SPECIES.length());
1508         boolean[] mask = fm.apply(SPECIES.length());
1509         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1510 
1511         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1512             for (int i = 0; i < a.length; i += SPECIES.length()) {
1513                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1514                 LongVector bv = LongVector.fromArray(SPECIES, b, i);
1515                 av.blend(bv, vmask).intoArray(r, i);
1516             }
1517         }
1518 
1519         assertArraysEquals(a, b, r, mask, LongMaxVectorTests::blend);
1520     }
1521 
1522     @Test(dataProvider = "longUnaryOpShuffleProvider")
1523     static void RearrangeLongMaxVectorTests(IntFunction<long[]> fa,
1524                                            BiFunction<Integer,Integer,int[]> fs) {
1525         long[] a = fa.apply(SPECIES.length());
1526         int[] order = fs.apply(a.length, SPECIES.length());
1527         long[] r = fr.apply(SPECIES.length());
1528 
1529         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1530             for (int i = 0; i < a.length; i += SPECIES.length()) {
1531                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1532                 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
1533             }
1534         }
1535 
1536         assertRearrangeArraysEquals(a, r, order, SPECIES.length());
1537     }
1538 
1539 
1540 
1541 
1542     @Test(dataProvider = "longUnaryOpProvider")
1543     static void getLongMaxVectorTests(IntFunction<long[]> fa) {
1544         long[] a = fa.apply(SPECIES.length());
1545         long[] r = fr.apply(SPECIES.length());
1546 
1547         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1548             for (int i = 0; i < a.length; i += SPECIES.length()) {
1549                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1550                 int num_lanes = SPECIES.length();
1551                 // Manually unroll because full unroll happens after intrinsification.
1552                 // Unroll is needed because get intrinsic requires for index to be a known constant.
1553                 if (num_lanes == 1) {
1554                     r[i]=av.get(0);
1555                 } else if (num_lanes == 2) {
1556                     r[i]=av.get(0);
1557                     r[i+1]=av.get(1);
1558                 } else if (num_lanes == 4) {
1559                     r[i]=av.get(0);
1560                     r[i+1]=av.get(1);
1561                     r[i+2]=av.get(2);
1562                     r[i+3]=av.get(3);
1563                 } else if (num_lanes == 8) {
1564                     r[i]=av.get(0);
1565                     r[i+1]=av.get(1);
1566                     r[i+2]=av.get(2);
1567                     r[i+3]=av.get(3);
1568                     r[i+4]=av.get(4);
1569                     r[i+5]=av.get(5);
1570                     r[i+6]=av.get(6);
1571                     r[i+7]=av.get(7);
1572                 } else if (num_lanes == 16) {
1573                     r[i]=av.get(0);
1574                     r[i+1]=av.get(1);
1575                     r[i+2]=av.get(2);
1576                     r[i+3]=av.get(3);
1577                     r[i+4]=av.get(4);
1578                     r[i+5]=av.get(5);
1579                     r[i+6]=av.get(6);
1580                     r[i+7]=av.get(7);
1581                     r[i+8]=av.get(8);
1582                     r[i+9]=av.get(9);
1583                     r[i+10]=av.get(10);
1584                     r[i+11]=av.get(11);
1585                     r[i+12]=av.get(12);
1586                     r[i+13]=av.get(13);
1587                     r[i+14]=av.get(14);
1588                     r[i+15]=av.get(15);
1589                 } else if (num_lanes == 32) {
1590                     r[i]=av.get(0);
1591                     r[i+1]=av.get(1);
1592                     r[i+2]=av.get(2);
1593                     r[i+3]=av.get(3);
1594                     r[i+4]=av.get(4);
1595                     r[i+5]=av.get(5);
1596                     r[i+6]=av.get(6);
1597                     r[i+7]=av.get(7);
1598                     r[i+8]=av.get(8);
1599                     r[i+9]=av.get(9);
1600                     r[i+10]=av.get(10);
1601                     r[i+11]=av.get(11);
1602                     r[i+12]=av.get(12);
1603                     r[i+13]=av.get(13);
1604                     r[i+14]=av.get(14);
1605                     r[i+15]=av.get(15);
1606                     r[i+16]=av.get(16);
1607                     r[i+17]=av.get(17);
1608                     r[i+18]=av.get(18);
1609                     r[i+19]=av.get(19);
1610                     r[i+20]=av.get(20);
1611                     r[i+21]=av.get(21);
1612                     r[i+22]=av.get(22);
1613                     r[i+23]=av.get(23);
1614                     r[i+24]=av.get(24);
1615                     r[i+25]=av.get(25);
1616                     r[i+26]=av.get(26);
1617                     r[i+27]=av.get(27);
1618                     r[i+28]=av.get(28);
1619                     r[i+29]=av.get(29);
1620                     r[i+30]=av.get(30);
1621                     r[i+31]=av.get(31);
1622                 } else if (num_lanes == 64) {
1623                     r[i]=av.get(0);
1624                     r[i+1]=av.get(1);
1625                     r[i+2]=av.get(2);
1626                     r[i+3]=av.get(3);
1627                     r[i+4]=av.get(4);
1628                     r[i+5]=av.get(5);
1629                     r[i+6]=av.get(6);
1630                     r[i+7]=av.get(7);
1631                     r[i+8]=av.get(8);
1632                     r[i+9]=av.get(9);
1633                     r[i+10]=av.get(10);
1634                     r[i+11]=av.get(11);
1635                     r[i+12]=av.get(12);
1636                     r[i+13]=av.get(13);
1637                     r[i+14]=av.get(14);
1638                     r[i+15]=av.get(15);
1639                     r[i+16]=av.get(16);
1640                     r[i+17]=av.get(17);
1641                     r[i+18]=av.get(18);
1642                     r[i+19]=av.get(19);
1643                     r[i+20]=av.get(20);
1644                     r[i+21]=av.get(21);
1645                     r[i+22]=av.get(22);
1646                     r[i+23]=av.get(23);
1647                     r[i+24]=av.get(24);
1648                     r[i+25]=av.get(25);
1649                     r[i+26]=av.get(26);
1650                     r[i+27]=av.get(27);
1651                     r[i+28]=av.get(28);
1652                     r[i+29]=av.get(29);
1653                     r[i+30]=av.get(30);
1654                     r[i+31]=av.get(31);
1655                     r[i+32]=av.get(32);
1656                     r[i+33]=av.get(33);
1657                     r[i+34]=av.get(34);
1658                     r[i+35]=av.get(35);
1659                     r[i+36]=av.get(36);
1660                     r[i+37]=av.get(37);
1661                     r[i+38]=av.get(38);
1662                     r[i+39]=av.get(39);
1663                     r[i+40]=av.get(40);
1664                     r[i+41]=av.get(41);
1665                     r[i+42]=av.get(42);
1666                     r[i+43]=av.get(43);
1667                     r[i+44]=av.get(44);
1668                     r[i+45]=av.get(45);
1669                     r[i+46]=av.get(46);
1670                     r[i+47]=av.get(47);
1671                     r[i+48]=av.get(48);
1672                     r[i+49]=av.get(49);
1673                     r[i+50]=av.get(50);
1674                     r[i+51]=av.get(51);
1675                     r[i+52]=av.get(52);
1676                     r[i+53]=av.get(53);
1677                     r[i+54]=av.get(54);
1678                     r[i+55]=av.get(55);
1679                     r[i+56]=av.get(56);
1680                     r[i+57]=av.get(57);
1681                     r[i+58]=av.get(58);
1682                     r[i+59]=av.get(59);
1683                     r[i+60]=av.get(60);
1684                     r[i+61]=av.get(61);
1685                     r[i+62]=av.get(62);
1686                     r[i+63]=av.get(63);
1687                 } else {
1688                     for (int j = 0; j < SPECIES.length(); j++) {
1689                         r[i+j]=av.get(j);
1690                     }
1691                 }
1692             }
1693         }
1694 
1695         assertArraysEquals(a, r, LongMaxVectorTests::get);
1696     }
1697 
1698 
1699 
1700 
1701 
1702 
1703 
1704 
1705 
1706 
1707 
1708 
1709 
1710 
1711 
1712 
1713 
1714 
1715 
1716 
1717 
1718 
1719     static long neg(long a) {
1720         return (long)(-((long)a));
1721     }
1722 
1723     @Test(dataProvider = "longUnaryOpProvider")
1724     static void negLongMaxVectorTests(IntFunction<long[]> fa) {
1725         long[] a = fa.apply(SPECIES.length());
1726         long[] r = fr.apply(SPECIES.length());
1727 
1728         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1729             for (int i = 0; i < a.length; i += SPECIES.length()) {
1730                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1731                 av.neg().intoArray(r, i);
1732             }
1733         }
1734 
1735         assertArraysEquals(a, r, LongMaxVectorTests::neg);
1736     }
1737 
1738     @Test(dataProvider = "longUnaryOpMaskProvider")
1739     static void negMaskedLongMaxVectorTests(IntFunction<long[]> fa,
1740                                                 IntFunction<boolean[]> fm) {
1741         long[] a = fa.apply(SPECIES.length());
1742         long[] r = fr.apply(SPECIES.length());
1743         boolean[] mask = fm.apply(SPECIES.length());
1744         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1745 
1746         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1747             for (int i = 0; i < a.length; i += SPECIES.length()) {
1748                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1749                 av.neg(vmask).intoArray(r, i);
1750             }
1751         }
1752 
1753         assertArraysEquals(a, r, mask, LongMaxVectorTests::neg);
1754     }
1755 
1756     static long abs(long a) {
1757         return (long)(Math.abs((long)a));
1758     }
1759 
1760     @Test(dataProvider = "longUnaryOpProvider")
1761     static void absLongMaxVectorTests(IntFunction<long[]> fa) {
1762         long[] a = fa.apply(SPECIES.length());
1763         long[] r = fr.apply(SPECIES.length());
1764 
1765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1766             for (int i = 0; i < a.length; i += SPECIES.length()) {
1767                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1768                 av.abs().intoArray(r, i);
1769             }
1770         }
1771 
1772         assertArraysEquals(a, r, LongMaxVectorTests::abs);
1773     }
1774 
1775     @Test(dataProvider = "longUnaryOpMaskProvider")
1776     static void absMaskedLongMaxVectorTests(IntFunction<long[]> fa,
1777                                                 IntFunction<boolean[]> fm) {
1778         long[] a = fa.apply(SPECIES.length());
1779         long[] r = fr.apply(SPECIES.length());
1780         boolean[] mask = fm.apply(SPECIES.length());
1781         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1782 
1783         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1784             for (int i = 0; i < a.length; i += SPECIES.length()) {
1785                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1786                 av.abs(vmask).intoArray(r, i);
1787             }
1788         }
1789 
1790         assertArraysEquals(a, r, mask, LongMaxVectorTests::abs);
1791     }
1792 
1793 
1794     static long not(long a) {
1795         return (long)(~((long)a));
1796     }
1797 
1798 
1799 
1800     @Test(dataProvider = "longUnaryOpProvider")
1801     static void notLongMaxVectorTests(IntFunction<long[]> fa) {
1802         long[] a = fa.apply(SPECIES.length());
1803         long[] r = fr.apply(SPECIES.length());
1804 
1805         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1806             for (int i = 0; i < a.length; i += SPECIES.length()) {
1807                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1808                 av.not().intoArray(r, i);
1809             }
1810         }
1811 
1812         assertArraysEquals(a, r, LongMaxVectorTests::not);
1813     }
1814 
1815 
1816 
1817     @Test(dataProvider = "longUnaryOpMaskProvider")
1818     static void notMaskedLongMaxVectorTests(IntFunction<long[]> fa,
1819                                                 IntFunction<boolean[]> fm) {
1820         long[] a = fa.apply(SPECIES.length());
1821         long[] r = fr.apply(SPECIES.length());
1822         boolean[] mask = fm.apply(SPECIES.length());
1823         VectorMask<Long> vmask = VectorMask.fromValues(SPECIES, mask);
1824 
1825         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1826             for (int i = 0; i < a.length; i += SPECIES.length()) {
1827                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1828                 av.not(vmask).intoArray(r, i);
1829             }
1830         }
1831 
1832         assertArraysEquals(a, r, mask, LongMaxVectorTests::not);
1833     }
1834 
1835 
1836 
1837 
1838 
1839     static long[] gather(long a[], int ix, int[] b, int iy) {
1840         long[] res = new long[SPECIES.length()];
1841         for (int i = 0; i < SPECIES.length(); i++) {
1842             int bi = iy + i;
1843             res[i] = a[b[bi] + ix];
1844         }
1845         return res;
1846     }
1847 
1848     @Test(dataProvider = "longUnaryOpIndexProvider")
1849     static void gatherLongMaxVectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1850         long[] a = fa.apply(SPECIES.length());
1851         int[] b    = fs.apply(a.length, SPECIES.length());
1852         long[] r = new long[a.length];
1853 
1854         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1855             for (int i = 0; i < a.length; i += SPECIES.length()) {
1856                 LongVector av = LongVector.fromArray(SPECIES, a, i, b, i);
1857                 av.intoArray(r, i);
1858             }
1859         }
1860 
1861         assertArraysEquals(a, b, r, LongMaxVectorTests::gather);
1862     }
1863 
1864 
1865     static long[] scatter(long a[], int ix, int[] b, int iy) {
1866       long[] res = new long[SPECIES.length()];
1867       for (int i = 0; i < SPECIES.length(); i++) {
1868         int bi = iy + i;
1869         res[b[bi]] = a[i + ix];
1870       }
1871       return res;
1872     }
1873 
1874     @Test(dataProvider = "longUnaryOpIndexProvider")
1875     static void scatterLongMaxVectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {
1876         long[] a = fa.apply(SPECIES.length());
1877         int[] b = fs.apply(a.length, SPECIES.length());
1878         long[] r = new long[a.length];
1879 
1880         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1881             for (int i = 0; i < a.length; i += SPECIES.length()) {
1882                 LongVector av = LongVector.fromArray(SPECIES, a, i);
1883                 av.intoArray(r, i, b, i);
1884             }
1885         }
1886 
1887         assertArraysEquals(a, b, r, LongMaxVectorTests::scatter);
1888     }
1889 
1890 }
1891 
--- EOF ---