Path: blob/master/test/jdk/jdk/incubator/vector/Long256VectorTests.java
42588 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @modules jdk.incubator.vector26* @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Long256VectorTests27*/2829// -- This file was mechanically generated: Do not edit! -- //3031import jdk.incubator.vector.VectorShape;32import jdk.incubator.vector.VectorSpecies;33import jdk.incubator.vector.VectorShuffle;34import jdk.incubator.vector.VectorMask;35import jdk.incubator.vector.VectorOperators;36import jdk.incubator.vector.Vector;3738import jdk.incubator.vector.LongVector;3940import org.testng.Assert;41import org.testng.annotations.DataProvider;42import org.testng.annotations.Test;4344import java.lang.Integer;45import java.util.List;46import java.util.Arrays;47import java.util.function.BiFunction;48import java.util.function.IntFunction;49import java.util.Objects;50import java.util.stream.Collectors;51import java.util.stream.Stream;5253@Test54public class Long256VectorTests extends AbstractVectorTest {5556static final VectorSpecies<Long> SPECIES =57LongVector.SPECIES_256;5859static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);606162static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);6364static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (256 / 8));6566interface FUnOp {67long apply(long a);68}6970static void assertArraysEquals(long[] r, long[] a, FUnOp f) {71int i = 0;72try {73for (; i < a.length; i++) {74Assert.assertEquals(r[i], f.apply(a[i]));75}76} catch (AssertionError e) {77Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);78}79}8081interface FUnArrayOp {82long[] apply(long a);83}8485static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) {86int i = 0;87try {88for (; i < a.length; i += SPECIES.length()) {89Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),90f.apply(a[i]));91}92} catch (AssertionError e) {93long[] ref = f.apply(a[i]);94long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());95Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)96+ ", res: " + Arrays.toString(res)97+ "), at index #" + i);98}99}100101static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) {102int i = 0;103try {104for (; i < a.length; i++) {105Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);106}107} catch (AssertionError e) {108Assert.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}111112interface FReductionOp {113long apply(long[] a, int idx);114}115116interface FReductionAllOp {117long apply(long[] a);118}119120static void assertReductionArraysEquals(long[] r, long rc, long[] a,121FReductionOp f, FReductionAllOp fa) {122int i = 0;123try {124Assert.assertEquals(rc, fa.apply(a));125for (; i < a.length; i += SPECIES.length()) {126Assert.assertEquals(r[i], f.apply(a, i));127}128} catch (AssertionError e) {129Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");130Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);131}132}133134interface FReductionMaskedOp {135long apply(long[] a, int idx, boolean[] mask);136}137138interface FReductionAllMaskedOp {139long apply(long[] a, boolean[] mask);140}141142static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boolean[] mask,143FReductionMaskedOp f, FReductionAllMaskedOp fa) {144int i = 0;145try {146Assert.assertEquals(rc, fa.apply(a, mask));147for (; i < a.length; i += SPECIES.length()) {148Assert.assertEquals(r[i], f.apply(a, i, mask));149}150} catch (AssertionError e) {151Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");152Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);153}154}155156157interface FBoolReductionOp {158boolean apply(boolean[] a, int idx);159}160161static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {162int i = 0;163try {164for (; i < a.length; i += SPECIES.length()) {165Assert.assertEquals(r[i], f.apply(a, i));166}167} catch (AssertionError e) {168Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);169}170}171172static void assertInsertArraysEquals(long[] r, long[] a, long element, int index) {173int i = 0;174try {175for (; i < a.length; i += 1) {176if(i%SPECIES.length() == index) {177Assert.assertEquals(r[i], element);178} else {179Assert.assertEquals(r[i], a[i]);180}181}182} catch (AssertionError e) {183if (i%SPECIES.length() == index) {184Assert.assertEquals(r[i], element, "at index #" + i);185} else {186Assert.assertEquals(r[i], a[i], "at index #" + i);187}188}189}190191static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vector_len) {192int i = 0, j = 0;193try {194for (; i < a.length; i += vector_len) {195for (j = 0; j < vector_len; j++) {196Assert.assertEquals(r[i+j], a[i+order[i+j]]);197}198}199} catch (AssertionError e) {200int idx = i + j;201Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);202}203}204205static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) {206int i = 0, j = 0;207try {208for (; i < a.length; i += vector_len) {209for (j = 0; j < vector_len; j++) {210Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);211}212}213} catch (AssertionError e) {214int idx = i + j;215Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);216}217}218219static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean[] mask, int vector_len) {220int i = 0, j = 0;221try {222for (; i < a.length; i += vector_len) {223for (j = 0; j < vector_len; j++) {224if (mask[j % SPECIES.length()])225Assert.assertEquals(r[i+j], a[i+order[i+j]]);226else227Assert.assertEquals(r[i+j], (long)0);228}229}230} catch (AssertionError e) {231int idx = i + j;232if (mask[j % SPECIES.length()])233Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);234else235Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);236}237}238239static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) {240int i = 0, j = 0;241try {242for (; i < a.length; i += vector_len) {243for (j = 0; j < vector_len; j++) {244if (mask[j % SPECIES.length()])245Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);246else247Assert.assertEquals(r[i+j], (long)0);248}249}250} catch (AssertionError e) {251int idx = i + j;252if (mask[j % SPECIES.length()])253Assert.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()]);254else255Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);256}257}258259static void assertBroadcastArraysEquals(long[] r, long[] a) {260int i = 0;261for (; i < a.length; i += SPECIES.length()) {262int idx = i;263for (int j = idx; j < (idx + SPECIES.length()); j++)264a[j]=a[idx];265}266267try {268for (i = 0; i < a.length; i++) {269Assert.assertEquals(r[i], a[i]);270}271} catch (AssertionError e) {272Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);273}274}275276interface FBinOp {277long apply(long a, long b);278}279280interface FBinMaskOp {281long apply(long a, long b, boolean m);282283static FBinMaskOp lift(FBinOp f) {284return (a, b, m) -> m ? f.apply(a, b) : a;285}286}287288static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {289int i = 0;290try {291for (; i < a.length; i++) {292Assert.assertEquals(r[i], f.apply(a[i], b[i]));293}294} catch (AssertionError e) {295Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);296}297}298299static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {300int i = 0;301try {302for (; i < a.length; i++) {303Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));304}305} catch (AssertionError e) {306Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),307"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);308}309}310311static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {312int i = 0;313try {314for (; i < a.length; i++) {315Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])));316}317} catch (AssertionError e) {318Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])),319"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);320}321}322323static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {324assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));325}326327static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {328int i = 0;329try {330for (; i < a.length; i++) {331Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));332}333} catch (AssertionError err) {334Assert.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()]);335}336}337338static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {339assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));340}341342static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {343int i = 0;344try {345for (; i < a.length; i++) {346Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));347}348} catch (AssertionError err) {349Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],350mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +351", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +352mask[i % SPECIES.length()]);353}354}355356static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {357assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));358}359360static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {361int i = 0;362try {363for (; i < a.length; i++) {364Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));365}366} catch (AssertionError err) {367Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]),368mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +369", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +370mask[i % SPECIES.length()]);371}372}373374static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) {375int i = 0;376int j = 0;377try {378for (; j < a.length; j += SPECIES.length()) {379for (i = 0; i < SPECIES.length(); i++) {380Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));381}382}383} catch (AssertionError e) {384Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);385}386}387388static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinOp f) {389assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));390}391392static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBinMaskOp f) {393int i = 0;394int j = 0;395try {396for (; j < a.length; j += SPECIES.length()) {397for (i = 0; i < SPECIES.length(); i++) {398Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));399}400}401} catch (AssertionError err) {402Assert.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]);403}404}405406interface FTernOp {407long apply(long a, long b, long c);408}409410interface FTernMaskOp {411long apply(long a, long b, long c, boolean m);412413static FTernMaskOp lift(FTernOp f) {414return (a, b, c, m) -> m ? f.apply(a, b, c) : a;415}416}417418static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {419int i = 0;420try {421for (; i < a.length; i++) {422Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));423}424} catch (AssertionError e) {425Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);426}427}428429static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernOp f) {430assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));431}432433static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask, FTernMaskOp f) {434int i = 0;435try {436for (; i < a.length; i++) {437Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));438}439} catch (AssertionError err) {440Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "441+ b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);442}443}444445static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {446int i = 0;447try {448for (; i < a.length; i++) {449Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));450}451} catch (AssertionError e) {452Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +453i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +454c[(i / SPECIES.length()) * SPECIES.length()]);455}456}457458static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {459int i = 0;460try {461for (; i < a.length; i++) {462Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));463}464} catch (AssertionError e) {465Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +466i + ", input1 = " + a[i] + ", input2 = " +467b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]);468}469}470471static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,472FTernOp f) {473assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));474}475476static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,477FTernMaskOp f) {478int i = 0;479try {480for (; i < a.length; i++) {481Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],482mask[i % SPECIES.length()]));483}484} catch (AssertionError err) {485Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],486mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +487b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +488mask[i % SPECIES.length()]);489}490}491492static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,493FTernOp f) {494assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));495}496497static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,498FTernMaskOp f) {499int i = 0;500try {501for (; i < a.length; i++) {502Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],503mask[i % SPECIES.length()]));504}505} catch (AssertionError err) {506Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],507mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +508", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +509", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);510}511}512513static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f) {514int i = 0;515try {516for (; i < a.length; i++) {517Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],518c[(i / SPECIES.length()) * SPECIES.length()]));519}520} catch (AssertionError e) {521Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],522c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]523+ ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +524c[(i / SPECIES.length()) * SPECIES.length()]);525}526}527528static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,529FTernOp f) {530assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));531}532533static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] mask,534FTernMaskOp f) {535int i = 0;536try {537for (; i < a.length; i++) {538Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],539c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));540}541} catch (AssertionError err) {542Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],543c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"544+ i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +545", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +546mask[i % SPECIES.length()]);547}548}549550551552interface FBinArrayOp {553long apply(long[] a, int b);554}555556static void assertArraysEquals(long[] r, long[] a, FBinArrayOp f) {557int i = 0;558try {559for (; i < a.length; i++) {560Assert.assertEquals(r[i], f.apply(a, i));561}562} catch (AssertionError e) {563Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);564}565}566567interface FGatherScatterOp {568long[] apply(long[] a, int ix, int[] b, int iy);569}570571static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) {572int i = 0;573try {574for (; i < a.length; i += SPECIES.length()) {575Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),576f.apply(a, i, b, i));577}578} catch (AssertionError e) {579long[] ref = f.apply(a, i, b, i);580long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());581Assert.assertEquals(res, ref,582"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "583+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))584+ ", b: "585+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))586+ " at index #" + i);587}588}589590interface FGatherMaskedOp {591long[] apply(long[] a, int ix, boolean[] mask, int[] b, int iy);592}593594interface FScatterMaskedOp {595long[] apply(long[] r, long[] a, int ix, boolean[] mask, int[] b, int iy);596}597598static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {599int i = 0;600try {601for (; i < a.length; i += SPECIES.length()) {602Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),603f.apply(a, i, mask, b, i));604}605} catch (AssertionError e) {606long[] ref = f.apply(a, i, mask, b, i);607long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());608Assert.assertEquals(res, ref,609"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "610+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))611+ ", b: "612+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))613+ ", mask: "614+ Arrays.toString(mask)615+ " at index #" + i);616}617}618619static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {620int i = 0;621try {622for (; i < a.length; i += SPECIES.length()) {623Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),624f.apply(r, a, i, mask, b, i));625}626} catch (AssertionError e) {627long[] ref = f.apply(r, a, i, mask, b, i);628long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());629Assert.assertEquals(res, ref,630"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "631+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))632+ ", b: "633+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))634+ ", r: "635+ Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))636+ ", mask: "637+ Arrays.toString(mask)638+ " at index #" + i);639}640}641642interface FLaneOp {643long[] apply(long[] a, int origin, int idx);644}645646static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) {647int i = 0;648try {649for (; i < a.length; i += SPECIES.length()) {650Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),651f.apply(a, origin, i));652}653} catch (AssertionError e) {654long[] ref = f.apply(a, origin, i);655long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());656Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)657+ ", res: " + Arrays.toString(res)658+ "), at index #" + i);659}660}661662interface FLaneBop {663long[] apply(long[] a, long[] b, int origin, int idx);664}665666static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBop f) {667int i = 0;668try {669for (; i < a.length; i += SPECIES.length()) {670Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),671f.apply(a, b, origin, i));672}673} catch (AssertionError e) {674long[] ref = f.apply(a, b, origin, i);675long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());676Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)677+ ", res: " + Arrays.toString(res)678+ "), at index #" + i679+ ", at origin #" + origin);680}681}682683interface FLaneMaskedBop {684long[] apply(long[] a, long[] b, int origin, boolean[] mask, int idx);685}686687static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean[] mask, FLaneMaskedBop f) {688int i = 0;689try {690for (; i < a.length; i += SPECIES.length()) {691Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),692f.apply(a, b, origin, mask, i));693}694} catch (AssertionError e) {695long[] ref = f.apply(a, b, origin, mask, i);696long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());697Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)698+ ", res: " + Arrays.toString(res)699+ "), at index #" + i700+ ", at origin #" + origin);701}702}703704interface FLanePartBop {705long[] apply(long[] a, long[] b, int origin, int part, int idx);706}707708static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, FLanePartBop f) {709int i = 0;710try {711for (; i < a.length; i += SPECIES.length()) {712Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),713f.apply(a, b, origin, part, i));714}715} catch (AssertionError e) {716long[] ref = f.apply(a, b, origin, part, i);717long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());718Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)719+ ", res: " + Arrays.toString(res)720+ "), at index #" + i721+ ", at origin #" + origin722+ ", with part #" + part);723}724}725726interface FLanePartMaskedBop {727long[] apply(long[] a, long[] b, int origin, int part, boolean[] mask, int idx);728}729730static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {731int i = 0;732try {733for (; i < a.length; i += SPECIES.length()) {734Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),735f.apply(a, b, origin, part, mask, i));736}737} catch (AssertionError e) {738long[] ref = f.apply(a, b, origin, part, mask, i);739long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());740Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)741+ ", res: " + Arrays.toString(res)742+ "), at index #" + i743+ ", at origin #" + origin744+ ", with part #" + part);745}746}747748static int intCornerCaseValue(int i) {749switch(i % 5) {750case 0:751return Integer.MAX_VALUE;752case 1:753return Integer.MIN_VALUE;754case 2:755return Integer.MIN_VALUE;756case 3:757return Integer.MAX_VALUE;758default:759return (int)0;760}761}762763static final List<IntFunction<long[]>> INT_LONG_GENERATORS = List.of(764withToString("long[-i * 5]", (int s) -> {765return fill(s * BUFFER_REPS,766i -> (long)(-i * 5));767}),768withToString("long[i * 5]", (int s) -> {769return fill(s * BUFFER_REPS,770i -> (long)(i * 5));771}),772withToString("long[i + 1]", (int s) -> {773return fill(s * BUFFER_REPS,774i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));775}),776withToString("long[intCornerCaseValue(i)]", (int s) -> {777return fill(s * BUFFER_REPS,778i -> (long)intCornerCaseValue(i));779})780);781782static void assertArraysEquals(int[] r, long[] a, int offs) {783int i = 0;784try {785for (; i < r.length; i++) {786Assert.assertEquals(r[i], (int)(a[i+offs]));787}788} catch (AssertionError e) {789Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);790}791}792793794795static void assertArraysEquals(long[] r, long[] a, int offs) {796int i = 0;797try {798for (; i < r.length; i++) {799Assert.assertEquals(r[i], (long)(a[i+offs]));800}801} catch (AssertionError e) {802Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);803}804}805806static void assertArraysEquals(double[] r, long[] a, int offs) {807int i = 0;808try {809for (; i < r.length; i++) {810Assert.assertEquals(r[i], (double)(a[i+offs]));811}812} catch (AssertionError e) {813Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);814}815}816817818static long bits(long e) {819return e;820}821822static final List<IntFunction<long[]>> LONG_GENERATORS = List.of(823withToString("long[-i * 5]", (int s) -> {824return fill(s * BUFFER_REPS,825i -> (long)(-i * 5));826}),827withToString("long[i * 5]", (int s) -> {828return fill(s * BUFFER_REPS,829i -> (long)(i * 5));830}),831withToString("long[i + 1]", (int s) -> {832return fill(s * BUFFER_REPS,833i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1)));834}),835withToString("long[cornerCaseValue(i)]", (int s) -> {836return fill(s * BUFFER_REPS,837i -> cornerCaseValue(i));838})839);840841// Create combinations of pairs842// @@@ Might be sensitive to order e.g. div by 0843static final List<List<IntFunction<long[]>>> LONG_GENERATOR_PAIRS =844Stream.of(LONG_GENERATORS.get(0)).845flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).846collect(Collectors.toList());847848@DataProvider849public Object[][] boolUnaryOpProvider() {850return BOOL_ARRAY_GENERATORS.stream().851map(f -> new Object[]{f}).852toArray(Object[][]::new);853}854855static final List<List<IntFunction<long[]>>> LONG_GENERATOR_TRIPLES =856LONG_GENERATOR_PAIRS.stream().857flatMap(pair -> LONG_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).858collect(Collectors.toList());859860@DataProvider861public Object[][] longBinaryOpProvider() {862return LONG_GENERATOR_PAIRS.stream().map(List::toArray).863toArray(Object[][]::new);864}865866@DataProvider867public Object[][] longIndexedOpProvider() {868return LONG_GENERATOR_PAIRS.stream().map(List::toArray).869toArray(Object[][]::new);870}871872@DataProvider873public Object[][] longBinaryOpMaskProvider() {874return BOOLEAN_MASK_GENERATORS.stream().875flatMap(fm -> LONG_GENERATOR_PAIRS.stream().map(lfa -> {876return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();877})).878toArray(Object[][]::new);879}880881@DataProvider882public Object[][] longTernaryOpProvider() {883return LONG_GENERATOR_TRIPLES.stream().map(List::toArray).884toArray(Object[][]::new);885}886887@DataProvider888public Object[][] longTernaryOpMaskProvider() {889return BOOLEAN_MASK_GENERATORS.stream().890flatMap(fm -> LONG_GENERATOR_TRIPLES.stream().map(lfa -> {891return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();892})).893toArray(Object[][]::new);894}895896@DataProvider897public Object[][] longUnaryOpProvider() {898return LONG_GENERATORS.stream().899map(f -> new Object[]{f}).900toArray(Object[][]::new);901}902903@DataProvider904public Object[][] longUnaryOpMaskProvider() {905return BOOLEAN_MASK_GENERATORS.stream().906flatMap(fm -> LONG_GENERATORS.stream().map(fa -> {907return new Object[] {fa, fm};908})).909toArray(Object[][]::new);910}911912@DataProvider913public Object[][] longtoIntUnaryOpProvider() {914return INT_LONG_GENERATORS.stream().915map(f -> new Object[]{f}).916toArray(Object[][]::new);917}918919920@DataProvider921public Object[][] maskProvider() {922return BOOLEAN_MASK_GENERATORS.stream().923map(f -> new Object[]{f}).924toArray(Object[][]::new);925}926927@DataProvider928public Object[][] maskCompareOpProvider() {929return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).930toArray(Object[][]::new);931}932933@DataProvider934public Object[][] shuffleProvider() {935return INT_SHUFFLE_GENERATORS.stream().936map(f -> new Object[]{f}).937toArray(Object[][]::new);938}939940@DataProvider941public Object[][] shuffleCompareOpProvider() {942return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).943toArray(Object[][]::new);944}945946@DataProvider947public Object[][] longUnaryOpShuffleProvider() {948return INT_SHUFFLE_GENERATORS.stream().949flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {950return new Object[] {fa, fs};951})).952toArray(Object[][]::new);953}954955@DataProvider956public Object[][] longUnaryOpShuffleMaskProvider() {957return BOOLEAN_MASK_GENERATORS.stream().958flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().959flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {960return new Object[] {fa, fs, fm};961}))).962toArray(Object[][]::new);963}964965static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of(966withToStringBi("shuffle[random]", (Integer l, Integer m) -> {967long[] a = new long[l];968int upper = m;969for (int i = 0; i < 1; i++) {970a[i] = (long)RAND.nextInt(upper);971}972return a;973})974);975976@DataProvider977public Object[][] longUnaryOpSelectFromProvider() {978return LONG_SHUFFLE_GENERATORS.stream().979flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {980return new Object[] {fa, fs};981})).982toArray(Object[][]::new);983}984985@DataProvider986public Object[][] longUnaryOpSelectFromMaskProvider() {987return BOOLEAN_MASK_GENERATORS.stream().988flatMap(fm -> LONG_SHUFFLE_GENERATORS.stream().989flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {990return new Object[] {fa, fs, fm};991}))).992toArray(Object[][]::new);993}994995996@DataProvider997public Object[][] longUnaryOpIndexProvider() {998return INT_INDEX_GENERATORS.stream().999flatMap(fs -> LONG_GENERATORS.stream().map(fa -> {1000return new Object[] {fa, fs};1001})).1002toArray(Object[][]::new);1003}10041005@DataProvider1006public Object[][] longUnaryMaskedOpIndexProvider() {1007return BOOLEAN_MASK_GENERATORS.stream().1008flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->1009LONG_GENERATORS.stream().map(fa -> {1010return new Object[] {fa, fm, fs};1011}))).1012toArray(Object[][]::new);1013}10141015@DataProvider1016public Object[][] scatterMaskedOpIndexProvider() {1017return BOOLEAN_MASK_GENERATORS.stream().1018flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->1019LONG_GENERATORS.stream().flatMap(fn ->1020LONG_GENERATORS.stream().map(fa -> {1021return new Object[] {fa, fn, fm, fs};1022})))).1023toArray(Object[][]::new);1024}10251026static final List<IntFunction<long[]>> LONG_COMPARE_GENERATORS = List.of(1027withToString("long[i]", (int s) -> {1028return fill(s * BUFFER_REPS,1029i -> (long)i);1030}),1031withToString("long[i - length / 2]", (int s) -> {1032return fill(s * BUFFER_REPS,1033i -> (long)(i - (s * BUFFER_REPS / 2)));1034}),1035withToString("long[i + 1]", (int s) -> {1036return fill(s * BUFFER_REPS,1037i -> (long)(i + 1));1038}),1039withToString("long[i - 2]", (int s) -> {1040return fill(s * BUFFER_REPS,1041i -> (long)(i - 2));1042}),1043withToString("long[zigZag(i)]", (int s) -> {1044return fill(s * BUFFER_REPS,1045i -> i%3 == 0 ? (long)i : (i%3 == 1 ? (long)(i + 1) : (long)(i - 2)));1046}),1047withToString("long[cornerCaseValue(i)]", (int s) -> {1048return fill(s * BUFFER_REPS,1049i -> cornerCaseValue(i));1050})1051);10521053static final List<List<IntFunction<long[]>>> LONG_TEST_GENERATOR_ARGS =1054LONG_COMPARE_GENERATORS.stream().1055map(fa -> List.of(fa)).1056collect(Collectors.toList());10571058@DataProvider1059public Object[][] longTestOpProvider() {1060return LONG_TEST_GENERATOR_ARGS.stream().map(List::toArray).1061toArray(Object[][]::new);1062}10631064@DataProvider1065public Object[][] longTestOpMaskProvider() {1066return BOOLEAN_MASK_GENERATORS.stream().1067flatMap(fm -> LONG_TEST_GENERATOR_ARGS.stream().map(lfa -> {1068return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1069})).1070toArray(Object[][]::new);1071}10721073static final List<List<IntFunction<long[]>>> LONG_COMPARE_GENERATOR_PAIRS =1074LONG_COMPARE_GENERATORS.stream().1075flatMap(fa -> LONG_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).1076collect(Collectors.toList());10771078@DataProvider1079public Object[][] longCompareOpProvider() {1080return LONG_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).1081toArray(Object[][]::new);1082}10831084@DataProvider1085public Object[][] longCompareOpMaskProvider() {1086return BOOLEAN_MASK_GENERATORS.stream().1087flatMap(fm -> LONG_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {1088return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1089})).1090toArray(Object[][]::new);1091}10921093interface ToLongF {1094long apply(int i);1095}10961097static long[] fill(int s , ToLongF f) {1098return fill(new long[s], f);1099}11001101static long[] fill(long[] a, ToLongF f) {1102for (int i = 0; i < a.length; i++) {1103a[i] = f.apply(i);1104}1105return a;1106}11071108static long cornerCaseValue(int i) {1109switch(i % 5) {1110case 0:1111return Long.MAX_VALUE;1112case 1:1113return Long.MIN_VALUE;1114case 2:1115return Long.MIN_VALUE;1116case 3:1117return Long.MAX_VALUE;1118default:1119return (long)0;1120}1121}11221123static long get(long[] a, int i) {1124return (long) a[i];1125}11261127static final IntFunction<long[]> fr = (vl) -> {1128int length = BUFFER_REPS * vl;1129return new long[length];1130};11311132static final IntFunction<boolean[]> fmr = (vl) -> {1133int length = BUFFER_REPS * vl;1134return new boolean[length];1135};113611371138static void replaceZero(long[] a, long v) {1139for (int i = 0; i < a.length; i++) {1140if (a[i] == 0) {1141a[i] = v;1142}1143}1144}11451146static void replaceZero(long[] a, boolean[] mask, long v) {1147for (int i = 0; i < a.length; i++) {1148if (mask[i % mask.length] && a[i] == 0) {1149a[i] = v;1150}1151}1152}11531154static boolean eq(long a, long b) {1155return a == b;1156}11571158static boolean neq(long a, long b) {1159return a != b;1160}11611162static boolean lt(long a, long b) {1163return a < b;1164}11651166static boolean le(long a, long b) {1167return a <= b;1168}11691170static boolean gt(long a, long b) {1171return a > b;1172}11731174static boolean ge(long a, long b) {1175return a >= b;1176}11771178static boolean ult(long a, long b) {1179return Long.compareUnsigned(a, b) < 0;1180}11811182static boolean ule(long a, long b) {1183return Long.compareUnsigned(a, b) <= 0;1184}11851186static boolean ugt(long a, long b) {1187return Long.compareUnsigned(a, b) > 0;1188}11891190static boolean uge(long a, long b) {1191return Long.compareUnsigned(a, b) >= 0;1192}11931194@Test1195static void smokeTest1() {1196LongVector three = LongVector.broadcast(SPECIES, (byte)-3);1197LongVector three2 = (LongVector) SPECIES.broadcast(-3);1198assert(three.eq(three2).allTrue());1199LongVector three3 = three2.broadcast(1).broadcast(-3);1200assert(three.eq(three3).allTrue());1201int scale = 2;1202Class<?> ETYPE = long.class;1203if (ETYPE == double.class || ETYPE == long.class)1204scale = 1000000;1205else if (ETYPE == byte.class && SPECIES.length() >= 64)1206scale = 1;1207LongVector higher = three.addIndex(scale);1208VectorMask<Long> m = three.compare(VectorOperators.LE, higher);1209assert(m.allTrue());1210m = higher.min((long)-1).test(VectorOperators.IS_NEGATIVE);1211assert(m.allTrue());1212long max = higher.reduceLanes(VectorOperators.MAX);1213assert(max == -3 + scale * (SPECIES.length()-1));1214}12151216private static long[]1217bothToArray(LongVector a, LongVector b) {1218long[] r = new long[a.length() + b.length()];1219a.intoArray(r, 0);1220b.intoArray(r, a.length());1221return r;1222}12231224@Test1225static void smokeTest2() {1226// Do some zipping and shuffling.1227LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);1228LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();1229Assert.assertEquals(io, io2);1230LongVector a = io.add((long)1); //[1,2]1231LongVector b = a.neg(); //[-1,-2]1232long[] abValues = bothToArray(a,b); //[1,2,-1,-2]1233VectorShuffle<Long> zip0 = VectorShuffle.makeZip(SPECIES, 0);1234VectorShuffle<Long> zip1 = VectorShuffle.makeZip(SPECIES, 1);1235LongVector zab0 = a.rearrange(zip0,b); //[1,-1]1236LongVector zab1 = a.rearrange(zip1,b); //[2,-2]1237long[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]1238// manually zip1239long[] manual = new long[zabValues.length];1240for (int i = 0; i < manual.length; i += 2) {1241manual[i+0] = abValues[i/2];1242manual[i+1] = abValues[a.length() + i/2];1243}1244Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));1245VectorShuffle<Long> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);1246VectorShuffle<Long> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);1247LongVector uab0 = zab0.rearrange(unz0,zab1);1248LongVector uab1 = zab0.rearrange(unz1,zab1);1249long[] abValues1 = bothToArray(uab0, uab1);1250Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));1251}12521253static void iotaShuffle() {1254LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1);1255LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();1256Assert.assertEquals(io, io2);1257}12581259@Test1260// Test all shuffle related operations.1261static void shuffleTest() {1262// To test backend instructions, make sure that C2 is used.1263for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {1264iotaShuffle();1265}1266}12671268@Test1269void viewAsIntegeralLanesTest() {1270Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();1271Assert.assertEquals(asIntegral.species(), SPECIES);1272}12731274@Test1275void viewAsFloatingLanesTest() {1276Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();1277VectorSpecies<?> asFloatingSpecies = asFloating.species();1278Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType());1279Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape());1280Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length());1281Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES);1282}12831284@Test1285// Test div by 0.1286static void bitwiseDivByZeroSmokeTest() {1287try {1288LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);1289LongVector b = (LongVector) SPECIES.broadcast(0);1290a.div(b);1291Assert.fail();1292} catch (ArithmeticException e) {1293}12941295try {1296LongVector a = (LongVector) SPECIES.broadcast(0).addIndex(1);1297LongVector b = (LongVector) SPECIES.broadcast(0);1298VectorMask<Long> m = a.lt((long) 1);1299a.div(b, m);1300Assert.fail();1301} catch (ArithmeticException e) {1302}1303}1304static long ADD(long a, long b) {1305return (long)(a + b);1306}13071308@Test(dataProvider = "longBinaryOpProvider")1309static void ADDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1310long[] a = fa.apply(SPECIES.length());1311long[] b = fb.apply(SPECIES.length());1312long[] r = fr.apply(SPECIES.length());13131314for (int ic = 0; ic < INVOC_COUNT; ic++) {1315for (int i = 0; i < a.length; i += SPECIES.length()) {1316LongVector av = LongVector.fromArray(SPECIES, a, i);1317LongVector bv = LongVector.fromArray(SPECIES, b, i);1318av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);1319}1320}13211322assertArraysEquals(r, a, b, Long256VectorTests::ADD);1323}1324static long add(long a, long b) {1325return (long)(a + b);1326}13271328@Test(dataProvider = "longBinaryOpProvider")1329static void addLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1330long[] a = fa.apply(SPECIES.length());1331long[] b = fb.apply(SPECIES.length());1332long[] r = fr.apply(SPECIES.length());13331334for (int i = 0; i < a.length; i += SPECIES.length()) {1335LongVector av = LongVector.fromArray(SPECIES, a, i);1336LongVector bv = LongVector.fromArray(SPECIES, b, i);1337av.add(bv).intoArray(r, i);1338}13391340assertArraysEquals(r, a, b, Long256VectorTests::add);1341}13421343@Test(dataProvider = "longBinaryOpMaskProvider")1344static void ADDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1345IntFunction<boolean[]> fm) {1346long[] a = fa.apply(SPECIES.length());1347long[] b = fb.apply(SPECIES.length());1348long[] r = fr.apply(SPECIES.length());1349boolean[] mask = fm.apply(SPECIES.length());1350VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);13511352for (int ic = 0; ic < INVOC_COUNT; ic++) {1353for (int i = 0; i < a.length; i += SPECIES.length()) {1354LongVector av = LongVector.fromArray(SPECIES, a, i);1355LongVector bv = LongVector.fromArray(SPECIES, b, i);1356av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);1357}1358}13591360assertArraysEquals(r, a, b, mask, Long256VectorTests::ADD);1361}13621363@Test(dataProvider = "longBinaryOpMaskProvider")1364static void addLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1365IntFunction<boolean[]> fm) {1366long[] a = fa.apply(SPECIES.length());1367long[] b = fb.apply(SPECIES.length());1368long[] r = fr.apply(SPECIES.length());1369boolean[] mask = fm.apply(SPECIES.length());1370VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);13711372for (int i = 0; i < a.length; i += SPECIES.length()) {1373LongVector av = LongVector.fromArray(SPECIES, a, i);1374LongVector bv = LongVector.fromArray(SPECIES, b, i);1375av.add(bv, vmask).intoArray(r, i);1376}13771378assertArraysEquals(r, a, b, mask, Long256VectorTests::add);1379}1380static long SUB(long a, long b) {1381return (long)(a - b);1382}13831384@Test(dataProvider = "longBinaryOpProvider")1385static void SUBLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1386long[] a = fa.apply(SPECIES.length());1387long[] b = fb.apply(SPECIES.length());1388long[] r = fr.apply(SPECIES.length());13891390for (int ic = 0; ic < INVOC_COUNT; ic++) {1391for (int i = 0; i < a.length; i += SPECIES.length()) {1392LongVector av = LongVector.fromArray(SPECIES, a, i);1393LongVector bv = LongVector.fromArray(SPECIES, b, i);1394av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);1395}1396}13971398assertArraysEquals(r, a, b, Long256VectorTests::SUB);1399}1400static long sub(long a, long b) {1401return (long)(a - b);1402}14031404@Test(dataProvider = "longBinaryOpProvider")1405static void subLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1406long[] a = fa.apply(SPECIES.length());1407long[] b = fb.apply(SPECIES.length());1408long[] r = fr.apply(SPECIES.length());14091410for (int i = 0; i < a.length; i += SPECIES.length()) {1411LongVector av = LongVector.fromArray(SPECIES, a, i);1412LongVector bv = LongVector.fromArray(SPECIES, b, i);1413av.sub(bv).intoArray(r, i);1414}14151416assertArraysEquals(r, a, b, Long256VectorTests::sub);1417}14181419@Test(dataProvider = "longBinaryOpMaskProvider")1420static void SUBLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1421IntFunction<boolean[]> fm) {1422long[] a = fa.apply(SPECIES.length());1423long[] b = fb.apply(SPECIES.length());1424long[] r = fr.apply(SPECIES.length());1425boolean[] mask = fm.apply(SPECIES.length());1426VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);14271428for (int ic = 0; ic < INVOC_COUNT; ic++) {1429for (int i = 0; i < a.length; i += SPECIES.length()) {1430LongVector av = LongVector.fromArray(SPECIES, a, i);1431LongVector bv = LongVector.fromArray(SPECIES, b, i);1432av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);1433}1434}14351436assertArraysEquals(r, a, b, mask, Long256VectorTests::SUB);1437}14381439@Test(dataProvider = "longBinaryOpMaskProvider")1440static void subLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1441IntFunction<boolean[]> fm) {1442long[] a = fa.apply(SPECIES.length());1443long[] b = fb.apply(SPECIES.length());1444long[] r = fr.apply(SPECIES.length());1445boolean[] mask = fm.apply(SPECIES.length());1446VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);14471448for (int i = 0; i < a.length; i += SPECIES.length()) {1449LongVector av = LongVector.fromArray(SPECIES, a, i);1450LongVector bv = LongVector.fromArray(SPECIES, b, i);1451av.sub(bv, vmask).intoArray(r, i);1452}14531454assertArraysEquals(r, a, b, mask, Long256VectorTests::sub);1455}1456static long MUL(long a, long b) {1457return (long)(a * b);1458}14591460@Test(dataProvider = "longBinaryOpProvider")1461static void MULLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1462long[] a = fa.apply(SPECIES.length());1463long[] b = fb.apply(SPECIES.length());1464long[] r = fr.apply(SPECIES.length());14651466for (int ic = 0; ic < INVOC_COUNT; ic++) {1467for (int i = 0; i < a.length; i += SPECIES.length()) {1468LongVector av = LongVector.fromArray(SPECIES, a, i);1469LongVector bv = LongVector.fromArray(SPECIES, b, i);1470av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);1471}1472}14731474assertArraysEquals(r, a, b, Long256VectorTests::MUL);1475}1476static long mul(long a, long b) {1477return (long)(a * b);1478}14791480@Test(dataProvider = "longBinaryOpProvider")1481static void mulLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1482long[] a = fa.apply(SPECIES.length());1483long[] b = fb.apply(SPECIES.length());1484long[] r = fr.apply(SPECIES.length());14851486for (int i = 0; i < a.length; i += SPECIES.length()) {1487LongVector av = LongVector.fromArray(SPECIES, a, i);1488LongVector bv = LongVector.fromArray(SPECIES, b, i);1489av.mul(bv).intoArray(r, i);1490}14911492assertArraysEquals(r, a, b, Long256VectorTests::mul);1493}14941495@Test(dataProvider = "longBinaryOpMaskProvider")1496static void MULLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1497IntFunction<boolean[]> fm) {1498long[] a = fa.apply(SPECIES.length());1499long[] b = fb.apply(SPECIES.length());1500long[] r = fr.apply(SPECIES.length());1501boolean[] mask = fm.apply(SPECIES.length());1502VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);15031504for (int ic = 0; ic < INVOC_COUNT; ic++) {1505for (int i = 0; i < a.length; i += SPECIES.length()) {1506LongVector av = LongVector.fromArray(SPECIES, a, i);1507LongVector bv = LongVector.fromArray(SPECIES, b, i);1508av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);1509}1510}15111512assertArraysEquals(r, a, b, mask, Long256VectorTests::MUL);1513}15141515@Test(dataProvider = "longBinaryOpMaskProvider")1516static void mulLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1517IntFunction<boolean[]> fm) {1518long[] a = fa.apply(SPECIES.length());1519long[] b = fb.apply(SPECIES.length());1520long[] r = fr.apply(SPECIES.length());1521boolean[] mask = fm.apply(SPECIES.length());1522VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);15231524for (int i = 0; i < a.length; i += SPECIES.length()) {1525LongVector av = LongVector.fromArray(SPECIES, a, i);1526LongVector bv = LongVector.fromArray(SPECIES, b, i);1527av.mul(bv, vmask).intoArray(r, i);1528}15291530assertArraysEquals(r, a, b, mask, Long256VectorTests::mul);1531}1532153315341535static long DIV(long a, long b) {1536return (long)(a / b);1537}15381539@Test(dataProvider = "longBinaryOpProvider")1540static void DIVLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1541long[] a = fa.apply(SPECIES.length());1542long[] b = fb.apply(SPECIES.length());1543long[] r = fr.apply(SPECIES.length());15441545replaceZero(b, (long) 1);15461547for (int ic = 0; ic < INVOC_COUNT; ic++) {1548for (int i = 0; i < a.length; i += SPECIES.length()) {1549LongVector av = LongVector.fromArray(SPECIES, a, i);1550LongVector bv = LongVector.fromArray(SPECIES, b, i);1551av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);1552}1553}15541555assertArraysEquals(r, a, b, Long256VectorTests::DIV);1556}1557static long div(long a, long b) {1558return (long)(a / b);1559}15601561@Test(dataProvider = "longBinaryOpProvider")1562static void divLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1563long[] a = fa.apply(SPECIES.length());1564long[] b = fb.apply(SPECIES.length());1565long[] r = fr.apply(SPECIES.length());15661567replaceZero(b, (long) 1);15681569for (int ic = 0; ic < INVOC_COUNT; ic++) {1570for (int i = 0; i < a.length; i += SPECIES.length()) {1571LongVector av = LongVector.fromArray(SPECIES, a, i);1572LongVector bv = LongVector.fromArray(SPECIES, b, i);1573av.div(bv).intoArray(r, i);1574}1575}15761577assertArraysEquals(r, a, b, Long256VectorTests::div);1578}1579158015811582@Test(dataProvider = "longBinaryOpMaskProvider")1583static void DIVLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1584IntFunction<boolean[]> fm) {1585long[] a = fa.apply(SPECIES.length());1586long[] b = fb.apply(SPECIES.length());1587long[] r = fr.apply(SPECIES.length());1588boolean[] mask = fm.apply(SPECIES.length());1589VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);15901591replaceZero(b, mask, (long) 1);15921593for (int ic = 0; ic < INVOC_COUNT; ic++) {1594for (int i = 0; i < a.length; i += SPECIES.length()) {1595LongVector av = LongVector.fromArray(SPECIES, a, i);1596LongVector bv = LongVector.fromArray(SPECIES, b, i);1597av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);1598}1599}16001601assertArraysEquals(r, a, b, mask, Long256VectorTests::DIV);1602}16031604@Test(dataProvider = "longBinaryOpMaskProvider")1605static void divLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1606IntFunction<boolean[]> fm) {1607long[] a = fa.apply(SPECIES.length());1608long[] b = fb.apply(SPECIES.length());1609long[] r = fr.apply(SPECIES.length());1610boolean[] mask = fm.apply(SPECIES.length());1611VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);16121613replaceZero(b, mask, (long) 1);16141615for (int ic = 0; ic < INVOC_COUNT; ic++) {1616for (int i = 0; i < a.length; i += SPECIES.length()) {1617LongVector av = LongVector.fromArray(SPECIES, a, i);1618LongVector bv = LongVector.fromArray(SPECIES, b, i);1619av.div(bv, vmask).intoArray(r, i);1620}1621}16221623assertArraysEquals(r, a, b, mask, Long256VectorTests::div);1624}16251626static long FIRST_NONZERO(long a, long b) {1627return (long)((a)!=0?a:b);1628}16291630@Test(dataProvider = "longBinaryOpProvider")1631static void FIRST_NONZEROLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1632long[] a = fa.apply(SPECIES.length());1633long[] b = fb.apply(SPECIES.length());1634long[] r = fr.apply(SPECIES.length());16351636for (int ic = 0; ic < INVOC_COUNT; ic++) {1637for (int i = 0; i < a.length; i += SPECIES.length()) {1638LongVector av = LongVector.fromArray(SPECIES, a, i);1639LongVector bv = LongVector.fromArray(SPECIES, b, i);1640av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);1641}1642}16431644assertArraysEquals(r, a, b, Long256VectorTests::FIRST_NONZERO);1645}16461647@Test(dataProvider = "longBinaryOpMaskProvider")1648static void FIRST_NONZEROLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1649IntFunction<boolean[]> fm) {1650long[] a = fa.apply(SPECIES.length());1651long[] b = fb.apply(SPECIES.length());1652long[] r = fr.apply(SPECIES.length());1653boolean[] mask = fm.apply(SPECIES.length());1654VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);16551656for (int ic = 0; ic < INVOC_COUNT; ic++) {1657for (int i = 0; i < a.length; i += SPECIES.length()) {1658LongVector av = LongVector.fromArray(SPECIES, a, i);1659LongVector bv = LongVector.fromArray(SPECIES, b, i);1660av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);1661}1662}16631664assertArraysEquals(r, a, b, mask, Long256VectorTests::FIRST_NONZERO);1665}16661667static long AND(long a, long b) {1668return (long)(a & b);1669}16701671@Test(dataProvider = "longBinaryOpProvider")1672static void ANDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1673long[] a = fa.apply(SPECIES.length());1674long[] b = fb.apply(SPECIES.length());1675long[] r = fr.apply(SPECIES.length());16761677for (int ic = 0; ic < INVOC_COUNT; ic++) {1678for (int i = 0; i < a.length; i += SPECIES.length()) {1679LongVector av = LongVector.fromArray(SPECIES, a, i);1680LongVector bv = LongVector.fromArray(SPECIES, b, i);1681av.lanewise(VectorOperators.AND, bv).intoArray(r, i);1682}1683}16841685assertArraysEquals(r, a, b, Long256VectorTests::AND);1686}1687static long and(long a, long b) {1688return (long)(a & b);1689}16901691@Test(dataProvider = "longBinaryOpProvider")1692static void andLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1693long[] a = fa.apply(SPECIES.length());1694long[] b = fb.apply(SPECIES.length());1695long[] r = fr.apply(SPECIES.length());16961697for (int i = 0; i < a.length; i += SPECIES.length()) {1698LongVector av = LongVector.fromArray(SPECIES, a, i);1699LongVector bv = LongVector.fromArray(SPECIES, b, i);1700av.and(bv).intoArray(r, i);1701}17021703assertArraysEquals(r, a, b, Long256VectorTests::and);1704}1705170617071708@Test(dataProvider = "longBinaryOpMaskProvider")1709static void ANDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1710IntFunction<boolean[]> fm) {1711long[] a = fa.apply(SPECIES.length());1712long[] b = fb.apply(SPECIES.length());1713long[] r = fr.apply(SPECIES.length());1714boolean[] mask = fm.apply(SPECIES.length());1715VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);17161717for (int ic = 0; ic < INVOC_COUNT; ic++) {1718for (int i = 0; i < a.length; i += SPECIES.length()) {1719LongVector av = LongVector.fromArray(SPECIES, a, i);1720LongVector bv = LongVector.fromArray(SPECIES, b, i);1721av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);1722}1723}17241725assertArraysEquals(r, a, b, mask, Long256VectorTests::AND);1726}172717281729static long AND_NOT(long a, long b) {1730return (long)(a & ~b);1731}17321733@Test(dataProvider = "longBinaryOpProvider")1734static void AND_NOTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1735long[] a = fa.apply(SPECIES.length());1736long[] b = fb.apply(SPECIES.length());1737long[] r = fr.apply(SPECIES.length());17381739for (int ic = 0; ic < INVOC_COUNT; ic++) {1740for (int i = 0; i < a.length; i += SPECIES.length()) {1741LongVector av = LongVector.fromArray(SPECIES, a, i);1742LongVector bv = LongVector.fromArray(SPECIES, b, i);1743av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);1744}1745}17461747assertArraysEquals(r, a, b, Long256VectorTests::AND_NOT);1748}1749175017511752@Test(dataProvider = "longBinaryOpMaskProvider")1753static void AND_NOTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1754IntFunction<boolean[]> fm) {1755long[] a = fa.apply(SPECIES.length());1756long[] b = fb.apply(SPECIES.length());1757long[] r = fr.apply(SPECIES.length());1758boolean[] mask = fm.apply(SPECIES.length());1759VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);17601761for (int ic = 0; ic < INVOC_COUNT; ic++) {1762for (int i = 0; i < a.length; i += SPECIES.length()) {1763LongVector av = LongVector.fromArray(SPECIES, a, i);1764LongVector bv = LongVector.fromArray(SPECIES, b, i);1765av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);1766}1767}17681769assertArraysEquals(r, a, b, mask, Long256VectorTests::AND_NOT);1770}177117721773static long OR(long a, long b) {1774return (long)(a | b);1775}17761777@Test(dataProvider = "longBinaryOpProvider")1778static void ORLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1779long[] a = fa.apply(SPECIES.length());1780long[] b = fb.apply(SPECIES.length());1781long[] r = fr.apply(SPECIES.length());17821783for (int ic = 0; ic < INVOC_COUNT; ic++) {1784for (int i = 0; i < a.length; i += SPECIES.length()) {1785LongVector av = LongVector.fromArray(SPECIES, a, i);1786LongVector bv = LongVector.fromArray(SPECIES, b, i);1787av.lanewise(VectorOperators.OR, bv).intoArray(r, i);1788}1789}17901791assertArraysEquals(r, a, b, Long256VectorTests::OR);1792}1793static long or(long a, long b) {1794return (long)(a | b);1795}17961797@Test(dataProvider = "longBinaryOpProvider")1798static void orLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1799long[] a = fa.apply(SPECIES.length());1800long[] b = fb.apply(SPECIES.length());1801long[] r = fr.apply(SPECIES.length());18021803for (int i = 0; i < a.length; i += SPECIES.length()) {1804LongVector av = LongVector.fromArray(SPECIES, a, i);1805LongVector bv = LongVector.fromArray(SPECIES, b, i);1806av.or(bv).intoArray(r, i);1807}18081809assertArraysEquals(r, a, b, Long256VectorTests::or);1810}1811181218131814@Test(dataProvider = "longBinaryOpMaskProvider")1815static void ORLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1816IntFunction<boolean[]> fm) {1817long[] a = fa.apply(SPECIES.length());1818long[] b = fb.apply(SPECIES.length());1819long[] r = fr.apply(SPECIES.length());1820boolean[] mask = fm.apply(SPECIES.length());1821VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);18221823for (int ic = 0; ic < INVOC_COUNT; ic++) {1824for (int i = 0; i < a.length; i += SPECIES.length()) {1825LongVector av = LongVector.fromArray(SPECIES, a, i);1826LongVector bv = LongVector.fromArray(SPECIES, b, i);1827av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);1828}1829}18301831assertArraysEquals(r, a, b, mask, Long256VectorTests::OR);1832}183318341835static long XOR(long a, long b) {1836return (long)(a ^ b);1837}18381839@Test(dataProvider = "longBinaryOpProvider")1840static void XORLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {1841long[] a = fa.apply(SPECIES.length());1842long[] b = fb.apply(SPECIES.length());1843long[] r = fr.apply(SPECIES.length());18441845for (int ic = 0; ic < INVOC_COUNT; ic++) {1846for (int i = 0; i < a.length; i += SPECIES.length()) {1847LongVector av = LongVector.fromArray(SPECIES, a, i);1848LongVector bv = LongVector.fromArray(SPECIES, b, i);1849av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);1850}1851}18521853assertArraysEquals(r, a, b, Long256VectorTests::XOR);1854}1855185618571858@Test(dataProvider = "longBinaryOpMaskProvider")1859static void XORLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,1860IntFunction<boolean[]> fm) {1861long[] a = fa.apply(SPECIES.length());1862long[] b = fb.apply(SPECIES.length());1863long[] r = fr.apply(SPECIES.length());1864boolean[] mask = fm.apply(SPECIES.length());1865VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);18661867for (int ic = 0; ic < INVOC_COUNT; ic++) {1868for (int i = 0; i < a.length; i += SPECIES.length()) {1869LongVector av = LongVector.fromArray(SPECIES, a, i);1870LongVector bv = LongVector.fromArray(SPECIES, b, i);1871av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);1872}1873}18741875assertArraysEquals(r, a, b, mask, Long256VectorTests::XOR);1876}187718781879@Test(dataProvider = "longBinaryOpProvider")1880static void addLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {1881long[] a = fa.apply(SPECIES.length());1882long[] b = fb.apply(SPECIES.length());1883long[] r = fr.apply(SPECIES.length());18841885for (int i = 0; i < a.length; i += SPECIES.length()) {1886LongVector av = LongVector.fromArray(SPECIES, a, i);1887av.add(b[i]).intoArray(r, i);1888}18891890assertBroadcastArraysEquals(r, a, b, Long256VectorTests::add);1891}18921893@Test(dataProvider = "longBinaryOpMaskProvider")1894static void addLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,1895IntFunction<boolean[]> fm) {1896long[] a = fa.apply(SPECIES.length());1897long[] b = fb.apply(SPECIES.length());1898long[] r = fr.apply(SPECIES.length());1899boolean[] mask = fm.apply(SPECIES.length());1900VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);19011902for (int i = 0; i < a.length; i += SPECIES.length()) {1903LongVector av = LongVector.fromArray(SPECIES, a, i);1904av.add(b[i], vmask).intoArray(r, i);1905}19061907assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::add);1908}19091910@Test(dataProvider = "longBinaryOpProvider")1911static void subLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {1912long[] a = fa.apply(SPECIES.length());1913long[] b = fb.apply(SPECIES.length());1914long[] r = fr.apply(SPECIES.length());19151916for (int i = 0; i < a.length; i += SPECIES.length()) {1917LongVector av = LongVector.fromArray(SPECIES, a, i);1918av.sub(b[i]).intoArray(r, i);1919}19201921assertBroadcastArraysEquals(r, a, b, Long256VectorTests::sub);1922}19231924@Test(dataProvider = "longBinaryOpMaskProvider")1925static void subLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,1926IntFunction<boolean[]> fm) {1927long[] a = fa.apply(SPECIES.length());1928long[] b = fb.apply(SPECIES.length());1929long[] r = fr.apply(SPECIES.length());1930boolean[] mask = fm.apply(SPECIES.length());1931VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);19321933for (int i = 0; i < a.length; i += SPECIES.length()) {1934LongVector av = LongVector.fromArray(SPECIES, a, i);1935av.sub(b[i], vmask).intoArray(r, i);1936}19371938assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::sub);1939}19401941@Test(dataProvider = "longBinaryOpProvider")1942static void mulLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {1943long[] a = fa.apply(SPECIES.length());1944long[] b = fb.apply(SPECIES.length());1945long[] r = fr.apply(SPECIES.length());19461947for (int i = 0; i < a.length; i += SPECIES.length()) {1948LongVector av = LongVector.fromArray(SPECIES, a, i);1949av.mul(b[i]).intoArray(r, i);1950}19511952assertBroadcastArraysEquals(r, a, b, Long256VectorTests::mul);1953}19541955@Test(dataProvider = "longBinaryOpMaskProvider")1956static void mulLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,1957IntFunction<boolean[]> fm) {1958long[] a = fa.apply(SPECIES.length());1959long[] b = fb.apply(SPECIES.length());1960long[] r = fr.apply(SPECIES.length());1961boolean[] mask = fm.apply(SPECIES.length());1962VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);19631964for (int i = 0; i < a.length; i += SPECIES.length()) {1965LongVector av = LongVector.fromArray(SPECIES, a, i);1966av.mul(b[i], vmask).intoArray(r, i);1967}19681969assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::mul);1970}19711972197319741975@Test(dataProvider = "longBinaryOpProvider")1976static void divLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {1977long[] a = fa.apply(SPECIES.length());1978long[] b = fb.apply(SPECIES.length());1979long[] r = fr.apply(SPECIES.length());19801981replaceZero(b, (long) 1);19821983for (int i = 0; i < a.length; i += SPECIES.length()) {1984LongVector av = LongVector.fromArray(SPECIES, a, i);1985av.div(b[i]).intoArray(r, i);1986}19871988assertBroadcastArraysEquals(r, a, b, Long256VectorTests::div);1989}1990199119921993@Test(dataProvider = "longBinaryOpMaskProvider")1994static void divLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,1995IntFunction<boolean[]> fm) {1996long[] a = fa.apply(SPECIES.length());1997long[] b = fb.apply(SPECIES.length());1998long[] r = fr.apply(SPECIES.length());1999boolean[] mask = fm.apply(SPECIES.length());2000VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);20012002replaceZero(b, (long) 1);20032004for (int i = 0; i < a.length; i += SPECIES.length()) {2005LongVector av = LongVector.fromArray(SPECIES, a, i);2006av.div(b[i], vmask).intoArray(r, i);2007}20082009assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::div);2010}2011201220132014@Test(dataProvider = "longBinaryOpProvider")2015static void ORLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2016long[] a = fa.apply(SPECIES.length());2017long[] b = fb.apply(SPECIES.length());2018long[] r = fr.apply(SPECIES.length());20192020for (int i = 0; i < a.length; i += SPECIES.length()) {2021LongVector av = LongVector.fromArray(SPECIES, a, i);2022av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);2023}20242025assertBroadcastArraysEquals(r, a, b, Long256VectorTests::OR);2026}20272028@Test(dataProvider = "longBinaryOpProvider")2029static void orLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2030long[] a = fa.apply(SPECIES.length());2031long[] b = fb.apply(SPECIES.length());2032long[] r = fr.apply(SPECIES.length());20332034for (int i = 0; i < a.length; i += SPECIES.length()) {2035LongVector av = LongVector.fromArray(SPECIES, a, i);2036av.or(b[i]).intoArray(r, i);2037}20382039assertBroadcastArraysEquals(r, a, b, Long256VectorTests::or);2040}2041204220432044@Test(dataProvider = "longBinaryOpMaskProvider")2045static void ORLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,2046IntFunction<boolean[]> fm) {2047long[] a = fa.apply(SPECIES.length());2048long[] b = fb.apply(SPECIES.length());2049long[] r = fr.apply(SPECIES.length());2050boolean[] mask = fm.apply(SPECIES.length());2051VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);20522053for (int i = 0; i < a.length; i += SPECIES.length()) {2054LongVector av = LongVector.fromArray(SPECIES, a, i);2055av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);2056}20572058assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::OR);2059}2060206120622063@Test(dataProvider = "longBinaryOpProvider")2064static void ANDLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2065long[] a = fa.apply(SPECIES.length());2066long[] b = fb.apply(SPECIES.length());2067long[] r = fr.apply(SPECIES.length());20682069for (int i = 0; i < a.length; i += SPECIES.length()) {2070LongVector av = LongVector.fromArray(SPECIES, a, i);2071av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);2072}20732074assertBroadcastArraysEquals(r, a, b, Long256VectorTests::AND);2075}20762077@Test(dataProvider = "longBinaryOpProvider")2078static void andLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2079long[] a = fa.apply(SPECIES.length());2080long[] b = fb.apply(SPECIES.length());2081long[] r = fr.apply(SPECIES.length());20822083for (int i = 0; i < a.length; i += SPECIES.length()) {2084LongVector av = LongVector.fromArray(SPECIES, a, i);2085av.and(b[i]).intoArray(r, i);2086}20872088assertBroadcastArraysEquals(r, a, b, Long256VectorTests::and);2089}2090209120922093@Test(dataProvider = "longBinaryOpMaskProvider")2094static void ANDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,2095IntFunction<boolean[]> fm) {2096long[] a = fa.apply(SPECIES.length());2097long[] b = fb.apply(SPECIES.length());2098long[] r = fr.apply(SPECIES.length());2099boolean[] mask = fm.apply(SPECIES.length());2100VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);21012102for (int i = 0; i < a.length; i += SPECIES.length()) {2103LongVector av = LongVector.fromArray(SPECIES, a, i);2104av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);2105}21062107assertBroadcastArraysEquals(r, a, b, mask, Long256VectorTests::AND);2108}2109211021112112@Test(dataProvider = "longBinaryOpProvider")2113static void ORLong256VectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2114long[] a = fa.apply(SPECIES.length());2115long[] b = fb.apply(SPECIES.length());2116long[] r = fr.apply(SPECIES.length());21172118for (int i = 0; i < a.length; i += SPECIES.length()) {2119LongVector av = LongVector.fromArray(SPECIES, a, i);2120av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);2121}21222123assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::OR);2124}2125212621272128@Test(dataProvider = "longBinaryOpMaskProvider")2129static void ORLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,2130IntFunction<boolean[]> fm) {2131long[] a = fa.apply(SPECIES.length());2132long[] b = fb.apply(SPECIES.length());2133long[] r = fr.apply(SPECIES.length());2134boolean[] mask = fm.apply(SPECIES.length());2135VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);21362137for (int i = 0; i < a.length; i += SPECIES.length()) {2138LongVector av = LongVector.fromArray(SPECIES, a, i);2139av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);2140}21412142assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::OR);2143}214421452146@Test(dataProvider = "longBinaryOpProvider")2147static void ADDLong256VectorTestsBroadcastLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2148long[] a = fa.apply(SPECIES.length());2149long[] b = fb.apply(SPECIES.length());2150long[] r = fr.apply(SPECIES.length());21512152for (int i = 0; i < a.length; i += SPECIES.length()) {2153LongVector av = LongVector.fromArray(SPECIES, a, i);2154av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);2155}21562157assertBroadcastLongArraysEquals(r, a, b, Long256VectorTests::ADD);2158}21592160@Test(dataProvider = "longBinaryOpMaskProvider")2161static void ADDLong256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,2162IntFunction<boolean[]> fm) {2163long[] a = fa.apply(SPECIES.length());2164long[] b = fb.apply(SPECIES.length());2165long[] r = fr.apply(SPECIES.length());2166boolean[] mask = fm.apply(SPECIES.length());2167VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);21682169for (int i = 0; i < a.length; i += SPECIES.length()) {2170LongVector av = LongVector.fromArray(SPECIES, a, i);2171av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);2172}21732174assertBroadcastLongArraysEquals(r, a, b, mask, Long256VectorTests::ADD);2175}21762177static long LSHL(long a, long b) {2178return (long)((a << b));2179}21802181@Test(dataProvider = "longBinaryOpProvider")2182static void LSHLLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2183long[] a = fa.apply(SPECIES.length());2184long[] b = fb.apply(SPECIES.length());2185long[] r = fr.apply(SPECIES.length());21862187for (int ic = 0; ic < INVOC_COUNT; ic++) {2188for (int i = 0; i < a.length; i += SPECIES.length()) {2189LongVector av = LongVector.fromArray(SPECIES, a, i);2190LongVector bv = LongVector.fromArray(SPECIES, b, i);2191av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);2192}2193}21942195assertArraysEquals(r, a, b, Long256VectorTests::LSHL);2196}2197219821992200@Test(dataProvider = "longBinaryOpMaskProvider")2201static void LSHLLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,2202IntFunction<boolean[]> fm) {2203long[] a = fa.apply(SPECIES.length());2204long[] b = fb.apply(SPECIES.length());2205long[] r = fr.apply(SPECIES.length());2206boolean[] mask = fm.apply(SPECIES.length());2207VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);22082209for (int ic = 0; ic < INVOC_COUNT; ic++) {2210for (int i = 0; i < a.length; i += SPECIES.length()) {2211LongVector av = LongVector.fromArray(SPECIES, a, i);2212LongVector bv = LongVector.fromArray(SPECIES, b, i);2213av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);2214}2215}22162217assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHL);2218}2219222022212222222322242225static long ASHR(long a, long b) {2226return (long)((a >> b));2227}22282229@Test(dataProvider = "longBinaryOpProvider")2230static void ASHRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2231long[] a = fa.apply(SPECIES.length());2232long[] b = fb.apply(SPECIES.length());2233long[] r = fr.apply(SPECIES.length());22342235for (int ic = 0; ic < INVOC_COUNT; ic++) {2236for (int i = 0; i < a.length; i += SPECIES.length()) {2237LongVector av = LongVector.fromArray(SPECIES, a, i);2238LongVector bv = LongVector.fromArray(SPECIES, b, i);2239av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);2240}2241}22422243assertArraysEquals(r, a, b, Long256VectorTests::ASHR);2244}2245224622472248@Test(dataProvider = "longBinaryOpMaskProvider")2249static void ASHRLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,2250IntFunction<boolean[]> fm) {2251long[] a = fa.apply(SPECIES.length());2252long[] b = fb.apply(SPECIES.length());2253long[] r = fr.apply(SPECIES.length());2254boolean[] mask = fm.apply(SPECIES.length());2255VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);22562257for (int ic = 0; ic < INVOC_COUNT; ic++) {2258for (int i = 0; i < a.length; i += SPECIES.length()) {2259LongVector av = LongVector.fromArray(SPECIES, a, i);2260LongVector bv = LongVector.fromArray(SPECIES, b, i);2261av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);2262}2263}22642265assertArraysEquals(r, a, b, mask, Long256VectorTests::ASHR);2266}2267226822692270227122722273static long LSHR(long a, long b) {2274return (long)((a >>> b));2275}22762277@Test(dataProvider = "longBinaryOpProvider")2278static void LSHRLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2279long[] a = fa.apply(SPECIES.length());2280long[] b = fb.apply(SPECIES.length());2281long[] r = fr.apply(SPECIES.length());22822283for (int ic = 0; ic < INVOC_COUNT; ic++) {2284for (int i = 0; i < a.length; i += SPECIES.length()) {2285LongVector av = LongVector.fromArray(SPECIES, a, i);2286LongVector bv = LongVector.fromArray(SPECIES, b, i);2287av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);2288}2289}22902291assertArraysEquals(r, a, b, Long256VectorTests::LSHR);2292}2293229422952296@Test(dataProvider = "longBinaryOpMaskProvider")2297static void LSHRLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,2298IntFunction<boolean[]> fm) {2299long[] a = fa.apply(SPECIES.length());2300long[] b = fb.apply(SPECIES.length());2301long[] r = fr.apply(SPECIES.length());2302boolean[] mask = fm.apply(SPECIES.length());2303VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);23042305for (int ic = 0; ic < INVOC_COUNT; ic++) {2306for (int i = 0; i < a.length; i += SPECIES.length()) {2307LongVector av = LongVector.fromArray(SPECIES, a, i);2308LongVector bv = LongVector.fromArray(SPECIES, b, i);2309av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);2310}2311}23122313assertArraysEquals(r, a, b, mask, Long256VectorTests::LSHR);2314}2315231623172318231923202321static long LSHL_unary(long a, long b) {2322return (long)((a << b));2323}23242325@Test(dataProvider = "longBinaryOpProvider")2326static void LSHLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {2327long[] a = fa.apply(SPECIES.length());2328long[] b = fb.apply(SPECIES.length());2329long[] r = fr.apply(SPECIES.length());23302331for (int ic = 0; ic < INVOC_COUNT; ic++) {2332for (int i = 0; i < a.length; i += SPECIES.length()) {2333LongVector av = LongVector.fromArray(SPECIES, a, i);2334av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);2335}2336}23372338assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHL_unary);2339}2340234123422343@Test(dataProvider = "longBinaryOpMaskProvider")2344static void LSHLLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,2345IntFunction<boolean[]> fm) {2346long[] a = fa.apply(SPECIES.length());2347long[] b = fb.apply(SPECIES.length());2348long[] r = fr.apply(SPECIES.length());2349boolean[] mask = fm.apply(SPECIES.length());2350VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);23512352for (int ic = 0; ic < INVOC_COUNT; ic++) {2353for (int i = 0; i < a.length; i += SPECIES.length()) {2354LongVector av = LongVector.fromArray(SPECIES, a, i);2355av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);2356}2357}23582359assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHL_unary);2360}2361236223632364236523662367static long LSHR_unary(long a, long b) {2368return (long)((a >>> b));2369}23702371@Test(dataProvider = "longBinaryOpProvider")2372static void LSHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {2373long[] a = fa.apply(SPECIES.length());2374long[] b = fb.apply(SPECIES.length());2375long[] r = fr.apply(SPECIES.length());23762377for (int ic = 0; ic < INVOC_COUNT; ic++) {2378for (int i = 0; i < a.length; i += SPECIES.length()) {2379LongVector av = LongVector.fromArray(SPECIES, a, i);2380av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);2381}2382}23832384assertShiftArraysEquals(r, a, b, Long256VectorTests::LSHR_unary);2385}2386238723882389@Test(dataProvider = "longBinaryOpMaskProvider")2390static void LSHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,2391IntFunction<boolean[]> fm) {2392long[] a = fa.apply(SPECIES.length());2393long[] b = fb.apply(SPECIES.length());2394long[] r = fr.apply(SPECIES.length());2395boolean[] mask = fm.apply(SPECIES.length());2396VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);23972398for (int ic = 0; ic < INVOC_COUNT; ic++) {2399for (int i = 0; i < a.length; i += SPECIES.length()) {2400LongVector av = LongVector.fromArray(SPECIES, a, i);2401av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);2402}2403}24042405assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::LSHR_unary);2406}2407240824092410241124122413static long ASHR_unary(long a, long b) {2414return (long)((a >> b));2415}24162417@Test(dataProvider = "longBinaryOpProvider")2418static void ASHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb) {2419long[] a = fa.apply(SPECIES.length());2420long[] b = fb.apply(SPECIES.length());2421long[] r = fr.apply(SPECIES.length());24222423for (int ic = 0; ic < INVOC_COUNT; ic++) {2424for (int i = 0; i < a.length; i += SPECIES.length()) {2425LongVector av = LongVector.fromArray(SPECIES, a, i);2426av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);2427}2428}24292430assertShiftArraysEquals(r, a, b, Long256VectorTests::ASHR_unary);2431}2432243324342435@Test(dataProvider = "longBinaryOpMaskProvider")2436static void ASHRLong256VectorTestsShift(IntFunction<long[]> fa, IntFunction<long[]> fb,2437IntFunction<boolean[]> fm) {2438long[] a = fa.apply(SPECIES.length());2439long[] b = fb.apply(SPECIES.length());2440long[] r = fr.apply(SPECIES.length());2441boolean[] mask = fm.apply(SPECIES.length());2442VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);24432444for (int ic = 0; ic < INVOC_COUNT; ic++) {2445for (int i = 0; i < a.length; i += SPECIES.length()) {2446LongVector av = LongVector.fromArray(SPECIES, a, i);2447av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);2448}2449}24502451assertShiftArraysEquals(r, a, b, mask, Long256VectorTests::ASHR_unary);2452}245324542455245624572458static long MIN(long a, long b) {2459return (long)(Math.min(a, b));2460}24612462@Test(dataProvider = "longBinaryOpProvider")2463static void MINLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2464long[] a = fa.apply(SPECIES.length());2465long[] b = fb.apply(SPECIES.length());2466long[] r = fr.apply(SPECIES.length());24672468for (int ic = 0; ic < INVOC_COUNT; ic++) {2469for (int i = 0; i < a.length; i += SPECIES.length()) {2470LongVector av = LongVector.fromArray(SPECIES, a, i);2471LongVector bv = LongVector.fromArray(SPECIES, b, i);2472av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);2473}2474}24752476assertArraysEquals(r, a, b, Long256VectorTests::MIN);2477}2478static long min(long a, long b) {2479return (long)(Math.min(a, b));2480}24812482@Test(dataProvider = "longBinaryOpProvider")2483static void minLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2484long[] a = fa.apply(SPECIES.length());2485long[] b = fb.apply(SPECIES.length());2486long[] r = fr.apply(SPECIES.length());24872488for (int i = 0; i < a.length; i += SPECIES.length()) {2489LongVector av = LongVector.fromArray(SPECIES, a, i);2490LongVector bv = LongVector.fromArray(SPECIES, b, i);2491av.min(bv).intoArray(r, i);2492}24932494assertArraysEquals(r, a, b, Long256VectorTests::min);2495}2496static long MAX(long a, long b) {2497return (long)(Math.max(a, b));2498}24992500@Test(dataProvider = "longBinaryOpProvider")2501static void MAXLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2502long[] a = fa.apply(SPECIES.length());2503long[] b = fb.apply(SPECIES.length());2504long[] r = fr.apply(SPECIES.length());25052506for (int ic = 0; ic < INVOC_COUNT; ic++) {2507for (int i = 0; i < a.length; i += SPECIES.length()) {2508LongVector av = LongVector.fromArray(SPECIES, a, i);2509LongVector bv = LongVector.fromArray(SPECIES, b, i);2510av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);2511}2512}25132514assertArraysEquals(r, a, b, Long256VectorTests::MAX);2515}2516static long max(long a, long b) {2517return (long)(Math.max(a, b));2518}25192520@Test(dataProvider = "longBinaryOpProvider")2521static void maxLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {2522long[] a = fa.apply(SPECIES.length());2523long[] b = fb.apply(SPECIES.length());2524long[] r = fr.apply(SPECIES.length());25252526for (int i = 0; i < a.length; i += SPECIES.length()) {2527LongVector av = LongVector.fromArray(SPECIES, a, i);2528LongVector bv = LongVector.fromArray(SPECIES, b, i);2529av.max(bv).intoArray(r, i);2530}25312532assertArraysEquals(r, a, b, Long256VectorTests::max);2533}25342535@Test(dataProvider = "longBinaryOpProvider")2536static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2537long[] a = fa.apply(SPECIES.length());2538long[] b = fb.apply(SPECIES.length());2539long[] r = fr.apply(SPECIES.length());25402541for (int i = 0; i < a.length; i += SPECIES.length()) {2542LongVector av = LongVector.fromArray(SPECIES, a, i);2543av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);2544}25452546assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MIN);2547}25482549@Test(dataProvider = "longBinaryOpProvider")2550static void minLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2551long[] a = fa.apply(SPECIES.length());2552long[] b = fb.apply(SPECIES.length());2553long[] r = fr.apply(SPECIES.length());25542555for (int i = 0; i < a.length; i += SPECIES.length()) {2556LongVector av = LongVector.fromArray(SPECIES, a, i);2557av.min(b[i]).intoArray(r, i);2558}25592560assertBroadcastArraysEquals(r, a, b, Long256VectorTests::min);2561}25622563@Test(dataProvider = "longBinaryOpProvider")2564static void MAXLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2565long[] a = fa.apply(SPECIES.length());2566long[] b = fb.apply(SPECIES.length());2567long[] r = fr.apply(SPECIES.length());25682569for (int i = 0; i < a.length; i += SPECIES.length()) {2570LongVector av = LongVector.fromArray(SPECIES, a, i);2571av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);2572}25732574assertBroadcastArraysEquals(r, a, b, Long256VectorTests::MAX);2575}25762577@Test(dataProvider = "longBinaryOpProvider")2578static void maxLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {2579long[] a = fa.apply(SPECIES.length());2580long[] b = fb.apply(SPECIES.length());2581long[] r = fr.apply(SPECIES.length());25822583for (int i = 0; i < a.length; i += SPECIES.length()) {2584LongVector av = LongVector.fromArray(SPECIES, a, i);2585av.max(b[i]).intoArray(r, i);2586}25872588assertBroadcastArraysEquals(r, a, b, Long256VectorTests::max);2589}25902591static long ANDReduce(long[] a, int idx) {2592long res = -1;2593for (int i = idx; i < (idx + SPECIES.length()); i++) {2594res &= a[i];2595}25962597return res;2598}25992600static long ANDReduceAll(long[] a) {2601long res = -1;2602for (int i = 0; i < a.length; i += SPECIES.length()) {2603res &= ANDReduce(a, i);2604}26052606return res;2607}260826092610@Test(dataProvider = "longUnaryOpProvider")2611static void ANDReduceLong256VectorTests(IntFunction<long[]> fa) {2612long[] a = fa.apply(SPECIES.length());2613long[] r = fr.apply(SPECIES.length());2614long ra = -1;26152616for (int ic = 0; ic < INVOC_COUNT; ic++) {2617for (int i = 0; i < a.length; i += SPECIES.length()) {2618LongVector av = LongVector.fromArray(SPECIES, a, i);2619r[i] = av.reduceLanes(VectorOperators.AND);2620}2621}26222623for (int ic = 0; ic < INVOC_COUNT; ic++) {2624ra = -1;2625for (int i = 0; i < a.length; i += SPECIES.length()) {2626LongVector av = LongVector.fromArray(SPECIES, a, i);2627ra &= av.reduceLanes(VectorOperators.AND);2628}2629}26302631assertReductionArraysEquals(r, ra, a,2632Long256VectorTests::ANDReduce, Long256VectorTests::ANDReduceAll);2633}263426352636static long ANDReduceMasked(long[] a, int idx, boolean[] mask) {2637long res = -1;2638for (int i = idx; i < (idx + SPECIES.length()); i++) {2639if (mask[i % SPECIES.length()])2640res &= a[i];2641}26422643return res;2644}26452646static long ANDReduceAllMasked(long[] a, boolean[] mask) {2647long res = -1;2648for (int i = 0; i < a.length; i += SPECIES.length()) {2649res &= ANDReduceMasked(a, i, mask);2650}26512652return res;2653}265426552656@Test(dataProvider = "longUnaryOpMaskProvider")2657static void ANDReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {2658long[] a = fa.apply(SPECIES.length());2659long[] r = fr.apply(SPECIES.length());2660boolean[] mask = fm.apply(SPECIES.length());2661VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);2662long ra = -1;26632664for (int ic = 0; ic < INVOC_COUNT; ic++) {2665for (int i = 0; i < a.length; i += SPECIES.length()) {2666LongVector av = LongVector.fromArray(SPECIES, a, i);2667r[i] = av.reduceLanes(VectorOperators.AND, vmask);2668}2669}26702671for (int ic = 0; ic < INVOC_COUNT; ic++) {2672ra = -1;2673for (int i = 0; i < a.length; i += SPECIES.length()) {2674LongVector av = LongVector.fromArray(SPECIES, a, i);2675ra &= av.reduceLanes(VectorOperators.AND, vmask);2676}2677}26782679assertReductionArraysEqualsMasked(r, ra, a, mask,2680Long256VectorTests::ANDReduceMasked, Long256VectorTests::ANDReduceAllMasked);2681}268226832684static long ORReduce(long[] a, int idx) {2685long res = 0;2686for (int i = idx; i < (idx + SPECIES.length()); i++) {2687res |= a[i];2688}26892690return res;2691}26922693static long ORReduceAll(long[] a) {2694long res = 0;2695for (int i = 0; i < a.length; i += SPECIES.length()) {2696res |= ORReduce(a, i);2697}26982699return res;2700}270127022703@Test(dataProvider = "longUnaryOpProvider")2704static void ORReduceLong256VectorTests(IntFunction<long[]> fa) {2705long[] a = fa.apply(SPECIES.length());2706long[] r = fr.apply(SPECIES.length());2707long ra = 0;27082709for (int ic = 0; ic < INVOC_COUNT; ic++) {2710for (int i = 0; i < a.length; i += SPECIES.length()) {2711LongVector av = LongVector.fromArray(SPECIES, a, i);2712r[i] = av.reduceLanes(VectorOperators.OR);2713}2714}27152716for (int ic = 0; ic < INVOC_COUNT; ic++) {2717ra = 0;2718for (int i = 0; i < a.length; i += SPECIES.length()) {2719LongVector av = LongVector.fromArray(SPECIES, a, i);2720ra |= av.reduceLanes(VectorOperators.OR);2721}2722}27232724assertReductionArraysEquals(r, ra, a,2725Long256VectorTests::ORReduce, Long256VectorTests::ORReduceAll);2726}272727282729static long ORReduceMasked(long[] a, int idx, boolean[] mask) {2730long res = 0;2731for (int i = idx; i < (idx + SPECIES.length()); i++) {2732if (mask[i % SPECIES.length()])2733res |= a[i];2734}27352736return res;2737}27382739static long ORReduceAllMasked(long[] a, boolean[] mask) {2740long res = 0;2741for (int i = 0; i < a.length; i += SPECIES.length()) {2742res |= ORReduceMasked(a, i, mask);2743}27442745return res;2746}274727482749@Test(dataProvider = "longUnaryOpMaskProvider")2750static void ORReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {2751long[] a = fa.apply(SPECIES.length());2752long[] r = fr.apply(SPECIES.length());2753boolean[] mask = fm.apply(SPECIES.length());2754VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);2755long ra = 0;27562757for (int ic = 0; ic < INVOC_COUNT; ic++) {2758for (int i = 0; i < a.length; i += SPECIES.length()) {2759LongVector av = LongVector.fromArray(SPECIES, a, i);2760r[i] = av.reduceLanes(VectorOperators.OR, vmask);2761}2762}27632764for (int ic = 0; ic < INVOC_COUNT; ic++) {2765ra = 0;2766for (int i = 0; i < a.length; i += SPECIES.length()) {2767LongVector av = LongVector.fromArray(SPECIES, a, i);2768ra |= av.reduceLanes(VectorOperators.OR, vmask);2769}2770}27712772assertReductionArraysEqualsMasked(r, ra, a, mask,2773Long256VectorTests::ORReduceMasked, Long256VectorTests::ORReduceAllMasked);2774}277527762777static long XORReduce(long[] a, int idx) {2778long res = 0;2779for (int i = idx; i < (idx + SPECIES.length()); i++) {2780res ^= a[i];2781}27822783return res;2784}27852786static long XORReduceAll(long[] a) {2787long res = 0;2788for (int i = 0; i < a.length; i += SPECIES.length()) {2789res ^= XORReduce(a, i);2790}27912792return res;2793}279427952796@Test(dataProvider = "longUnaryOpProvider")2797static void XORReduceLong256VectorTests(IntFunction<long[]> fa) {2798long[] a = fa.apply(SPECIES.length());2799long[] r = fr.apply(SPECIES.length());2800long ra = 0;28012802for (int ic = 0; ic < INVOC_COUNT; ic++) {2803for (int i = 0; i < a.length; i += SPECIES.length()) {2804LongVector av = LongVector.fromArray(SPECIES, a, i);2805r[i] = av.reduceLanes(VectorOperators.XOR);2806}2807}28082809for (int ic = 0; ic < INVOC_COUNT; ic++) {2810ra = 0;2811for (int i = 0; i < a.length; i += SPECIES.length()) {2812LongVector av = LongVector.fromArray(SPECIES, a, i);2813ra ^= av.reduceLanes(VectorOperators.XOR);2814}2815}28162817assertReductionArraysEquals(r, ra, a,2818Long256VectorTests::XORReduce, Long256VectorTests::XORReduceAll);2819}282028212822static long XORReduceMasked(long[] a, int idx, boolean[] mask) {2823long res = 0;2824for (int i = idx; i < (idx + SPECIES.length()); i++) {2825if (mask[i % SPECIES.length()])2826res ^= a[i];2827}28282829return res;2830}28312832static long XORReduceAllMasked(long[] a, boolean[] mask) {2833long res = 0;2834for (int i = 0; i < a.length; i += SPECIES.length()) {2835res ^= XORReduceMasked(a, i, mask);2836}28372838return res;2839}284028412842@Test(dataProvider = "longUnaryOpMaskProvider")2843static void XORReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {2844long[] a = fa.apply(SPECIES.length());2845long[] r = fr.apply(SPECIES.length());2846boolean[] mask = fm.apply(SPECIES.length());2847VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);2848long ra = 0;28492850for (int ic = 0; ic < INVOC_COUNT; ic++) {2851for (int i = 0; i < a.length; i += SPECIES.length()) {2852LongVector av = LongVector.fromArray(SPECIES, a, i);2853r[i] = av.reduceLanes(VectorOperators.XOR, vmask);2854}2855}28562857for (int ic = 0; ic < INVOC_COUNT; ic++) {2858ra = 0;2859for (int i = 0; i < a.length; i += SPECIES.length()) {2860LongVector av = LongVector.fromArray(SPECIES, a, i);2861ra ^= av.reduceLanes(VectorOperators.XOR, vmask);2862}2863}28642865assertReductionArraysEqualsMasked(r, ra, a, mask,2866Long256VectorTests::XORReduceMasked, Long256VectorTests::XORReduceAllMasked);2867}28682869static long ADDReduce(long[] a, int idx) {2870long res = 0;2871for (int i = idx; i < (idx + SPECIES.length()); i++) {2872res += a[i];2873}28742875return res;2876}28772878static long ADDReduceAll(long[] a) {2879long res = 0;2880for (int i = 0; i < a.length; i += SPECIES.length()) {2881res += ADDReduce(a, i);2882}28832884return res;2885}2886@Test(dataProvider = "longUnaryOpProvider")2887static void ADDReduceLong256VectorTests(IntFunction<long[]> fa) {2888long[] a = fa.apply(SPECIES.length());2889long[] r = fr.apply(SPECIES.length());2890long ra = 0;28912892for (int ic = 0; ic < INVOC_COUNT; ic++) {2893for (int i = 0; i < a.length; i += SPECIES.length()) {2894LongVector av = LongVector.fromArray(SPECIES, a, i);2895r[i] = av.reduceLanes(VectorOperators.ADD);2896}2897}28982899for (int ic = 0; ic < INVOC_COUNT; ic++) {2900ra = 0;2901for (int i = 0; i < a.length; i += SPECIES.length()) {2902LongVector av = LongVector.fromArray(SPECIES, a, i);2903ra += av.reduceLanes(VectorOperators.ADD);2904}2905}29062907assertReductionArraysEquals(r, ra, a,2908Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll);2909}2910static long ADDReduceMasked(long[] a, int idx, boolean[] mask) {2911long res = 0;2912for (int i = idx; i < (idx + SPECIES.length()); i++) {2913if (mask[i % SPECIES.length()])2914res += a[i];2915}29162917return res;2918}29192920static long ADDReduceAllMasked(long[] a, boolean[] mask) {2921long res = 0;2922for (int i = 0; i < a.length; i += SPECIES.length()) {2923res += ADDReduceMasked(a, i, mask);2924}29252926return res;2927}2928@Test(dataProvider = "longUnaryOpMaskProvider")2929static void ADDReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {2930long[] a = fa.apply(SPECIES.length());2931long[] r = fr.apply(SPECIES.length());2932boolean[] mask = fm.apply(SPECIES.length());2933VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);2934long ra = 0;29352936for (int ic = 0; ic < INVOC_COUNT; ic++) {2937for (int i = 0; i < a.length; i += SPECIES.length()) {2938LongVector av = LongVector.fromArray(SPECIES, a, i);2939r[i] = av.reduceLanes(VectorOperators.ADD, vmask);2940}2941}29422943for (int ic = 0; ic < INVOC_COUNT; ic++) {2944ra = 0;2945for (int i = 0; i < a.length; i += SPECIES.length()) {2946LongVector av = LongVector.fromArray(SPECIES, a, i);2947ra += av.reduceLanes(VectorOperators.ADD, vmask);2948}2949}29502951assertReductionArraysEqualsMasked(r, ra, a, mask,2952Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked);2953}2954static long MULReduce(long[] a, int idx) {2955long res = 1;2956for (int i = idx; i < (idx + SPECIES.length()); i++) {2957res *= a[i];2958}29592960return res;2961}29622963static long MULReduceAll(long[] a) {2964long res = 1;2965for (int i = 0; i < a.length; i += SPECIES.length()) {2966res *= MULReduce(a, i);2967}29682969return res;2970}2971@Test(dataProvider = "longUnaryOpProvider")2972static void MULReduceLong256VectorTests(IntFunction<long[]> fa) {2973long[] a = fa.apply(SPECIES.length());2974long[] r = fr.apply(SPECIES.length());2975long ra = 1;29762977for (int ic = 0; ic < INVOC_COUNT; ic++) {2978for (int i = 0; i < a.length; i += SPECIES.length()) {2979LongVector av = LongVector.fromArray(SPECIES, a, i);2980r[i] = av.reduceLanes(VectorOperators.MUL);2981}2982}29832984for (int ic = 0; ic < INVOC_COUNT; ic++) {2985ra = 1;2986for (int i = 0; i < a.length; i += SPECIES.length()) {2987LongVector av = LongVector.fromArray(SPECIES, a, i);2988ra *= av.reduceLanes(VectorOperators.MUL);2989}2990}29912992assertReductionArraysEquals(r, ra, a,2993Long256VectorTests::MULReduce, Long256VectorTests::MULReduceAll);2994}2995static long MULReduceMasked(long[] a, int idx, boolean[] mask) {2996long res = 1;2997for (int i = idx; i < (idx + SPECIES.length()); i++) {2998if (mask[i % SPECIES.length()])2999res *= a[i];3000}30013002return res;3003}30043005static long MULReduceAllMasked(long[] a, boolean[] mask) {3006long res = 1;3007for (int i = 0; i < a.length; i += SPECIES.length()) {3008res *= MULReduceMasked(a, i, mask);3009}30103011return res;3012}3013@Test(dataProvider = "longUnaryOpMaskProvider")3014static void MULReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {3015long[] a = fa.apply(SPECIES.length());3016long[] r = fr.apply(SPECIES.length());3017boolean[] mask = fm.apply(SPECIES.length());3018VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);3019long ra = 1;30203021for (int ic = 0; ic < INVOC_COUNT; ic++) {3022for (int i = 0; i < a.length; i += SPECIES.length()) {3023LongVector av = LongVector.fromArray(SPECIES, a, i);3024r[i] = av.reduceLanes(VectorOperators.MUL, vmask);3025}3026}30273028for (int ic = 0; ic < INVOC_COUNT; ic++) {3029ra = 1;3030for (int i = 0; i < a.length; i += SPECIES.length()) {3031LongVector av = LongVector.fromArray(SPECIES, a, i);3032ra *= av.reduceLanes(VectorOperators.MUL, vmask);3033}3034}30353036assertReductionArraysEqualsMasked(r, ra, a, mask,3037Long256VectorTests::MULReduceMasked, Long256VectorTests::MULReduceAllMasked);3038}3039static long MINReduce(long[] a, int idx) {3040long res = Long.MAX_VALUE;3041for (int i = idx; i < (idx + SPECIES.length()); i++) {3042res = (long)Math.min(res, a[i]);3043}30443045return res;3046}30473048static long MINReduceAll(long[] a) {3049long res = Long.MAX_VALUE;3050for (int i = 0; i < a.length; i++) {3051res = (long)Math.min(res, a[i]);3052}30533054return res;3055}3056@Test(dataProvider = "longUnaryOpProvider")3057static void MINReduceLong256VectorTests(IntFunction<long[]> fa) {3058long[] a = fa.apply(SPECIES.length());3059long[] r = fr.apply(SPECIES.length());3060long ra = Long.MAX_VALUE;30613062for (int ic = 0; ic < INVOC_COUNT; ic++) {3063for (int i = 0; i < a.length; i += SPECIES.length()) {3064LongVector av = LongVector.fromArray(SPECIES, a, i);3065r[i] = av.reduceLanes(VectorOperators.MIN);3066}3067}30683069for (int ic = 0; ic < INVOC_COUNT; ic++) {3070ra = Long.MAX_VALUE;3071for (int i = 0; i < a.length; i += SPECIES.length()) {3072LongVector av = LongVector.fromArray(SPECIES, a, i);3073ra = (long)Math.min(ra, av.reduceLanes(VectorOperators.MIN));3074}3075}30763077assertReductionArraysEquals(r, ra, a,3078Long256VectorTests::MINReduce, Long256VectorTests::MINReduceAll);3079}3080static long MINReduceMasked(long[] a, int idx, boolean[] mask) {3081long res = Long.MAX_VALUE;3082for (int i = idx; i < (idx + SPECIES.length()); i++) {3083if(mask[i % SPECIES.length()])3084res = (long)Math.min(res, a[i]);3085}30863087return res;3088}30893090static long MINReduceAllMasked(long[] a, boolean[] mask) {3091long res = Long.MAX_VALUE;3092for (int i = 0; i < a.length; i++) {3093if(mask[i % SPECIES.length()])3094res = (long)Math.min(res, a[i]);3095}30963097return res;3098}3099@Test(dataProvider = "longUnaryOpMaskProvider")3100static void MINReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {3101long[] a = fa.apply(SPECIES.length());3102long[] r = fr.apply(SPECIES.length());3103boolean[] mask = fm.apply(SPECIES.length());3104VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);3105long ra = Long.MAX_VALUE;31063107for (int ic = 0; ic < INVOC_COUNT; ic++) {3108for (int i = 0; i < a.length; i += SPECIES.length()) {3109LongVector av = LongVector.fromArray(SPECIES, a, i);3110r[i] = av.reduceLanes(VectorOperators.MIN, vmask);3111}3112}31133114for (int ic = 0; ic < INVOC_COUNT; ic++) {3115ra = Long.MAX_VALUE;3116for (int i = 0; i < a.length; i += SPECIES.length()) {3117LongVector av = LongVector.fromArray(SPECIES, a, i);3118ra = (long)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));3119}3120}31213122assertReductionArraysEqualsMasked(r, ra, a, mask,3123Long256VectorTests::MINReduceMasked, Long256VectorTests::MINReduceAllMasked);3124}3125static long MAXReduce(long[] a, int idx) {3126long res = Long.MIN_VALUE;3127for (int i = idx; i < (idx + SPECIES.length()); i++) {3128res = (long)Math.max(res, a[i]);3129}31303131return res;3132}31333134static long MAXReduceAll(long[] a) {3135long res = Long.MIN_VALUE;3136for (int i = 0; i < a.length; i++) {3137res = (long)Math.max(res, a[i]);3138}31393140return res;3141}3142@Test(dataProvider = "longUnaryOpProvider")3143static void MAXReduceLong256VectorTests(IntFunction<long[]> fa) {3144long[] a = fa.apply(SPECIES.length());3145long[] r = fr.apply(SPECIES.length());3146long ra = Long.MIN_VALUE;31473148for (int ic = 0; ic < INVOC_COUNT; ic++) {3149for (int i = 0; i < a.length; i += SPECIES.length()) {3150LongVector av = LongVector.fromArray(SPECIES, a, i);3151r[i] = av.reduceLanes(VectorOperators.MAX);3152}3153}31543155for (int ic = 0; ic < INVOC_COUNT; ic++) {3156ra = Long.MIN_VALUE;3157for (int i = 0; i < a.length; i += SPECIES.length()) {3158LongVector av = LongVector.fromArray(SPECIES, a, i);3159ra = (long)Math.max(ra, av.reduceLanes(VectorOperators.MAX));3160}3161}31623163assertReductionArraysEquals(r, ra, a,3164Long256VectorTests::MAXReduce, Long256VectorTests::MAXReduceAll);3165}3166static long MAXReduceMasked(long[] a, int idx, boolean[] mask) {3167long res = Long.MIN_VALUE;3168for (int i = idx; i < (idx + SPECIES.length()); i++) {3169if(mask[i % SPECIES.length()])3170res = (long)Math.max(res, a[i]);3171}31723173return res;3174}31753176static long MAXReduceAllMasked(long[] a, boolean[] mask) {3177long res = Long.MIN_VALUE;3178for (int i = 0; i < a.length; i++) {3179if(mask[i % SPECIES.length()])3180res = (long)Math.max(res, a[i]);3181}31823183return res;3184}3185@Test(dataProvider = "longUnaryOpMaskProvider")3186static void MAXReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {3187long[] a = fa.apply(SPECIES.length());3188long[] r = fr.apply(SPECIES.length());3189boolean[] mask = fm.apply(SPECIES.length());3190VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);3191long ra = Long.MIN_VALUE;31923193for (int ic = 0; ic < INVOC_COUNT; ic++) {3194for (int i = 0; i < a.length; i += SPECIES.length()) {3195LongVector av = LongVector.fromArray(SPECIES, a, i);3196r[i] = av.reduceLanes(VectorOperators.MAX, vmask);3197}3198}31993200for (int ic = 0; ic < INVOC_COUNT; ic++) {3201ra = Long.MIN_VALUE;3202for (int i = 0; i < a.length; i += SPECIES.length()) {3203LongVector av = LongVector.fromArray(SPECIES, a, i);3204ra = (long)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));3205}3206}32073208assertReductionArraysEqualsMasked(r, ra, a, mask,3209Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked);3210}32113212static boolean anyTrue(boolean[] a, int idx) {3213boolean res = false;3214for (int i = idx; i < (idx + SPECIES.length()); i++) {3215res |= a[i];3216}32173218return res;3219}322032213222@Test(dataProvider = "boolUnaryOpProvider")3223static void anyTrueLong256VectorTests(IntFunction<boolean[]> fm) {3224boolean[] mask = fm.apply(SPECIES.length());3225boolean[] r = fmr.apply(SPECIES.length());32263227for (int ic = 0; ic < INVOC_COUNT; ic++) {3228for (int i = 0; i < mask.length; i += SPECIES.length()) {3229VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);3230r[i] = vmask.anyTrue();3231}3232}32333234assertReductionBoolArraysEquals(r, mask, Long256VectorTests::anyTrue);3235}323632373238static boolean allTrue(boolean[] a, int idx) {3239boolean res = true;3240for (int i = idx; i < (idx + SPECIES.length()); i++) {3241res &= a[i];3242}32433244return res;3245}324632473248@Test(dataProvider = "boolUnaryOpProvider")3249static void allTrueLong256VectorTests(IntFunction<boolean[]> fm) {3250boolean[] mask = fm.apply(SPECIES.length());3251boolean[] r = fmr.apply(SPECIES.length());32523253for (int ic = 0; ic < INVOC_COUNT; ic++) {3254for (int i = 0; i < mask.length; i += SPECIES.length()) {3255VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, i);3256r[i] = vmask.allTrue();3257}3258}32593260assertReductionBoolArraysEquals(r, mask, Long256VectorTests::allTrue);3261}326232633264@Test(dataProvider = "longUnaryOpProvider")3265static void withLong256VectorTests(IntFunction<long []> fa) {3266long[] a = fa.apply(SPECIES.length());3267long[] r = fr.apply(SPECIES.length());32683269for (int ic = 0; ic < INVOC_COUNT; ic++) {3270for (int i = 0; i < a.length; i += SPECIES.length()) {3271LongVector av = LongVector.fromArray(SPECIES, a, i);3272av.withLane(0, (long)4).intoArray(r, i);3273}3274}32753276assertInsertArraysEquals(r, a, (long)4, 0);3277}3278static boolean testIS_DEFAULT(long a) {3279return bits(a)==0;3280}32813282@Test(dataProvider = "longTestOpProvider")3283static void IS_DEFAULTLong256VectorTests(IntFunction<long[]> fa) {3284long[] a = fa.apply(SPECIES.length());32853286for (int ic = 0; ic < INVOC_COUNT; ic++) {3287for (int i = 0; i < a.length; i += SPECIES.length()) {3288LongVector av = LongVector.fromArray(SPECIES, a, i);3289VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT);32903291// Check results as part of computation.3292for (int j = 0; j < SPECIES.length(); j++) {3293Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));3294}3295}3296}3297}32983299@Test(dataProvider = "longTestOpMaskProvider")3300static void IS_DEFAULTMaskedLong256VectorTestsSmokeTest(IntFunction<long[]> fa,3301IntFunction<boolean[]> fm) {3302long[] a = fa.apply(SPECIES.length());3303boolean[] mask = fm.apply(SPECIES.length());3304VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);33053306for (int i = 0; i < a.length; i += SPECIES.length()) {3307LongVector av = LongVector.fromArray(SPECIES, a, i);3308VectorMask<Long> mv = av.test(VectorOperators.IS_DEFAULT, vmask);33093310// Check results as part of computation.3311for (int j = 0; j < SPECIES.length(); j++) {3312Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));3313}3314}3315}3316static boolean testIS_NEGATIVE(long a) {3317return bits(a)<0;3318}33193320@Test(dataProvider = "longTestOpProvider")3321static void IS_NEGATIVELong256VectorTests(IntFunction<long[]> fa) {3322long[] a = fa.apply(SPECIES.length());33233324for (int ic = 0; ic < INVOC_COUNT; ic++) {3325for (int i = 0; i < a.length; i += SPECIES.length()) {3326LongVector av = LongVector.fromArray(SPECIES, a, i);3327VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE);33283329// Check results as part of computation.3330for (int j = 0; j < SPECIES.length(); j++) {3331Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));3332}3333}3334}3335}33363337@Test(dataProvider = "longTestOpMaskProvider")3338static void IS_NEGATIVEMaskedLong256VectorTestsSmokeTest(IntFunction<long[]> fa,3339IntFunction<boolean[]> fm) {3340long[] a = fa.apply(SPECIES.length());3341boolean[] mask = fm.apply(SPECIES.length());3342VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);33433344for (int i = 0; i < a.length; i += SPECIES.length()) {3345LongVector av = LongVector.fromArray(SPECIES, a, i);3346VectorMask<Long> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);33473348// Check results as part of computation.3349for (int j = 0; j < SPECIES.length(); j++) {3350Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));3351}3352}3353}33543355335633573358@Test(dataProvider = "longCompareOpProvider")3359static void LTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3360long[] a = fa.apply(SPECIES.length());3361long[] b = fb.apply(SPECIES.length());33623363for (int ic = 0; ic < INVOC_COUNT; ic++) {3364for (int i = 0; i < a.length; i += SPECIES.length()) {3365LongVector av = LongVector.fromArray(SPECIES, a, i);3366LongVector bv = LongVector.fromArray(SPECIES, b, i);3367VectorMask<Long> mv = av.compare(VectorOperators.LT, bv);33683369// Check results as part of computation.3370for (int j = 0; j < SPECIES.length(); j++) {3371Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));3372}3373}3374}3375}337633773378@Test(dataProvider = "longCompareOpProvider")3379static void ltLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3380long[] a = fa.apply(SPECIES.length());3381long[] b = fb.apply(SPECIES.length());33823383for (int ic = 0; ic < INVOC_COUNT; ic++) {3384for (int i = 0; i < a.length; i += SPECIES.length()) {3385LongVector av = LongVector.fromArray(SPECIES, a, i);3386LongVector bv = LongVector.fromArray(SPECIES, b, i);3387VectorMask<Long> mv = av.lt(bv);33883389// Check results as part of computation.3390for (int j = 0; j < SPECIES.length(); j++) {3391Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));3392}3393}3394}3395}33963397@Test(dataProvider = "longCompareOpMaskProvider")3398static void LTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3399IntFunction<boolean[]> fm) {3400long[] a = fa.apply(SPECIES.length());3401long[] b = fb.apply(SPECIES.length());3402boolean[] mask = fm.apply(SPECIES.length());34033404VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);34053406for (int ic = 0; ic < INVOC_COUNT; ic++) {3407for (int i = 0; i < a.length; i += SPECIES.length()) {3408LongVector av = LongVector.fromArray(SPECIES, a, i);3409LongVector bv = LongVector.fromArray(SPECIES, b, i);3410VectorMask<Long> mv = av.compare(VectorOperators.LT, bv, vmask);34113412// Check results as part of computation.3413for (int j = 0; j < SPECIES.length(); j++) {3414Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));3415}3416}3417}3418}341934203421@Test(dataProvider = "longCompareOpProvider")3422static void GTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3423long[] a = fa.apply(SPECIES.length());3424long[] b = fb.apply(SPECIES.length());34253426for (int ic = 0; ic < INVOC_COUNT; ic++) {3427for (int i = 0; i < a.length; i += SPECIES.length()) {3428LongVector av = LongVector.fromArray(SPECIES, a, i);3429LongVector bv = LongVector.fromArray(SPECIES, b, i);3430VectorMask<Long> mv = av.compare(VectorOperators.GT, bv);34313432// Check results as part of computation.3433for (int j = 0; j < SPECIES.length(); j++) {3434Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));3435}3436}3437}3438}34393440@Test(dataProvider = "longCompareOpMaskProvider")3441static void GTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3442IntFunction<boolean[]> fm) {3443long[] a = fa.apply(SPECIES.length());3444long[] b = fb.apply(SPECIES.length());3445boolean[] mask = fm.apply(SPECIES.length());34463447VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);34483449for (int ic = 0; ic < INVOC_COUNT; ic++) {3450for (int i = 0; i < a.length; i += SPECIES.length()) {3451LongVector av = LongVector.fromArray(SPECIES, a, i);3452LongVector bv = LongVector.fromArray(SPECIES, b, i);3453VectorMask<Long> mv = av.compare(VectorOperators.GT, bv, vmask);34543455// Check results as part of computation.3456for (int j = 0; j < SPECIES.length(); j++) {3457Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));3458}3459}3460}3461}346234633464@Test(dataProvider = "longCompareOpProvider")3465static void EQLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3466long[] a = fa.apply(SPECIES.length());3467long[] b = fb.apply(SPECIES.length());34683469for (int ic = 0; ic < INVOC_COUNT; ic++) {3470for (int i = 0; i < a.length; i += SPECIES.length()) {3471LongVector av = LongVector.fromArray(SPECIES, a, i);3472LongVector bv = LongVector.fromArray(SPECIES, b, i);3473VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv);34743475// Check results as part of computation.3476for (int j = 0; j < SPECIES.length(); j++) {3477Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));3478}3479}3480}3481}348234833484@Test(dataProvider = "longCompareOpProvider")3485static void eqLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3486long[] a = fa.apply(SPECIES.length());3487long[] b = fb.apply(SPECIES.length());34883489for (int ic = 0; ic < INVOC_COUNT; ic++) {3490for (int i = 0; i < a.length; i += SPECIES.length()) {3491LongVector av = LongVector.fromArray(SPECIES, a, i);3492LongVector bv = LongVector.fromArray(SPECIES, b, i);3493VectorMask<Long> mv = av.eq(bv);34943495// Check results as part of computation.3496for (int j = 0; j < SPECIES.length(); j++) {3497Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));3498}3499}3500}3501}35023503@Test(dataProvider = "longCompareOpMaskProvider")3504static void EQLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3505IntFunction<boolean[]> fm) {3506long[] a = fa.apply(SPECIES.length());3507long[] b = fb.apply(SPECIES.length());3508boolean[] mask = fm.apply(SPECIES.length());35093510VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);35113512for (int ic = 0; ic < INVOC_COUNT; ic++) {3513for (int i = 0; i < a.length; i += SPECIES.length()) {3514LongVector av = LongVector.fromArray(SPECIES, a, i);3515LongVector bv = LongVector.fromArray(SPECIES, b, i);3516VectorMask<Long> mv = av.compare(VectorOperators.EQ, bv, vmask);35173518// Check results as part of computation.3519for (int j = 0; j < SPECIES.length(); j++) {3520Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));3521}3522}3523}3524}352535263527@Test(dataProvider = "longCompareOpProvider")3528static void NELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3529long[] a = fa.apply(SPECIES.length());3530long[] b = fb.apply(SPECIES.length());35313532for (int ic = 0; ic < INVOC_COUNT; ic++) {3533for (int i = 0; i < a.length; i += SPECIES.length()) {3534LongVector av = LongVector.fromArray(SPECIES, a, i);3535LongVector bv = LongVector.fromArray(SPECIES, b, i);3536VectorMask<Long> mv = av.compare(VectorOperators.NE, bv);35373538// Check results as part of computation.3539for (int j = 0; j < SPECIES.length(); j++) {3540Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));3541}3542}3543}3544}35453546@Test(dataProvider = "longCompareOpMaskProvider")3547static void NELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3548IntFunction<boolean[]> fm) {3549long[] a = fa.apply(SPECIES.length());3550long[] b = fb.apply(SPECIES.length());3551boolean[] mask = fm.apply(SPECIES.length());35523553VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);35543555for (int ic = 0; ic < INVOC_COUNT; ic++) {3556for (int i = 0; i < a.length; i += SPECIES.length()) {3557LongVector av = LongVector.fromArray(SPECIES, a, i);3558LongVector bv = LongVector.fromArray(SPECIES, b, i);3559VectorMask<Long> mv = av.compare(VectorOperators.NE, bv, vmask);35603561// Check results as part of computation.3562for (int j = 0; j < SPECIES.length(); j++) {3563Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));3564}3565}3566}3567}356835693570@Test(dataProvider = "longCompareOpProvider")3571static void LELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3572long[] a = fa.apply(SPECIES.length());3573long[] b = fb.apply(SPECIES.length());35743575for (int ic = 0; ic < INVOC_COUNT; ic++) {3576for (int i = 0; i < a.length; i += SPECIES.length()) {3577LongVector av = LongVector.fromArray(SPECIES, a, i);3578LongVector bv = LongVector.fromArray(SPECIES, b, i);3579VectorMask<Long> mv = av.compare(VectorOperators.LE, bv);35803581// Check results as part of computation.3582for (int j = 0; j < SPECIES.length(); j++) {3583Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));3584}3585}3586}3587}35883589@Test(dataProvider = "longCompareOpMaskProvider")3590static void LELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3591IntFunction<boolean[]> fm) {3592long[] a = fa.apply(SPECIES.length());3593long[] b = fb.apply(SPECIES.length());3594boolean[] mask = fm.apply(SPECIES.length());35953596VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);35973598for (int ic = 0; ic < INVOC_COUNT; ic++) {3599for (int i = 0; i < a.length; i += SPECIES.length()) {3600LongVector av = LongVector.fromArray(SPECIES, a, i);3601LongVector bv = LongVector.fromArray(SPECIES, b, i);3602VectorMask<Long> mv = av.compare(VectorOperators.LE, bv, vmask);36033604// Check results as part of computation.3605for (int j = 0; j < SPECIES.length(); j++) {3606Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));3607}3608}3609}3610}361136123613@Test(dataProvider = "longCompareOpProvider")3614static void GELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3615long[] a = fa.apply(SPECIES.length());3616long[] b = fb.apply(SPECIES.length());36173618for (int ic = 0; ic < INVOC_COUNT; ic++) {3619for (int i = 0; i < a.length; i += SPECIES.length()) {3620LongVector av = LongVector.fromArray(SPECIES, a, i);3621LongVector bv = LongVector.fromArray(SPECIES, b, i);3622VectorMask<Long> mv = av.compare(VectorOperators.GE, bv);36233624// Check results as part of computation.3625for (int j = 0; j < SPECIES.length(); j++) {3626Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));3627}3628}3629}3630}36313632@Test(dataProvider = "longCompareOpMaskProvider")3633static void GELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3634IntFunction<boolean[]> fm) {3635long[] a = fa.apply(SPECIES.length());3636long[] b = fb.apply(SPECIES.length());3637boolean[] mask = fm.apply(SPECIES.length());36383639VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);36403641for (int ic = 0; ic < INVOC_COUNT; ic++) {3642for (int i = 0; i < a.length; i += SPECIES.length()) {3643LongVector av = LongVector.fromArray(SPECIES, a, i);3644LongVector bv = LongVector.fromArray(SPECIES, b, i);3645VectorMask<Long> mv = av.compare(VectorOperators.GE, bv, vmask);36463647// Check results as part of computation.3648for (int j = 0; j < SPECIES.length(); j++) {3649Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));3650}3651}3652}3653}3654365536563657@Test(dataProvider = "longCompareOpProvider")3658static void UNSIGNED_LTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3659long[] a = fa.apply(SPECIES.length());3660long[] b = fb.apply(SPECIES.length());36613662for (int ic = 0; ic < INVOC_COUNT; ic++) {3663for (int i = 0; i < a.length; i += SPECIES.length()) {3664LongVector av = LongVector.fromArray(SPECIES, a, i);3665LongVector bv = LongVector.fromArray(SPECIES, b, i);3666VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);36673668// Check results as part of computation.3669for (int j = 0; j < SPECIES.length(); j++) {3670Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));3671}3672}3673}3674}3675367636773678@Test(dataProvider = "longCompareOpMaskProvider")3679static void UNSIGNED_LTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3680IntFunction<boolean[]> fm) {3681long[] a = fa.apply(SPECIES.length());3682long[] b = fb.apply(SPECIES.length());3683boolean[] mask = fm.apply(SPECIES.length());36843685VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);36863687for (int ic = 0; ic < INVOC_COUNT; ic++) {3688for (int i = 0; i < a.length; i += SPECIES.length()) {3689LongVector av = LongVector.fromArray(SPECIES, a, i);3690LongVector bv = LongVector.fromArray(SPECIES, b, i);3691VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);36923693// Check results as part of computation.3694for (int j = 0; j < SPECIES.length(); j++) {3695Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));3696}3697}3698}3699}37003701370237033704@Test(dataProvider = "longCompareOpProvider")3705static void UNSIGNED_GTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3706long[] a = fa.apply(SPECIES.length());3707long[] b = fb.apply(SPECIES.length());37083709for (int ic = 0; ic < INVOC_COUNT; ic++) {3710for (int i = 0; i < a.length; i += SPECIES.length()) {3711LongVector av = LongVector.fromArray(SPECIES, a, i);3712LongVector bv = LongVector.fromArray(SPECIES, b, i);3713VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);37143715// Check results as part of computation.3716for (int j = 0; j < SPECIES.length(); j++) {3717Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));3718}3719}3720}3721}3722372337243725@Test(dataProvider = "longCompareOpMaskProvider")3726static void UNSIGNED_GTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3727IntFunction<boolean[]> fm) {3728long[] a = fa.apply(SPECIES.length());3729long[] b = fb.apply(SPECIES.length());3730boolean[] mask = fm.apply(SPECIES.length());37313732VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);37333734for (int ic = 0; ic < INVOC_COUNT; ic++) {3735for (int i = 0; i < a.length; i += SPECIES.length()) {3736LongVector av = LongVector.fromArray(SPECIES, a, i);3737LongVector bv = LongVector.fromArray(SPECIES, b, i);3738VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);37393740// Check results as part of computation.3741for (int j = 0; j < SPECIES.length(); j++) {3742Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));3743}3744}3745}3746}37473748374937503751@Test(dataProvider = "longCompareOpProvider")3752static void UNSIGNED_LELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3753long[] a = fa.apply(SPECIES.length());3754long[] b = fb.apply(SPECIES.length());37553756for (int ic = 0; ic < INVOC_COUNT; ic++) {3757for (int i = 0; i < a.length; i += SPECIES.length()) {3758LongVector av = LongVector.fromArray(SPECIES, a, i);3759LongVector bv = LongVector.fromArray(SPECIES, b, i);3760VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);37613762// Check results as part of computation.3763for (int j = 0; j < SPECIES.length(); j++) {3764Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));3765}3766}3767}3768}3769377037713772@Test(dataProvider = "longCompareOpMaskProvider")3773static void UNSIGNED_LELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3774IntFunction<boolean[]> fm) {3775long[] a = fa.apply(SPECIES.length());3776long[] b = fb.apply(SPECIES.length());3777boolean[] mask = fm.apply(SPECIES.length());37783779VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);37803781for (int ic = 0; ic < INVOC_COUNT; ic++) {3782for (int i = 0; i < a.length; i += SPECIES.length()) {3783LongVector av = LongVector.fromArray(SPECIES, a, i);3784LongVector bv = LongVector.fromArray(SPECIES, b, i);3785VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);37863787// Check results as part of computation.3788for (int j = 0; j < SPECIES.length(); j++) {3789Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));3790}3791}3792}3793}37943795379637973798@Test(dataProvider = "longCompareOpProvider")3799static void UNSIGNED_GELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {3800long[] a = fa.apply(SPECIES.length());3801long[] b = fb.apply(SPECIES.length());38023803for (int ic = 0; ic < INVOC_COUNT; ic++) {3804for (int i = 0; i < a.length; i += SPECIES.length()) {3805LongVector av = LongVector.fromArray(SPECIES, a, i);3806LongVector bv = LongVector.fromArray(SPECIES, b, i);3807VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);38083809// Check results as part of computation.3810for (int j = 0; j < SPECIES.length(); j++) {3811Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));3812}3813}3814}3815}3816381738183819@Test(dataProvider = "longCompareOpMaskProvider")3820static void UNSIGNED_GELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,3821IntFunction<boolean[]> fm) {3822long[] a = fa.apply(SPECIES.length());3823long[] b = fb.apply(SPECIES.length());3824boolean[] mask = fm.apply(SPECIES.length());38253826VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);38273828for (int ic = 0; ic < INVOC_COUNT; ic++) {3829for (int i = 0; i < a.length; i += SPECIES.length()) {3830LongVector av = LongVector.fromArray(SPECIES, a, i);3831LongVector bv = LongVector.fromArray(SPECIES, b, i);3832VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);38333834// Check results as part of computation.3835for (int j = 0; j < SPECIES.length(); j++) {3836Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));3837}3838}3839}3840}3841384238433844@Test(dataProvider = "longCompareOpProvider")3845static void LTLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {3846long[] a = fa.apply(SPECIES.length());3847long[] b = fb.apply(SPECIES.length());38483849for (int i = 0; i < a.length; i += SPECIES.length()) {3850LongVector av = LongVector.fromArray(SPECIES, a, i);3851VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i]);38523853// Check results as part of computation.3854for (int j = 0; j < SPECIES.length(); j++) {3855Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);3856}3857}3858}385938603861@Test(dataProvider = "longCompareOpMaskProvider")3862static void LTLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,3863IntFunction<long[]> fb, IntFunction<boolean[]> fm) {3864long[] a = fa.apply(SPECIES.length());3865long[] b = fb.apply(SPECIES.length());3866boolean[] mask = fm.apply(SPECIES.length());38673868VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);38693870for (int i = 0; i < a.length; i += SPECIES.length()) {3871LongVector av = LongVector.fromArray(SPECIES, a, i);3872VectorMask<Long> mv = av.compare(VectorOperators.LT, b[i], vmask);38733874// Check results as part of computation.3875for (int j = 0; j < SPECIES.length(); j++) {3876Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));3877}3878}3879}388038813882@Test(dataProvider = "longCompareOpProvider")3883static void EQLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {3884long[] a = fa.apply(SPECIES.length());3885long[] b = fb.apply(SPECIES.length());38863887for (int i = 0; i < a.length; i += SPECIES.length()) {3888LongVector av = LongVector.fromArray(SPECIES, a, i);3889VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i]);38903891// Check results as part of computation.3892for (int j = 0; j < SPECIES.length(); j++) {3893Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);3894}3895}3896}389738983899@Test(dataProvider = "longCompareOpMaskProvider")3900static void EQLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa,3901IntFunction<long[]> fb, IntFunction<boolean[]> fm) {3902long[] a = fa.apply(SPECIES.length());3903long[] b = fb.apply(SPECIES.length());3904boolean[] mask = fm.apply(SPECIES.length());39053906VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);39073908for (int i = 0; i < a.length; i += SPECIES.length()) {3909LongVector av = LongVector.fromArray(SPECIES, a, i);3910VectorMask<Long> mv = av.compare(VectorOperators.EQ, b[i], vmask);39113912// Check results as part of computation.3913for (int j = 0; j < SPECIES.length(); j++) {3914Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));3915}3916}3917}391839193920static long blend(long a, long b, boolean mask) {3921return mask ? b : a;3922}39233924@Test(dataProvider = "longBinaryOpMaskProvider")3925static void blendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb,3926IntFunction<boolean[]> fm) {3927long[] a = fa.apply(SPECIES.length());3928long[] b = fb.apply(SPECIES.length());3929long[] r = fr.apply(SPECIES.length());3930boolean[] mask = fm.apply(SPECIES.length());3931VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);39323933for (int ic = 0; ic < INVOC_COUNT; ic++) {3934for (int i = 0; i < a.length; i += SPECIES.length()) {3935LongVector av = LongVector.fromArray(SPECIES, a, i);3936LongVector bv = LongVector.fromArray(SPECIES, b, i);3937av.blend(bv, vmask).intoArray(r, i);3938}3939}39403941assertArraysEquals(r, a, b, mask, Long256VectorTests::blend);3942}39433944@Test(dataProvider = "longUnaryOpShuffleProvider")3945static void RearrangeLong256VectorTests(IntFunction<long[]> fa,3946BiFunction<Integer,Integer,int[]> fs) {3947long[] a = fa.apply(SPECIES.length());3948int[] order = fs.apply(a.length, SPECIES.length());3949long[] r = fr.apply(SPECIES.length());39503951for (int ic = 0; ic < INVOC_COUNT; ic++) {3952for (int i = 0; i < a.length; i += SPECIES.length()) {3953LongVector av = LongVector.fromArray(SPECIES, a, i);3954av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);3955}3956}39573958assertRearrangeArraysEquals(r, a, order, SPECIES.length());3959}39603961@Test(dataProvider = "longUnaryOpShuffleMaskProvider")3962static void RearrangeLong256VectorTestsMaskedSmokeTest(IntFunction<long[]> fa,3963BiFunction<Integer,Integer,int[]> fs,3964IntFunction<boolean[]> fm) {3965long[] a = fa.apply(SPECIES.length());3966int[] order = fs.apply(a.length, SPECIES.length());3967long[] r = fr.apply(SPECIES.length());3968boolean[] mask = fm.apply(SPECIES.length());3969VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);39703971for (int i = 0; i < a.length; i += SPECIES.length()) {3972LongVector av = LongVector.fromArray(SPECIES, a, i);3973av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);3974}39753976assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());3977}3978@Test(dataProvider = "longUnaryOpProvider")3979static void getLong256VectorTests(IntFunction<long[]> fa) {3980long[] a = fa.apply(SPECIES.length());3981long[] r = fr.apply(SPECIES.length());39823983for (int ic = 0; ic < INVOC_COUNT; ic++) {3984for (int i = 0; i < a.length; i += SPECIES.length()) {3985LongVector av = LongVector.fromArray(SPECIES, a, i);3986int num_lanes = SPECIES.length();3987// Manually unroll because full unroll happens after intrinsification.3988// Unroll is needed because get intrinsic requires for index to be a known constant.3989if (num_lanes == 1) {3990r[i]=av.lane(0);3991} else if (num_lanes == 2) {3992r[i]=av.lane(0);3993r[i+1]=av.lane(1);3994} else if (num_lanes == 4) {3995r[i]=av.lane(0);3996r[i+1]=av.lane(1);3997r[i+2]=av.lane(2);3998r[i+3]=av.lane(3);3999} else if (num_lanes == 8) {4000r[i]=av.lane(0);4001r[i+1]=av.lane(1);4002r[i+2]=av.lane(2);4003r[i+3]=av.lane(3);4004r[i+4]=av.lane(4);4005r[i+5]=av.lane(5);4006r[i+6]=av.lane(6);4007r[i+7]=av.lane(7);4008} else if (num_lanes == 16) {4009r[i]=av.lane(0);4010r[i+1]=av.lane(1);4011r[i+2]=av.lane(2);4012r[i+3]=av.lane(3);4013r[i+4]=av.lane(4);4014r[i+5]=av.lane(5);4015r[i+6]=av.lane(6);4016r[i+7]=av.lane(7);4017r[i+8]=av.lane(8);4018r[i+9]=av.lane(9);4019r[i+10]=av.lane(10);4020r[i+11]=av.lane(11);4021r[i+12]=av.lane(12);4022r[i+13]=av.lane(13);4023r[i+14]=av.lane(14);4024r[i+15]=av.lane(15);4025} else if (num_lanes == 32) {4026r[i]=av.lane(0);4027r[i+1]=av.lane(1);4028r[i+2]=av.lane(2);4029r[i+3]=av.lane(3);4030r[i+4]=av.lane(4);4031r[i+5]=av.lane(5);4032r[i+6]=av.lane(6);4033r[i+7]=av.lane(7);4034r[i+8]=av.lane(8);4035r[i+9]=av.lane(9);4036r[i+10]=av.lane(10);4037r[i+11]=av.lane(11);4038r[i+12]=av.lane(12);4039r[i+13]=av.lane(13);4040r[i+14]=av.lane(14);4041r[i+15]=av.lane(15);4042r[i+16]=av.lane(16);4043r[i+17]=av.lane(17);4044r[i+18]=av.lane(18);4045r[i+19]=av.lane(19);4046r[i+20]=av.lane(20);4047r[i+21]=av.lane(21);4048r[i+22]=av.lane(22);4049r[i+23]=av.lane(23);4050r[i+24]=av.lane(24);4051r[i+25]=av.lane(25);4052r[i+26]=av.lane(26);4053r[i+27]=av.lane(27);4054r[i+28]=av.lane(28);4055r[i+29]=av.lane(29);4056r[i+30]=av.lane(30);4057r[i+31]=av.lane(31);4058} else if (num_lanes == 64) {4059r[i]=av.lane(0);4060r[i+1]=av.lane(1);4061r[i+2]=av.lane(2);4062r[i+3]=av.lane(3);4063r[i+4]=av.lane(4);4064r[i+5]=av.lane(5);4065r[i+6]=av.lane(6);4066r[i+7]=av.lane(7);4067r[i+8]=av.lane(8);4068r[i+9]=av.lane(9);4069r[i+10]=av.lane(10);4070r[i+11]=av.lane(11);4071r[i+12]=av.lane(12);4072r[i+13]=av.lane(13);4073r[i+14]=av.lane(14);4074r[i+15]=av.lane(15);4075r[i+16]=av.lane(16);4076r[i+17]=av.lane(17);4077r[i+18]=av.lane(18);4078r[i+19]=av.lane(19);4079r[i+20]=av.lane(20);4080r[i+21]=av.lane(21);4081r[i+22]=av.lane(22);4082r[i+23]=av.lane(23);4083r[i+24]=av.lane(24);4084r[i+25]=av.lane(25);4085r[i+26]=av.lane(26);4086r[i+27]=av.lane(27);4087r[i+28]=av.lane(28);4088r[i+29]=av.lane(29);4089r[i+30]=av.lane(30);4090r[i+31]=av.lane(31);4091r[i+32]=av.lane(32);4092r[i+33]=av.lane(33);4093r[i+34]=av.lane(34);4094r[i+35]=av.lane(35);4095r[i+36]=av.lane(36);4096r[i+37]=av.lane(37);4097r[i+38]=av.lane(38);4098r[i+39]=av.lane(39);4099r[i+40]=av.lane(40);4100r[i+41]=av.lane(41);4101r[i+42]=av.lane(42);4102r[i+43]=av.lane(43);4103r[i+44]=av.lane(44);4104r[i+45]=av.lane(45);4105r[i+46]=av.lane(46);4106r[i+47]=av.lane(47);4107r[i+48]=av.lane(48);4108r[i+49]=av.lane(49);4109r[i+50]=av.lane(50);4110r[i+51]=av.lane(51);4111r[i+52]=av.lane(52);4112r[i+53]=av.lane(53);4113r[i+54]=av.lane(54);4114r[i+55]=av.lane(55);4115r[i+56]=av.lane(56);4116r[i+57]=av.lane(57);4117r[i+58]=av.lane(58);4118r[i+59]=av.lane(59);4119r[i+60]=av.lane(60);4120r[i+61]=av.lane(61);4121r[i+62]=av.lane(62);4122r[i+63]=av.lane(63);4123} else {4124for (int j = 0; j < SPECIES.length(); j++) {4125r[i+j]=av.lane(j);4126}4127}4128}4129}41304131assertArraysEquals(r, a, Long256VectorTests::get);4132}41334134@Test(dataProvider = "longUnaryOpProvider")4135static void BroadcastLong256VectorTests(IntFunction<long[]> fa) {4136long[] a = fa.apply(SPECIES.length());4137long[] r = new long[a.length];41384139for (int ic = 0; ic < INVOC_COUNT; ic++) {4140for (int i = 0; i < a.length; i += SPECIES.length()) {4141LongVector.broadcast(SPECIES, a[i]).intoArray(r, i);4142}4143}41444145assertBroadcastArraysEquals(r, a);4146}414741484149415041514152@Test(dataProvider = "longUnaryOpProvider")4153static void ZeroLong256VectorTests(IntFunction<long[]> fa) {4154long[] a = fa.apply(SPECIES.length());4155long[] r = new long[a.length];41564157for (int ic = 0; ic < INVOC_COUNT; ic++) {4158for (int i = 0; i < a.length; i += SPECIES.length()) {4159LongVector.zero(SPECIES).intoArray(a, i);4160}4161}41624163Assert.assertEquals(a, r);4164}41654166416741684169static long[] sliceUnary(long[] a, int origin, int idx) {4170long[] res = new long[SPECIES.length()];4171for (int i = 0; i < SPECIES.length(); i++){4172if(i+origin < SPECIES.length())4173res[i] = a[idx+i+origin];4174else4175res[i] = (long)0;4176}4177return res;4178}41794180@Test(dataProvider = "longUnaryOpProvider")4181static void sliceUnaryLong256VectorTests(IntFunction<long[]> fa) {4182long[] a = fa.apply(SPECIES.length());4183long[] r = new long[a.length];4184int origin = (new java.util.Random()).nextInt(SPECIES.length());4185for (int ic = 0; ic < INVOC_COUNT; ic++) {4186for (int i = 0; i < a.length; i += SPECIES.length()) {4187LongVector av = LongVector.fromArray(SPECIES, a, i);4188av.slice(origin).intoArray(r, i);4189}4190}41914192assertArraysEquals(r, a, origin, Long256VectorTests::sliceUnary);4193}4194static long[] sliceBinary(long[] a, long[] b, int origin, int idx) {4195long[] res = new long[SPECIES.length()];4196for (int i = 0, j = 0; i < SPECIES.length(); i++){4197if(i+origin < SPECIES.length())4198res[i] = a[idx+i+origin];4199else {4200res[i] = b[idx+j];4201j++;4202}4203}4204return res;4205}42064207@Test(dataProvider = "longBinaryOpProvider")4208static void sliceBinaryLong256VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {4209long[] a = fa.apply(SPECIES.length());4210long[] b = fb.apply(SPECIES.length());4211long[] r = new long[a.length];4212int origin = (new java.util.Random()).nextInt(SPECIES.length());4213for (int ic = 0; ic < INVOC_COUNT; ic++) {4214for (int i = 0; i < a.length; i += SPECIES.length()) {4215LongVector av = LongVector.fromArray(SPECIES, a, i);4216LongVector bv = LongVector.fromArray(SPECIES, b, i);4217av.slice(origin, bv).intoArray(r, i);4218}4219}42204221assertArraysEquals(r, a, b, origin, Long256VectorTests::sliceBinary);4222}4223static long[] slice(long[] a, long[] b, int origin, boolean[] mask, int idx) {4224long[] res = new long[SPECIES.length()];4225for (int i = 0, j = 0; i < SPECIES.length(); i++){4226if(i+origin < SPECIES.length())4227res[i] = mask[i] ? a[idx+i+origin] : (long)0;4228else {4229res[i] = mask[i] ? b[idx+j] : (long)0;4230j++;4231}4232}4233return res;4234}42354236@Test(dataProvider = "longBinaryOpMaskProvider")4237static void sliceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,4238IntFunction<boolean[]> fm) {4239long[] a = fa.apply(SPECIES.length());4240long[] b = fb.apply(SPECIES.length());4241boolean[] mask = fm.apply(SPECIES.length());4242VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);42434244long[] r = new long[a.length];4245int origin = (new java.util.Random()).nextInt(SPECIES.length());4246for (int ic = 0; ic < INVOC_COUNT; ic++) {4247for (int i = 0; i < a.length; i += SPECIES.length()) {4248LongVector av = LongVector.fromArray(SPECIES, a, i);4249LongVector bv = LongVector.fromArray(SPECIES, b, i);4250av.slice(origin, bv, vmask).intoArray(r, i);4251}4252}42534254assertArraysEquals(r, a, b, origin, mask, Long256VectorTests::slice);4255}4256static long[] unsliceUnary(long[] a, int origin, int idx) {4257long[] res = new long[SPECIES.length()];4258for (int i = 0, j = 0; i < SPECIES.length(); i++){4259if(i < origin)4260res[i] = (long)0;4261else {4262res[i] = a[idx+j];4263j++;4264}4265}4266return res;4267}42684269@Test(dataProvider = "longUnaryOpProvider")4270static void unsliceUnaryLong256VectorTests(IntFunction<long[]> fa) {4271long[] a = fa.apply(SPECIES.length());4272long[] r = new long[a.length];4273int origin = (new java.util.Random()).nextInt(SPECIES.length());4274for (int ic = 0; ic < INVOC_COUNT; ic++) {4275for (int i = 0; i < a.length; i += SPECIES.length()) {4276LongVector av = LongVector.fromArray(SPECIES, a, i);4277av.unslice(origin).intoArray(r, i);4278}4279}42804281assertArraysEquals(r, a, origin, Long256VectorTests::unsliceUnary);4282}4283static long[] unsliceBinary(long[] a, long[] b, int origin, int part, int idx) {4284long[] res = new long[SPECIES.length()];4285for (int i = 0, j = 0; i < SPECIES.length(); i++){4286if (part == 0) {4287if (i < origin)4288res[i] = b[idx+i];4289else {4290res[i] = a[idx+j];4291j++;4292}4293} else if (part == 1) {4294if (i < origin)4295res[i] = a[idx+SPECIES.length()-origin+i];4296else {4297res[i] = b[idx+origin+j];4298j++;4299}4300}4301}4302return res;4303}43044305@Test(dataProvider = "longBinaryOpProvider")4306static void unsliceBinaryLong256VectorTestsBinary(IntFunction<long[]> fa, IntFunction<long[]> fb) {4307long[] a = fa.apply(SPECIES.length());4308long[] b = fb.apply(SPECIES.length());4309long[] r = new long[a.length];4310int origin = (new java.util.Random()).nextInt(SPECIES.length());4311int part = (new java.util.Random()).nextInt(2);4312for (int ic = 0; ic < INVOC_COUNT; ic++) {4313for (int i = 0; i < a.length; i += SPECIES.length()) {4314LongVector av = LongVector.fromArray(SPECIES, a, i);4315LongVector bv = LongVector.fromArray(SPECIES, b, i);4316av.unslice(origin, bv, part).intoArray(r, i);4317}4318}43194320assertArraysEquals(r, a, b, origin, part, Long256VectorTests::unsliceBinary);4321}4322static long[] unslice(long[] a, long[] b, int origin, int part, boolean[] mask, int idx) {4323long[] res = new long[SPECIES.length()];4324for (int i = 0, j = 0; i < SPECIES.length(); i++){4325if(i+origin < SPECIES.length())4326res[i] = b[idx+i+origin];4327else {4328res[i] = b[idx+j];4329j++;4330}4331}4332for (int i = 0; i < SPECIES.length(); i++){4333res[i] = mask[i] ? a[idx+i] : res[i];4334}4335long[] res1 = new long[SPECIES.length()];4336if (part == 0) {4337for (int i = 0, j = 0; i < SPECIES.length(); i++){4338if (i < origin)4339res1[i] = b[idx+i];4340else {4341res1[i] = res[j];4342j++;4343}4344}4345} else if (part == 1) {4346for (int i = 0, j = 0; i < SPECIES.length(); i++){4347if (i < origin)4348res1[i] = res[SPECIES.length()-origin+i];4349else {4350res1[i] = b[idx+origin+j];4351j++;4352}4353}4354}4355return res1;4356}43574358@Test(dataProvider = "longBinaryOpMaskProvider")4359static void unsliceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,4360IntFunction<boolean[]> fm) {4361long[] a = fa.apply(SPECIES.length());4362long[] b = fb.apply(SPECIES.length());4363boolean[] mask = fm.apply(SPECIES.length());4364VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);4365long[] r = new long[a.length];4366int origin = (new java.util.Random()).nextInt(SPECIES.length());4367int part = (new java.util.Random()).nextInt(2);4368for (int ic = 0; ic < INVOC_COUNT; ic++) {4369for (int i = 0; i < a.length; i += SPECIES.length()) {4370LongVector av = LongVector.fromArray(SPECIES, a, i);4371LongVector bv = LongVector.fromArray(SPECIES, b, i);4372av.unslice(origin, bv, part, vmask).intoArray(r, i);4373}4374}43754376assertArraysEquals(r, a, b, origin, part, mask, Long256VectorTests::unslice);4377}437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401static long BITWISE_BLEND(long a, long b, long c) {4402return (long)((a&~(c))|(b&c));4403}4404static long bitwiseBlend(long a, long b, long c) {4405return (long)((a&~(c))|(b&c));4406}440744084409@Test(dataProvider = "longTernaryOpProvider")4410static void BITWISE_BLENDLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4411long[] a = fa.apply(SPECIES.length());4412long[] b = fb.apply(SPECIES.length());4413long[] c = fc.apply(SPECIES.length());4414long[] r = fr.apply(SPECIES.length());44154416for (int ic = 0; ic < INVOC_COUNT; ic++) {4417for (int i = 0; i < a.length; i += SPECIES.length()) {4418LongVector av = LongVector.fromArray(SPECIES, a, i);4419LongVector bv = LongVector.fromArray(SPECIES, b, i);4420LongVector cv = LongVector.fromArray(SPECIES, c, i);4421av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);4422}4423}44244425assertArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);4426}4427@Test(dataProvider = "longTernaryOpProvider")4428static void bitwiseBlendLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4429long[] a = fa.apply(SPECIES.length());4430long[] b = fb.apply(SPECIES.length());4431long[] c = fc.apply(SPECIES.length());4432long[] r = fr.apply(SPECIES.length());44334434for (int i = 0; i < a.length; i += SPECIES.length()) {4435LongVector av = LongVector.fromArray(SPECIES, a, i);4436LongVector bv = LongVector.fromArray(SPECIES, b, i);4437LongVector cv = LongVector.fromArray(SPECIES, c, i);4438av.bitwiseBlend(bv, cv).intoArray(r, i);4439}44404441assertArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);4442}444344444445@Test(dataProvider = "longTernaryOpMaskProvider")4446static void BITWISE_BLENDLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,4447IntFunction<long[]> fc, IntFunction<boolean[]> fm) {4448long[] a = fa.apply(SPECIES.length());4449long[] b = fb.apply(SPECIES.length());4450long[] c = fc.apply(SPECIES.length());4451long[] r = fr.apply(SPECIES.length());4452boolean[] mask = fm.apply(SPECIES.length());4453VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);44544455for (int ic = 0; ic < INVOC_COUNT; ic++) {4456for (int i = 0; i < a.length; i += SPECIES.length()) {4457LongVector av = LongVector.fromArray(SPECIES, a, i);4458LongVector bv = LongVector.fromArray(SPECIES, b, i);4459LongVector cv = LongVector.fromArray(SPECIES, c, i);4460av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);4461}4462}44634464assertArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);4465}44664467446844694470@Test(dataProvider = "longTernaryOpProvider")4471static void BITWISE_BLENDLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4472long[] a = fa.apply(SPECIES.length());4473long[] b = fb.apply(SPECIES.length());4474long[] c = fc.apply(SPECIES.length());4475long[] r = fr.apply(SPECIES.length());44764477for (int i = 0; i < a.length; i += SPECIES.length()) {4478LongVector av = LongVector.fromArray(SPECIES, a, i);4479LongVector bv = LongVector.fromArray(SPECIES, b, i);4480av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);4481}4482assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);4483}44844485@Test(dataProvider = "longTernaryOpProvider")4486static void BITWISE_BLENDLong256VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4487long[] a = fa.apply(SPECIES.length());4488long[] b = fb.apply(SPECIES.length());4489long[] c = fc.apply(SPECIES.length());4490long[] r = fr.apply(SPECIES.length());44914492for (int i = 0; i < a.length; i += SPECIES.length()) {4493LongVector av = LongVector.fromArray(SPECIES, a, i);4494LongVector cv = LongVector.fromArray(SPECIES, c, i);4495av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);4496}4497assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);4498}4499@Test(dataProvider = "longTernaryOpProvider")4500static void bitwiseBlendLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4501long[] a = fa.apply(SPECIES.length());4502long[] b = fb.apply(SPECIES.length());4503long[] c = fc.apply(SPECIES.length());4504long[] r = fr.apply(SPECIES.length());45054506for (int i = 0; i < a.length; i += SPECIES.length()) {4507LongVector av = LongVector.fromArray(SPECIES, a, i);4508LongVector bv = LongVector.fromArray(SPECIES, b, i);4509av.bitwiseBlend(bv, c[i]).intoArray(r, i);4510}4511assertBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);4512}45134514@Test(dataProvider = "longTernaryOpProvider")4515static void bitwiseBlendLong256VectorTestsAltBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4516long[] a = fa.apply(SPECIES.length());4517long[] b = fb.apply(SPECIES.length());4518long[] c = fc.apply(SPECIES.length());4519long[] r = fr.apply(SPECIES.length());45204521for (int i = 0; i < a.length; i += SPECIES.length()) {4522LongVector av = LongVector.fromArray(SPECIES, a, i);4523LongVector cv = LongVector.fromArray(SPECIES, c, i);4524av.bitwiseBlend(b[i], cv).intoArray(r, i);4525}4526assertAltBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);4527}452845294530@Test(dataProvider = "longTernaryOpMaskProvider")4531static void BITWISE_BLENDLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,4532IntFunction<long[]> fc, IntFunction<boolean[]> fm) {4533long[] a = fa.apply(SPECIES.length());4534long[] b = fb.apply(SPECIES.length());4535long[] c = fc.apply(SPECIES.length());4536long[] r = fr.apply(SPECIES.length());4537boolean[] mask = fm.apply(SPECIES.length());4538VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);45394540for (int i = 0; i < a.length; i += SPECIES.length()) {4541LongVector av = LongVector.fromArray(SPECIES, a, i);4542LongVector bv = LongVector.fromArray(SPECIES, b, i);4543av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);4544}45454546assertBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);4547}45484549@Test(dataProvider = "longTernaryOpMaskProvider")4550static void BITWISE_BLENDLong256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,4551IntFunction<long[]> fc, IntFunction<boolean[]> fm) {4552long[] a = fa.apply(SPECIES.length());4553long[] b = fb.apply(SPECIES.length());4554long[] c = fc.apply(SPECIES.length());4555long[] r = fr.apply(SPECIES.length());4556boolean[] mask = fm.apply(SPECIES.length());4557VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);45584559for (int i = 0; i < a.length; i += SPECIES.length()) {4560LongVector av = LongVector.fromArray(SPECIES, a, i);4561LongVector cv = LongVector.fromArray(SPECIES, c, i);4562av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);4563}45644565assertAltBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);4566}45674568456945704571@Test(dataProvider = "longTernaryOpProvider")4572static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4573long[] a = fa.apply(SPECIES.length());4574long[] b = fb.apply(SPECIES.length());4575long[] c = fc.apply(SPECIES.length());4576long[] r = fr.apply(SPECIES.length());45774578for (int i = 0; i < a.length; i += SPECIES.length()) {4579LongVector av = LongVector.fromArray(SPECIES, a, i);4580av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);4581}45824583assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::BITWISE_BLEND);4584}4585@Test(dataProvider = "longTernaryOpProvider")4586static void bitwiseBlendLong256VectorTestsDoubleBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb, IntFunction<long[]> fc) {4587long[] a = fa.apply(SPECIES.length());4588long[] b = fb.apply(SPECIES.length());4589long[] c = fc.apply(SPECIES.length());4590long[] r = fr.apply(SPECIES.length());45914592for (int i = 0; i < a.length; i += SPECIES.length()) {4593LongVector av = LongVector.fromArray(SPECIES, a, i);4594av.bitwiseBlend(b[i], c[i]).intoArray(r, i);4595}45964597assertDoubleBroadcastArraysEquals(r, a, b, c, Long256VectorTests::bitwiseBlend);4598}459946004601@Test(dataProvider = "longTernaryOpMaskProvider")4602static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb,4603IntFunction<long[]> fc, IntFunction<boolean[]> fm) {4604long[] a = fa.apply(SPECIES.length());4605long[] b = fb.apply(SPECIES.length());4606long[] c = fc.apply(SPECIES.length());4607long[] r = fr.apply(SPECIES.length());4608boolean[] mask = fm.apply(SPECIES.length());4609VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);46104611for (int i = 0; i < a.length; i += SPECIES.length()) {4612LongVector av = LongVector.fromArray(SPECIES, a, i);4613av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);4614}46154616assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Long256VectorTests::BITWISE_BLEND);4617}461846194620static long NEG(long a) {4621return (long)(-((long)a));4622}46234624static long neg(long a) {4625return (long)(-((long)a));4626}46274628@Test(dataProvider = "longUnaryOpProvider")4629static void NEGLong256VectorTests(IntFunction<long[]> fa) {4630long[] a = fa.apply(SPECIES.length());4631long[] r = fr.apply(SPECIES.length());46324633for (int ic = 0; ic < INVOC_COUNT; ic++) {4634for (int i = 0; i < a.length; i += SPECIES.length()) {4635LongVector av = LongVector.fromArray(SPECIES, a, i);4636av.lanewise(VectorOperators.NEG).intoArray(r, i);4637}4638}46394640assertArraysEquals(r, a, Long256VectorTests::NEG);4641}46424643@Test(dataProvider = "longUnaryOpProvider")4644static void negLong256VectorTests(IntFunction<long[]> fa) {4645long[] a = fa.apply(SPECIES.length());4646long[] r = fr.apply(SPECIES.length());46474648for (int ic = 0; ic < INVOC_COUNT; ic++) {4649for (int i = 0; i < a.length; i += SPECIES.length()) {4650LongVector av = LongVector.fromArray(SPECIES, a, i);4651av.neg().intoArray(r, i);4652}4653}46544655assertArraysEquals(r, a, Long256VectorTests::neg);4656}46574658@Test(dataProvider = "longUnaryOpMaskProvider")4659static void NEGMaskedLong256VectorTests(IntFunction<long[]> fa,4660IntFunction<boolean[]> fm) {4661long[] a = fa.apply(SPECIES.length());4662long[] r = fr.apply(SPECIES.length());4663boolean[] mask = fm.apply(SPECIES.length());4664VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);46654666for (int ic = 0; ic < INVOC_COUNT; ic++) {4667for (int i = 0; i < a.length; i += SPECIES.length()) {4668LongVector av = LongVector.fromArray(SPECIES, a, i);4669av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);4670}4671}46724673assertArraysEquals(r, a, mask, Long256VectorTests::NEG);4674}46754676static long ABS(long a) {4677return (long)(Math.abs((long)a));4678}46794680static long abs(long a) {4681return (long)(Math.abs((long)a));4682}46834684@Test(dataProvider = "longUnaryOpProvider")4685static void ABSLong256VectorTests(IntFunction<long[]> fa) {4686long[] a = fa.apply(SPECIES.length());4687long[] r = fr.apply(SPECIES.length());46884689for (int ic = 0; ic < INVOC_COUNT; ic++) {4690for (int i = 0; i < a.length; i += SPECIES.length()) {4691LongVector av = LongVector.fromArray(SPECIES, a, i);4692av.lanewise(VectorOperators.ABS).intoArray(r, i);4693}4694}46954696assertArraysEquals(r, a, Long256VectorTests::ABS);4697}46984699@Test(dataProvider = "longUnaryOpProvider")4700static void absLong256VectorTests(IntFunction<long[]> fa) {4701long[] a = fa.apply(SPECIES.length());4702long[] r = fr.apply(SPECIES.length());47034704for (int ic = 0; ic < INVOC_COUNT; ic++) {4705for (int i = 0; i < a.length; i += SPECIES.length()) {4706LongVector av = LongVector.fromArray(SPECIES, a, i);4707av.abs().intoArray(r, i);4708}4709}47104711assertArraysEquals(r, a, Long256VectorTests::abs);4712}47134714@Test(dataProvider = "longUnaryOpMaskProvider")4715static void ABSMaskedLong256VectorTests(IntFunction<long[]> fa,4716IntFunction<boolean[]> fm) {4717long[] a = fa.apply(SPECIES.length());4718long[] r = fr.apply(SPECIES.length());4719boolean[] mask = fm.apply(SPECIES.length());4720VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);47214722for (int ic = 0; ic < INVOC_COUNT; ic++) {4723for (int i = 0; i < a.length; i += SPECIES.length()) {4724LongVector av = LongVector.fromArray(SPECIES, a, i);4725av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);4726}4727}47284729assertArraysEquals(r, a, mask, Long256VectorTests::ABS);4730}473147324733static long NOT(long a) {4734return (long)(~((long)a));4735}47364737static long not(long a) {4738return (long)(~((long)a));4739}4740474147424743@Test(dataProvider = "longUnaryOpProvider")4744static void NOTLong256VectorTests(IntFunction<long[]> fa) {4745long[] a = fa.apply(SPECIES.length());4746long[] r = fr.apply(SPECIES.length());47474748for (int ic = 0; ic < INVOC_COUNT; ic++) {4749for (int i = 0; i < a.length; i += SPECIES.length()) {4750LongVector av = LongVector.fromArray(SPECIES, a, i);4751av.lanewise(VectorOperators.NOT).intoArray(r, i);4752}4753}47544755assertArraysEquals(r, a, Long256VectorTests::NOT);4756}47574758@Test(dataProvider = "longUnaryOpProvider")4759static void notLong256VectorTests(IntFunction<long[]> fa) {4760long[] a = fa.apply(SPECIES.length());4761long[] r = fr.apply(SPECIES.length());47624763for (int ic = 0; ic < INVOC_COUNT; ic++) {4764for (int i = 0; i < a.length; i += SPECIES.length()) {4765LongVector av = LongVector.fromArray(SPECIES, a, i);4766av.not().intoArray(r, i);4767}4768}47694770assertArraysEquals(r, a, Long256VectorTests::not);4771}4772477347744775@Test(dataProvider = "longUnaryOpMaskProvider")4776static void NOTMaskedLong256VectorTests(IntFunction<long[]> fa,4777IntFunction<boolean[]> fm) {4778long[] a = fa.apply(SPECIES.length());4779long[] r = fr.apply(SPECIES.length());4780boolean[] mask = fm.apply(SPECIES.length());4781VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);47824783for (int ic = 0; ic < INVOC_COUNT; ic++) {4784for (int i = 0; i < a.length; i += SPECIES.length()) {4785LongVector av = LongVector.fromArray(SPECIES, a, i);4786av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);4787}4788}47894790assertArraysEquals(r, a, mask, Long256VectorTests::NOT);4791}4792479347944795static long ZOMO(long a) {4796return (long)((a==0?0:-1));4797}4798479948004801@Test(dataProvider = "longUnaryOpProvider")4802static void ZOMOLong256VectorTests(IntFunction<long[]> fa) {4803long[] a = fa.apply(SPECIES.length());4804long[] r = fr.apply(SPECIES.length());48054806for (int ic = 0; ic < INVOC_COUNT; ic++) {4807for (int i = 0; i < a.length; i += SPECIES.length()) {4808LongVector av = LongVector.fromArray(SPECIES, a, i);4809av.lanewise(VectorOperators.ZOMO).intoArray(r, i);4810}4811}48124813assertArraysEquals(r, a, Long256VectorTests::ZOMO);4814}4815481648174818@Test(dataProvider = "longUnaryOpMaskProvider")4819static void ZOMOMaskedLong256VectorTests(IntFunction<long[]> fa,4820IntFunction<boolean[]> fm) {4821long[] a = fa.apply(SPECIES.length());4822long[] r = fr.apply(SPECIES.length());4823boolean[] mask = fm.apply(SPECIES.length());4824VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);48254826for (int ic = 0; ic < INVOC_COUNT; ic++) {4827for (int i = 0; i < a.length; i += SPECIES.length()) {4828LongVector av = LongVector.fromArray(SPECIES, a, i);4829av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);4830}4831}48324833assertArraysEquals(r, a, mask, Long256VectorTests::ZOMO);4834}48354836483748384839static long[] gather(long a[], int ix, int[] b, int iy) {4840long[] res = new long[SPECIES.length()];4841for (int i = 0; i < SPECIES.length(); i++) {4842int bi = iy + i;4843res[i] = a[b[bi] + ix];4844}4845return res;4846}48474848@Test(dataProvider = "longUnaryOpIndexProvider")4849static void gatherLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {4850long[] a = fa.apply(SPECIES.length());4851int[] b = fs.apply(a.length, SPECIES.length());4852long[] r = new long[a.length];48534854for (int ic = 0; ic < INVOC_COUNT; ic++) {4855for (int i = 0; i < a.length; i += SPECIES.length()) {4856LongVector av = LongVector.fromArray(SPECIES, a, i, b, i);4857av.intoArray(r, i);4858}4859}48604861assertArraysEquals(r, a, b, Long256VectorTests::gather);4862}4863static long[] gatherMasked(long a[], int ix, boolean[] mask, int[] b, int iy) {4864long[] res = new long[SPECIES.length()];4865for (int i = 0; i < SPECIES.length(); i++) {4866int bi = iy + i;4867if (mask[i]) {4868res[i] = a[b[bi] + ix];4869}4870}4871return res;4872}48734874@Test(dataProvider = "longUnaryMaskedOpIndexProvider")4875static void gatherMaskedLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {4876long[] a = fa.apply(SPECIES.length());4877int[] b = fs.apply(a.length, SPECIES.length());4878long[] r = new long[a.length];4879boolean[] mask = fm.apply(SPECIES.length());4880VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);48814882for (int ic = 0; ic < INVOC_COUNT; ic++) {4883for (int i = 0; i < a.length; i += SPECIES.length()) {4884LongVector av = LongVector.fromArray(SPECIES, a, i, b, i, vmask);4885av.intoArray(r, i);4886}4887}48884889assertArraysEquals(r, a, b, mask, Long256VectorTests::gatherMasked);4890}48914892static long[] scatter(long a[], int ix, int[] b, int iy) {4893long[] res = new long[SPECIES.length()];4894for (int i = 0; i < SPECIES.length(); i++) {4895int bi = iy + i;4896res[b[bi]] = a[i + ix];4897}4898return res;4899}49004901@Test(dataProvider = "longUnaryOpIndexProvider")4902static void scatterLong256VectorTests(IntFunction<long[]> fa, BiFunction<Integer,Integer,int[]> fs) {4903long[] a = fa.apply(SPECIES.length());4904int[] b = fs.apply(a.length, SPECIES.length());4905long[] r = new long[a.length];49064907for (int ic = 0; ic < INVOC_COUNT; ic++) {4908for (int i = 0; i < a.length; i += SPECIES.length()) {4909LongVector av = LongVector.fromArray(SPECIES, a, i);4910av.intoArray(r, i, b, i);4911}4912}49134914assertArraysEquals(r, a, b, Long256VectorTests::scatter);4915}49164917static long[] scatterMasked(long r[], long a[], int ix, boolean[] mask, int[] b, int iy) {4918// First, gather r.4919long[] oldVal = gather(r, ix, b, iy);4920long[] newVal = new long[SPECIES.length()];49214922// Second, blending it with a.4923for (int i = 0; i < SPECIES.length(); i++) {4924newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);4925}49264927// Third, scatter: copy old value of r, and scatter it manually.4928long[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());4929for (int i = 0; i < SPECIES.length(); i++) {4930int bi = iy + i;4931res[b[bi]] = newVal[i];4932}49334934return res;4935}49364937@Test(dataProvider = "scatterMaskedOpIndexProvider")4938static void scatterMaskedLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {4939long[] a = fa.apply(SPECIES.length());4940int[] b = fs.apply(a.length, SPECIES.length());4941long[] r = fb.apply(SPECIES.length());4942boolean[] mask = fm.apply(SPECIES.length());4943VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);49444945for (int ic = 0; ic < INVOC_COUNT; ic++) {4946for (int i = 0; i < a.length; i += SPECIES.length()) {4947LongVector av = LongVector.fromArray(SPECIES, a, i);4948av.intoArray(r, i, b, i, vmask);4949}4950}49514952assertArraysEquals(r, a, b, mask, Long256VectorTests::scatterMasked);4953}495449554956@Test(dataProvider = "longCompareOpProvider")4957static void ltLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {4958long[] a = fa.apply(SPECIES.length());4959long[] b = fb.apply(SPECIES.length());49604961for (int i = 0; i < a.length; i += SPECIES.length()) {4962LongVector av = LongVector.fromArray(SPECIES, a, i);4963VectorMask<Long> mv = av.lt(b[i]);49644965// Check results as part of computation.4966for (int j = 0; j < SPECIES.length(); j++) {4967Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);4968}4969}4970}49714972@Test(dataProvider = "longCompareOpProvider")4973static void eqLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {4974long[] a = fa.apply(SPECIES.length());4975long[] b = fb.apply(SPECIES.length());49764977for (int i = 0; i < a.length; i += SPECIES.length()) {4978LongVector av = LongVector.fromArray(SPECIES, a, i);4979VectorMask<Long> mv = av.eq(b[i]);49804981// Check results as part of computation.4982for (int j = 0; j < SPECIES.length(); j++) {4983Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);4984}4985}4986}49874988@Test(dataProvider = "longtoIntUnaryOpProvider")4989static void toIntArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {4990long[] a = fa.apply(SPECIES.length());49914992for (int i = 0; i < a.length; i += SPECIES.length()) {4993LongVector av = LongVector.fromArray(SPECIES, a, i);4994int[] r = av.toIntArray();4995assertArraysEquals(r, a, i);4996}4997}49984999@Test(dataProvider = "longUnaryOpProvider")5000static void toLongArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {5001long[] a = fa.apply(SPECIES.length());50025003for (int i = 0; i < a.length; i += SPECIES.length()) {5004LongVector av = LongVector.fromArray(SPECIES, a, i);5005long[] r = av.toLongArray();5006assertArraysEquals(r, a, i);5007}5008}50095010@Test(dataProvider = "longUnaryOpProvider")5011static void toDoubleArrayLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {5012long[] a = fa.apply(SPECIES.length());50135014for (int i = 0; i < a.length; i += SPECIES.length()) {5015LongVector av = LongVector.fromArray(SPECIES, a, i);5016double[] r = av.toDoubleArray();5017assertArraysEquals(r, a, i);5018}5019}50205021@Test(dataProvider = "longUnaryOpProvider")5022static void toStringLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {5023long[] a = fa.apply(SPECIES.length());50245025for (int i = 0; i < a.length; i += SPECIES.length()) {5026LongVector av = LongVector.fromArray(SPECIES, a, i);5027String str = av.toString();50285029long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());5030Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);5031}5032}50335034@Test(dataProvider = "longUnaryOpProvider")5035static void hashCodeLong256VectorTestsSmokeTest(IntFunction<long[]> fa) {5036long[] a = fa.apply(SPECIES.length());50375038for (int i = 0; i < a.length; i += SPECIES.length()) {5039LongVector av = LongVector.fromArray(SPECIES, a, i);5040int hash = av.hashCode();50415042long subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());5043int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));5044Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);5045}5046}5047504850495050@Test(dataProvider = "longUnaryOpProvider")5051static void ADDReduceLongLong256VectorTests(IntFunction<long[]> fa) {5052long[] a = fa.apply(SPECIES.length());5053long[] r = fr.apply(SPECIES.length());5054long ra = 0;50555056for (int i = 0; i < a.length; i += SPECIES.length()) {5057LongVector av = LongVector.fromArray(SPECIES, a, i);5058r[i] = av.reduceLanesToLong(VectorOperators.ADD);5059}50605061ra = 0;5062for (int i = 0; i < a.length; i ++) {5063ra += r[i];5064}50655066assertReductionArraysEquals(r, ra, a,5067Long256VectorTests::ADDReduce, Long256VectorTests::ADDReduceAll);5068}50695070@Test(dataProvider = "longUnaryOpMaskProvider")5071static void ADDReduceLongLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {5072long[] a = fa.apply(SPECIES.length());5073long[] r = fr.apply(SPECIES.length());5074boolean[] mask = fm.apply(SPECIES.length());5075VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);5076long ra = 0;50775078for (int i = 0; i < a.length; i += SPECIES.length()) {5079LongVector av = LongVector.fromArray(SPECIES, a, i);5080r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);5081}50825083ra = 0;5084for (int i = 0; i < a.length; i ++) {5085ra += r[i];5086}50875088assertReductionArraysEqualsMasked(r, ra, a, mask,5089Long256VectorTests::ADDReduceMasked, Long256VectorTests::ADDReduceAllMasked);5090}50915092@Test(dataProvider = "longUnaryOpSelectFromProvider")5093static void SelectFromLong256VectorTests(IntFunction<long[]> fa,5094BiFunction<Integer,Integer,long[]> fs) {5095long[] a = fa.apply(SPECIES.length());5096long[] order = fs.apply(a.length, SPECIES.length());5097long[] r = fr.apply(SPECIES.length());50985099for (int i = 0; i < a.length; i += SPECIES.length()) {5100LongVector av = LongVector.fromArray(SPECIES, a, i);5101LongVector bv = LongVector.fromArray(SPECIES, order, i);5102bv.selectFrom(av).intoArray(r, i);5103}51045105assertSelectFromArraysEquals(r, a, order, SPECIES.length());5106}51075108@Test(dataProvider = "longUnaryOpSelectFromMaskProvider")5109static void SelectFromLong256VectorTestsMaskedSmokeTest(IntFunction<long[]> fa,5110BiFunction<Integer,Integer,long[]> fs,5111IntFunction<boolean[]> fm) {5112long[] a = fa.apply(SPECIES.length());5113long[] order = fs.apply(a.length, SPECIES.length());5114long[] r = fr.apply(SPECIES.length());5115boolean[] mask = fm.apply(SPECIES.length());5116VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);51175118for (int i = 0; i < a.length; i += SPECIES.length()) {5119LongVector av = LongVector.fromArray(SPECIES, a, i);5120LongVector bv = LongVector.fromArray(SPECIES, order, i);5121bv.selectFrom(av, vmask).intoArray(r, i);5122}51235124assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());5125}51265127@Test(dataProvider = "shuffleProvider")5128static void shuffleMiscellaneousLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {5129int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());51305131for (int i = 0; i < a.length; i += SPECIES.length()) {5132var shuffle = VectorShuffle.fromArray(SPECIES, a, i);5133int hash = shuffle.hashCode();5134int length = shuffle.length();51355136int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());5137int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));5138Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);5139Assert.assertEquals(length, SPECIES.length());5140}5141}51425143@Test(dataProvider = "shuffleProvider")5144static void shuffleToStringLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {5145int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());51465147for (int i = 0; i < a.length; i += SPECIES.length()) {5148var shuffle = VectorShuffle.fromArray(SPECIES, a, i);5149String str = shuffle.toString();51505151int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());5152Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +5153i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);5154}5155}51565157@Test(dataProvider = "shuffleCompareOpProvider")5158static void shuffleEqualsLong256VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {5159int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());5160int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());51615162for (int i = 0; i < a.length; i += SPECIES.length()) {5163var av = VectorShuffle.fromArray(SPECIES, a, i);5164var bv = VectorShuffle.fromArray(SPECIES, b, i);5165boolean eq = av.equals(bv);5166int to = i + SPECIES.length();5167Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));5168}5169}51705171@Test(dataProvider = "maskCompareOpProvider")5172static void maskEqualsLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {5173boolean[] a = fa.apply(SPECIES.length());5174boolean[] b = fb.apply(SPECIES.length());51755176for (int i = 0; i < a.length; i += SPECIES.length()) {5177var av = SPECIES.loadMask(a, i);5178var bv = SPECIES.loadMask(b, i);5179boolean equals = av.equals(bv);5180int to = i + SPECIES.length();5181Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));5182}5183}51845185static boolean beq(boolean a, boolean b) {5186return (a == b);5187}51885189@Test(dataProvider = "maskCompareOpProvider")5190static void maskEqLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {5191boolean[] a = fa.apply(SPECIES.length());5192boolean[] b = fb.apply(SPECIES.length());5193boolean[] r = new boolean[a.length];51945195for (int i = 0; i < a.length; i += SPECIES.length()) {5196var av = SPECIES.loadMask(a, i);5197var bv = SPECIES.loadMask(b, i);5198var cv = av.eq(bv);5199cv.intoArray(r, i);5200}5201assertArraysEquals(r, a, b, Long256VectorTests::beq);5202}52035204@Test(dataProvider = "maskProvider")5205static void maskHashCodeLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {5206boolean[] a = fa.apply(SPECIES.length());52075208for (int i = 0; i < a.length; i += SPECIES.length()) {5209var vmask = SPECIES.loadMask(a, i);5210int hash = vmask.hashCode();52115212boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());5213int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));5214Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);5215}5216}52175218@Test(dataProvider = "maskProvider")5219static void maskTrueCountLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {5220boolean[] a = fa.apply(SPECIES.length());52215222for (int i = 0; i < a.length; i += SPECIES.length()) {5223var vmask = SPECIES.loadMask(a, i);5224int tcount = vmask.trueCount();5225int expectedTcount = 0;5226for (int j = i; j < i + SPECIES.length(); j++) {5227expectedTcount += a[j] ? 1 : 0;5228}5229Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);5230}5231}52325233@Test(dataProvider = "maskProvider")5234static void maskLastTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {5235boolean[] a = fa.apply(SPECIES.length());52365237for (int i = 0; i < a.length; i += SPECIES.length()) {5238var vmask = SPECIES.loadMask(a, i);5239int ltrue = vmask.lastTrue();5240int j = i + SPECIES.length() - 1;5241for (; j >= i; j--) {5242if (a[j]) break;5243}5244int expectedLtrue = j - i;52455246Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +5247", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);5248}5249}52505251@Test(dataProvider = "maskProvider")5252static void maskFirstTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {5253boolean[] a = fa.apply(SPECIES.length());52545255for (int i = 0; i < a.length; i += SPECIES.length()) {5256var vmask = SPECIES.loadMask(a, i);5257int ftrue = vmask.firstTrue();5258int j = i;5259for (; j < i + SPECIES.length() ; j++) {5260if (a[j]) break;5261}5262int expectedFtrue = j - i;52635264Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +5265", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);5266}5267}52685269@DataProvider5270public static Object[][] longMaskProvider() {5271return new Object[][]{5272{0xFFFFFFFFFFFFFFFFL},5273{0x0000000000000000L},5274{0x5555555555555555L},5275{0x0123456789abcdefL},5276};5277}52785279@Test(dataProvider = "longMaskProvider")5280static void maskFromToLongLong256VectorTestsSmokeTest(long inputLong) {5281var vmask = VectorMask.fromLong(SPECIES, inputLong);5282long outputLong = vmask.toLong();5283Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));5284}52855286@DataProvider5287public static Object[][] offsetProvider() {5288return new Object[][]{5289{0},5290{-1},5291{+1},5292{+2},5293{-2},5294};5295}52965297@Test(dataProvider = "offsetProvider")5298static void indexInRangeLong256VectorTestsSmokeTest(int offset) {5299int limit = SPECIES.length() * BUFFER_REPS;5300for (int i = 0; i < limit; i += SPECIES.length()) {5301var actualMask = SPECIES.indexInRange(i + offset, limit);5302var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);5303assert(actualMask.equals(expectedMask));5304for (int j = 0; j < SPECIES.length(); j++) {5305int index = i + j + offset;5306Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);5307}5308}5309}53105311@DataProvider5312public static Object[][] lengthProvider() {5313return new Object[][]{5314{0},5315{1},5316{32},5317{37},5318{1024},5319{1024+1},5320{1024+5},5321};5322}53235324@Test(dataProvider = "lengthProvider")5325static void loopBoundLong256VectorTestsSmokeTest(int length) {5326int actualLoopBound = SPECIES.loopBound(length);5327int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());5328Assert.assertEquals(actualLoopBound, expectedLoopBound);5329}53305331@Test5332static void ElementSizeLong256VectorTestsSmokeTest() {5333LongVector av = LongVector.zero(SPECIES);5334int elsize = av.elementSize();5335Assert.assertEquals(elsize, Long.SIZE);5336}53375338@Test5339static void VectorShapeLong256VectorTestsSmokeTest() {5340LongVector av = LongVector.zero(SPECIES);5341VectorShape vsh = av.shape();5342assert(vsh.equals(VectorShape.S_256_BIT));5343}53445345@Test5346static void ShapeWithLanesLong256VectorTestsSmokeTest() {5347LongVector av = LongVector.zero(SPECIES);5348VectorShape vsh = av.shape();5349VectorSpecies species = vsh.withLanes(long.class);5350assert(species.equals(SPECIES));5351}53525353@Test5354static void ElementTypeLong256VectorTestsSmokeTest() {5355LongVector av = LongVector.zero(SPECIES);5356assert(av.species().elementType() == long.class);5357}53585359@Test5360static void SpeciesElementSizeLong256VectorTestsSmokeTest() {5361LongVector av = LongVector.zero(SPECIES);5362assert(av.species().elementSize() == Long.SIZE);5363}53645365@Test5366static void VectorTypeLong256VectorTestsSmokeTest() {5367LongVector av = LongVector.zero(SPECIES);5368assert(av.species().vectorType() == av.getClass());5369}53705371@Test5372static void WithLanesLong256VectorTestsSmokeTest() {5373LongVector av = LongVector.zero(SPECIES);5374VectorSpecies species = av.species().withLanes(long.class);5375assert(species.equals(SPECIES));5376}53775378@Test5379static void WithShapeLong256VectorTestsSmokeTest() {5380LongVector av = LongVector.zero(SPECIES);5381VectorShape vsh = av.shape();5382VectorSpecies species = av.species().withShape(vsh);5383assert(species.equals(SPECIES));5384}5385}5386538753885389