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