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