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