1 /*
2 * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @key randomness
27 *
28 * @library /test/lib
29 * @modules jdk.incubator.vector
30 * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Short64VectorTests
31 */
32
33 // -- This file was mechanically generated: Do not edit! -- //
34
35 import jdk.incubator.vector.VectorShape;
36 import jdk.incubator.vector.VectorSpecies;
37 import jdk.incubator.vector.VectorShuffle;
38 import jdk.incubator.vector.VectorMask;
39 import jdk.incubator.vector.VectorOperators;
40 import jdk.incubator.vector.Vector;
41 import jdk.incubator.vector.VectorMath;
42
43 import jdk.incubator.vector.ShortVector;
44
45 import org.testng.Assert;
46 import org.testng.annotations.DataProvider;
47 import org.testng.annotations.Test;
48
49 import java.lang.Integer;
50 import java.util.List;
51 import java.util.Arrays;
52 import java.util.function.BiFunction;
53 import java.util.function.IntFunction;
54 import java.util.Objects;
55 import java.util.stream.Collectors;
56 import java.util.stream.Stream;
57
58 @Test
59 public class Short64VectorTests extends AbstractVectorTest {
60
61 static final VectorSpecies<Short> SPECIES =
62 ShortVector.SPECIES_64;
63
64 static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
65
66
67 private static final short CONST_SHIFT = Short.SIZE / 2;
68
69 static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
70
71 static void assertArraysStrictlyEquals(short[] r, short[] a) {
72 for (int i = 0; i < a.length; i++) {
73 if (r[i] != a[i]) {
74 Assert.fail("at index #" + i + ", expected = " + a[i] + ", actual = " + r[i]);
75 }
76 }
77 }
78
79 interface FUnOp {
80 short apply(short a);
81 }
82
83 static void assertArraysEquals(short[] r, short[] a, FUnOp f) {
84 int i = 0;
85 try {
86 for (; i < a.length; i++) {
87 Assert.assertEquals(r[i], f.apply(a[i]));
88 }
89 } catch (AssertionError e) {
90 Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);
91 }
92 }
93
94 interface FUnArrayOp {
95 short[] apply(short a);
96 }
97
98 static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) {
99 int i = 0;
100 try {
101 for (; i < a.length; i += SPECIES.length()) {
102 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
103 f.apply(a[i]));
104 }
105 } catch (AssertionError e) {
106 short[] ref = f.apply(a[i]);
107 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
108 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
109 + ", res: " + Arrays.toString(res)
110 + "), at index #" + i);
111 }
112 }
113
114 static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) {
115 int i = 0;
116 try {
117 for (; i < a.length; i++) {
118 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);
119 }
120 } catch (AssertionError e) {
121 Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);
122 }
123 }
124
125 interface FReductionOp {
126 short apply(short[] a, int idx);
127 }
128
129 interface FReductionAllOp {
130 short apply(short[] a);
131 }
132
133 static void assertReductionArraysEquals(short[] r, short rc, short[] a,
134 FReductionOp f, FReductionAllOp fa) {
135 int i = 0;
136 try {
137 Assert.assertEquals(rc, fa.apply(a));
138 for (; i < a.length; i += SPECIES.length()) {
139 Assert.assertEquals(r[i], f.apply(a, i));
140 }
141 } catch (AssertionError e) {
142 Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
143 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
144 }
145 }
146
147 interface FReductionMaskedOp {
148 short apply(short[] a, int idx, boolean[] mask);
149 }
150
151 interface FReductionAllMaskedOp {
152 short apply(short[] a, boolean[] mask);
153 }
154
155 static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask,
156 FReductionMaskedOp f, FReductionAllMaskedOp fa) {
157 int i = 0;
158 try {
159 Assert.assertEquals(rc, fa.apply(a, mask));
160 for (; i < a.length; i += SPECIES.length()) {
161 Assert.assertEquals(r[i], f.apply(a, i, mask));
162 }
163 } catch (AssertionError e) {
164 Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
165 Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
166 }
167 }
168
169 interface FReductionOpLong {
170 long apply(short[] a, int idx);
171 }
172
173 interface FReductionAllOpLong {
174 long apply(short[] a);
175 }
176
177 static void assertReductionLongArraysEquals(long[] r, long rc, short[] a,
178 FReductionOpLong f, FReductionAllOpLong fa) {
179 int i = 0;
180 try {
181 Assert.assertEquals(rc, fa.apply(a));
182 for (; i < a.length; i += SPECIES.length()) {
183 Assert.assertEquals(r[i], f.apply(a, i));
184 }
185 } catch (AssertionError e) {
186 Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");
187 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
188 }
189 }
190
191 interface FReductionMaskedOpLong {
192 long apply(short[] a, int idx, boolean[] mask);
193 }
194
195 interface FReductionAllMaskedOpLong {
196 long apply(short[] a, boolean[] mask);
197 }
198
199 static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask,
200 FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {
201 int i = 0;
202 try {
203 Assert.assertEquals(rc, fa.apply(a, mask));
204 for (; i < a.length; i += SPECIES.length()) {
205 Assert.assertEquals(r[i], f.apply(a, i, mask));
206 }
207 } catch (AssertionError e) {
208 Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");
209 Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);
210 }
211 }
212
213 interface FBoolReductionOp {
214 boolean apply(boolean[] a, int idx);
215 }
216
217 static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {
218 int i = 0;
219 try {
220 for (; i < a.length; i += SPECIES.length()) {
221 Assert.assertEquals(r[i], f.apply(a, i));
222 }
223 } catch (AssertionError e) {
224 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
225 }
226 }
227
228 interface FMaskReductionOp {
229 int apply(boolean[] a, int idx);
230 }
231
232 static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) {
233 int i = 0;
234 try {
235 for (; i < a.length; i += SPECIES.length()) {
236 Assert.assertEquals(r[i], f.apply(a, i));
237 }
238 } catch (AssertionError e) {
239 Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);
240 }
241 }
242
243 static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) {
244 int i = 0, j = 0;
245 try {
246 for (; i < a.length; i += vector_len) {
247 for (j = 0; j < vector_len; j++) {
248 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
249 }
250 }
251 } catch (AssertionError e) {
252 int idx = i + j;
253 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
254 }
255 }
256
257 static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
258 int i = 0, j = 0, k = 0;
259 try {
260 for (; i < a.length; i += vector_len) {
261 k = 0;
262 for (j = 0; j < vector_len; j++) {
263 if (m[(i + j) % SPECIES.length()]) {
264 Assert.assertEquals(r[i + k], a[i + j]);
265 k++;
266 }
267 }
268 for (; k < vector_len; k++) {
269 Assert.assertEquals(r[i + k], (short)0);
270 }
271 }
272 } catch (AssertionError e) {
273 int idx = i + k;
274 if (m[(i + j) % SPECIES.length()]) {
275 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
276 } else {
277 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
278 }
279 }
280 }
281
282 static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
283 int i = 0, j = 0, k = 0;
284 try {
285 for (; i < a.length; i += vector_len) {
286 k = 0;
287 for (j = 0; j < vector_len; j++) {
288 if (m[(i + j) % SPECIES.length()]) {
289 Assert.assertEquals(r[i + j], a[i + k]);
290 k++;
291 } else {
292 Assert.assertEquals(r[i + j], (short)0);
293 }
294 }
295 }
296 } catch (AssertionError e) {
297 int idx = i + j;
298 if (m[idx % SPECIES.length()]) {
299 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
300 } else {
301 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
302 }
303 }
304 }
305
306 static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) {
307 int i = 0, j = 0;
308 boolean is_exceptional_idx = false;
309 int idx = 0, wrapped_index = 0, oidx = 0;
310 try {
311 for (; i < a.length; i += vector_len) {
312 for (j = 0; j < vector_len; j++) {
313 idx = i + j;
314 wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len);
315 is_exceptional_idx = wrapped_index >= vector_len;
316 oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index;
317 Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]));
318 }
319 }
320 } catch (AssertionError e) {
321 Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]);
322 }
323 }
324
325 static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
326 int i = 0, j = 0;
327 try {
328 for (; i < a.length; i += vector_len) {
329 for (j = 0; j < vector_len; j++) {
330 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
331 }
332 }
333 } catch (AssertionError e) {
334 int idx = i + j;
335 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
336 }
337 }
338
339 static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) {
340 int i = 0, j = 0;
341 try {
342 for (; i < a.length; i += vector_len) {
343 for (j = 0; j < vector_len; j++) {
344 if (mask[j % SPECIES.length()])
345 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
346 else
347 Assert.assertEquals(r[i+j], (short)0);
348 }
349 }
350 } catch (AssertionError e) {
351 int idx = i + j;
352 if (mask[j % SPECIES.length()])
353 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
354 else
355 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
356 }
357 }
358
359 static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) {
360 int i = 0, j = 0;
361 try {
362 for (; i < a.length; i += vector_len) {
363 for (j = 0; j < vector_len; j++) {
364 if (mask[j % SPECIES.length()])
365 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
366 else
367 Assert.assertEquals(r[i+j], (short)0);
368 }
369 }
370 } catch (AssertionError e) {
371 int idx = i + j;
372 if (mask[j % SPECIES.length()])
373 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
374 else
375 Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);
376 }
377 }
378
379 static void assertBroadcastArraysEquals(short[] r, short[] a) {
380 int i = 0;
381 for (; i < a.length; i += SPECIES.length()) {
382 int idx = i;
383 for (int j = idx; j < (idx + SPECIES.length()); j++)
384 a[j]=a[idx];
385 }
386
387 try {
388 for (i = 0; i < a.length; i++) {
389 Assert.assertEquals(r[i], a[i]);
390 }
391 } catch (AssertionError e) {
392 Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);
393 }
394 }
395
396 interface FBinOp {
397 short apply(short a, short b);
398 }
399
400 interface FBinMaskOp {
401 short apply(short a, short b, boolean m);
402
403 static FBinMaskOp lift(FBinOp f) {
404 return (a, b, m) -> m ? f.apply(a, b) : a;
405 }
406 }
407
408 static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) {
409 int i = 0;
410 try {
411 for (; i < a.length; i++) {
412 //Left associative
413 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]));
414
415 //Right associative
416 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])));
417
418 //Results equal sanity check
419 Assert.assertEquals(rl[i], rr[i]);
420 }
421 } catch (AssertionError e) {
422 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
423 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
424 Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
425 }
426 }
427
428 static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) {
429 assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f));
430 }
431
432 static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) {
433 int i = 0;
434 boolean mask_bit = false;
435 try {
436 for (; i < a.length; i++) {
437 mask_bit = mask[i % SPECIES.length()];
438 //Left associative
439 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit));
440
441 //Right associative
442 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit));
443
444 //Results equal sanity check
445 Assert.assertEquals(rl[i], rr[i]);
446 }
447 } catch (AssertionError e) {
448 Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
449 Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit);
450 Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]);
451 }
452 }
453
454 static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
455 int i = 0;
456 try {
457 for (; i < a.length; i++) {
458 Assert.assertEquals(r[i], f.apply(a[i], b[i]));
459 }
460 } catch (AssertionError e) {
461 Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
462 }
463 }
464
465 static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) {
466 int i = 0;
467 try {
468 for (; i < a.length; i++) {
469 Assert.assertEquals(r[i], f.apply(a[i], b));
470 }
471 } catch (AssertionError e) {
472 Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i);
473 }
474 }
475
476 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
477 int i = 0;
478 try {
479 for (; i < a.length; i++) {
480 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));
481 }
482 } catch (AssertionError e) {
483 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),
484 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
485 }
486 }
487
488 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
489 int i = 0;
490 try {
491 for (; i < a.length; i++) {
492 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])));
493 }
494 } catch (AssertionError e) {
495 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])),
496 "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);
497 }
498 }
499
500 static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
501 assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
502 }
503
504 static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
505 int i = 0;
506 try {
507 for (; i < a.length; i++) {
508 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));
509 }
510 } catch (AssertionError err) {
511 Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);
512 }
513 }
514
515 static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) {
516 assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
517 }
518
519 static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) {
520 int i = 0;
521 try {
522 for (; i < a.length; i++) {
523 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]));
524 }
525 } catch (AssertionError err) {
526 Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]);
527 }
528 }
529
530 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
531 assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
532 }
533
534 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
535 int i = 0;
536 try {
537 for (; i < a.length; i++) {
538 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
539 }
540 } catch (AssertionError err) {
541 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
542 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
543 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
544 mask[i % SPECIES.length()]);
545 }
546 }
547
548 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
549 assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
550 }
551
552 static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
553 int i = 0;
554 try {
555 for (; i < a.length; i++) {
556 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));
557 }
558 } catch (AssertionError err) {
559 Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]),
560 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
561 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
562 mask[i % SPECIES.length()]);
563 }
564 }
565
566 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) {
567 int i = 0;
568 int j = 0;
569 try {
570 for (; j < a.length; j += SPECIES.length()) {
571 for (i = 0; i < SPECIES.length(); i++) {
572 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));
573 }
574 }
575 } catch (AssertionError e) {
576 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);
577 }
578 }
579
580 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) {
581 assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));
582 }
583
584 static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) {
585 int i = 0;
586 int j = 0;
587 try {
588 for (; j < a.length; j += SPECIES.length()) {
589 for (i = 0; i < SPECIES.length(); i++) {
590 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));
591 }
592 }
593 } catch (AssertionError err) {
594 Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);
595 }
596 }
597
598 interface FBinConstOp {
599 short apply(short a);
600 }
601
602 interface FBinConstMaskOp {
603 short apply(short a, boolean m);
604
605 static FBinConstMaskOp lift(FBinConstOp f) {
606 return (a, m) -> m ? f.apply(a) : a;
607 }
608 }
609
610 static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) {
611 int i = 0;
612 int j = 0;
613 try {
614 for (; j < a.length; j += SPECIES.length()) {
615 for (i = 0; i < SPECIES.length(); i++) {
616 Assert.assertEquals(r[i+j], f.apply(a[i+j]));
617 }
618 }
619 } catch (AssertionError e) {
620 Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j);
621 }
622 }
623
624 static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) {
625 assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f));
626 }
627
628 static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) {
629 int i = 0;
630 int j = 0;
631 try {
632 for (; j < a.length; j += SPECIES.length()) {
633 for (i = 0; i < SPECIES.length(); i++) {
634 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]));
635 }
636 }
637 } catch (AssertionError err) {
638 Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]);
639 }
640 }
641
642 interface FTernOp {
643 short apply(short a, short b, short c);
644 }
645
646 interface FTernMaskOp {
647 short apply(short a, short b, short c, boolean m);
648
649 static FTernMaskOp lift(FTernOp f) {
650 return (a, b, c, m) -> m ? f.apply(a, b, c) : a;
651 }
652 }
653
654 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
655 int i = 0;
656 try {
657 for (; i < a.length; i++) {
658 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));
659 }
660 } catch (AssertionError e) {
661 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);
662 }
663 }
664
665 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) {
666 assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
667 }
668
669 static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) {
670 int i = 0;
671 try {
672 for (; i < a.length; i++) {
673 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));
674 }
675 } catch (AssertionError err) {
676 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "
677 + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
678 }
679 }
680
681 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
682 int i = 0;
683 try {
684 for (; i < a.length; i++) {
685 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));
686 }
687 } catch (AssertionError e) {
688 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +
689 i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +
690 c[(i / SPECIES.length()) * SPECIES.length()]);
691 }
692 }
693
694 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
695 int i = 0;
696 try {
697 for (; i < a.length; i++) {
698 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));
699 }
700 } catch (AssertionError e) {
701 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +
702 i + ", input1 = " + a[i] + ", input2 = " +
703 b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]);
704 }
705 }
706
707 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
708 FTernOp f) {
709 assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
710 }
711
712 static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
713 FTernMaskOp f) {
714 int i = 0;
715 try {
716 for (; i < a.length; i++) {
717 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
718 mask[i % SPECIES.length()]));
719 }
720 } catch (AssertionError err) {
721 Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],
722 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +
723 b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
724 mask[i % SPECIES.length()]);
725 }
726 }
727
728 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
729 FTernOp f) {
730 assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
731 }
732
733 static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
734 FTernMaskOp f) {
735 int i = 0;
736 try {
737 for (; i < a.length; i++) {
738 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
739 mask[i % SPECIES.length()]));
740 }
741 } catch (AssertionError err) {
742 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],
743 mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +
744 ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
745 ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);
746 }
747 }
748
749 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) {
750 int i = 0;
751 try {
752 for (; i < a.length; i++) {
753 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
754 c[(i / SPECIES.length()) * SPECIES.length()]));
755 }
756 } catch (AssertionError e) {
757 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
758 c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]
759 + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +
760 c[(i / SPECIES.length()) * SPECIES.length()]);
761 }
762 }
763
764 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
765 FTernOp f) {
766 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));
767 }
768
769 static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask,
770 FTernMaskOp f) {
771 int i = 0;
772 try {
773 for (; i < a.length; i++) {
774 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
775 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));
776 }
777 } catch (AssertionError err) {
778 Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],
779 c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"
780 + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +
781 ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +
782 mask[i % SPECIES.length()]);
783 }
784 }
785
786
787
788 interface FGatherScatterOp {
789 short[] apply(short[] a, int ix, int[] b, int iy);
790 }
791
792 static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) {
793 int i = 0;
794 try {
795 for (; i < a.length; i += SPECIES.length()) {
796 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
797 f.apply(a, i, b, i));
798 }
799 } catch (AssertionError e) {
800 short[] ref = f.apply(a, i, b, i);
801 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
802 Assert.assertEquals(res, ref,
803 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
804 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
805 + ", b: "
806 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
807 + " at index #" + i);
808 }
809 }
810
811 interface FGatherMaskedOp {
812 short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy);
813 }
814
815 interface FScatterMaskedOp {
816 short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy);
817 }
818
819 static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {
820 int i = 0;
821 try {
822 for (; i < a.length; i += SPECIES.length()) {
823 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
824 f.apply(a, i, mask, b, i));
825 }
826 } catch (AssertionError e) {
827 short[] ref = f.apply(a, i, mask, b, i);
828 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
829 Assert.assertEquals(res, ref,
830 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
831 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
832 + ", b: "
833 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
834 + ", mask: "
835 + Arrays.toString(mask)
836 + " at index #" + i);
837 }
838 }
839
840 static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {
841 int i = 0;
842 try {
843 for (; i < a.length; i += SPECIES.length()) {
844 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
845 f.apply(r, a, i, mask, b, i));
846 }
847 } catch (AssertionError e) {
848 short[] ref = f.apply(r, a, i, mask, b, i);
849 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
850 Assert.assertEquals(res, ref,
851 "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "
852 + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))
853 + ", b: "
854 + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))
855 + ", r: "
856 + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))
857 + ", mask: "
858 + Arrays.toString(mask)
859 + " at index #" + i);
860 }
861 }
862
863 interface FLaneOp {
864 short[] apply(short[] a, int origin, int idx);
865 }
866
867 static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) {
868 int i = 0;
869 try {
870 for (; i < a.length; i += SPECIES.length()) {
871 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
872 f.apply(a, origin, i));
873 }
874 } catch (AssertionError e) {
875 short[] ref = f.apply(a, origin, i);
876 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
877 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
878 + ", res: " + Arrays.toString(res)
879 + "), at index #" + i);
880 }
881 }
882
883 interface FLaneBop {
884 short[] apply(short[] a, short[] b, int origin, int idx);
885 }
886
887 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) {
888 int i = 0;
889 try {
890 for (; i < a.length; i += SPECIES.length()) {
891 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
892 f.apply(a, b, origin, i));
893 }
894 } catch (AssertionError e) {
895 short[] ref = f.apply(a, b, origin, i);
896 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
897 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
898 + ", res: " + Arrays.toString(res)
899 + "), at index #" + i
900 + ", at origin #" + origin);
901 }
902 }
903
904 interface FLaneMaskedBop {
905 short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx);
906 }
907
908 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) {
909 int i = 0;
910 try {
911 for (; i < a.length; i += SPECIES.length()) {
912 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
913 f.apply(a, b, origin, mask, i));
914 }
915 } catch (AssertionError e) {
916 short[] ref = f.apply(a, b, origin, mask, i);
917 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
918 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
919 + ", res: " + Arrays.toString(res)
920 + "), at index #" + i
921 + ", at origin #" + origin);
922 }
923 }
924
925 interface FLanePartBop {
926 short[] apply(short[] a, short[] b, int origin, int part, int idx);
927 }
928
929 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) {
930 int i = 0;
931 try {
932 for (; i < a.length; i += SPECIES.length()) {
933 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
934 f.apply(a, b, origin, part, i));
935 }
936 } catch (AssertionError e) {
937 short[] ref = f.apply(a, b, origin, part, i);
938 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
939 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
940 + ", res: " + Arrays.toString(res)
941 + "), at index #" + i
942 + ", at origin #" + origin
943 + ", with part #" + part);
944 }
945 }
946
947 interface FLanePartMaskedBop {
948 short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx);
949 }
950
951 static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {
952 int i = 0;
953 try {
954 for (; i < a.length; i += SPECIES.length()) {
955 Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),
956 f.apply(a, b, origin, part, mask, i));
957 }
958 } catch (AssertionError e) {
959 short[] ref = f.apply(a, b, origin, part, mask, i);
960 short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());
961 Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)
962 + ", res: " + Arrays.toString(res)
963 + "), at index #" + i
964 + ", at origin #" + origin
965 + ", with part #" + part);
966 }
967 }
968
969
970 static void assertArraysEquals(int[] r, short[] a, int offs) {
971 int i = 0;
972 try {
973 for (; i < r.length; i++) {
974 Assert.assertEquals(r[i], (int)(a[i+offs]));
975 }
976 } catch (AssertionError e) {
977 Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
978 }
979 }
980
981
982
983 static void assertArraysEquals(long[] r, short[] a, int offs) {
984 int i = 0;
985 try {
986 for (; i < r.length; i++) {
987 Assert.assertEquals(r[i], (long)(a[i+offs]));
988 }
989 } catch (AssertionError e) {
990 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
991 }
992 }
993
994 static void assertArraysEquals(double[] r, short[] a, int offs) {
995 int i = 0;
996 try {
997 for (; i < r.length; i++) {
998 Assert.assertEquals(r[i], (double)(a[i+offs]));
999 }
1000 } catch (AssertionError e) {
1001 Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
1002 }
1003 }
1004
1005 static short bits(short e) {
1006 return e;
1007 }
1008
1009 static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
1010 withToString("short[-i * 5]", (int s) -> {
1011 return fill(s * BUFFER_REPS,
1012 i -> (short)(-i * 5));
1013 }),
1014 withToString("short[i * 5]", (int s) -> {
1015 return fill(s * BUFFER_REPS,
1016 i -> (short)(i * 5));
1017 }),
1018 withToString("short[i + 1]", (int s) -> {
1019 return fill(s * BUFFER_REPS,
1020 i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1)));
1021 }),
1022 withToString("short[cornerCaseValue(i)]", (int s) -> {
1023 return fill(s * BUFFER_REPS,
1024 i -> cornerCaseValue(i));
1025 })
1026 );
1027
1028 static final List<IntFunction<short[]>> SHORT_SATURATING_GENERATORS = List.of(
1029 withToString("short[Short.MIN_VALUE]", (int s) -> {
1030 return fill(s * BUFFER_REPS,
1031 i -> (short)(Short.MIN_VALUE));
1032 }),
1033 withToString("short[Short.MAX_VALUE]", (int s) -> {
1034 return fill(s * BUFFER_REPS,
1035 i -> (short)(Short.MAX_VALUE));
1036 }),
1037 withToString("short[Short.MAX_VALUE - 100]", (int s) -> {
1038 return fill(s * BUFFER_REPS,
1039 i -> (short)(Short.MAX_VALUE - 100));
1040 }),
1041 withToString("short[Short.MIN_VALUE + 100]", (int s) -> {
1042 return fill(s * BUFFER_REPS,
1043 i -> (short)(Short.MIN_VALUE + 100));
1044 }),
1045 withToString("short[-i * 5]", (int s) -> {
1046 return fill(s * BUFFER_REPS,
1047 i -> (short)(-i * 5));
1048 }),
1049 withToString("short[i * 5]", (int s) -> {
1050 return fill(s * BUFFER_REPS,
1051 i -> (short)(i * 5));
1052 })
1053 );
1054
1055 static final List<IntFunction<short[]>> SHORT_SATURATING_GENERATORS_ASSOC = List.of(
1056 withToString("short[Short.MAX_VALUE]", (int s) -> {
1057 return fill(s * BUFFER_REPS,
1058 i -> (short)(Short.MAX_VALUE));
1059 }),
1060 withToString("short[Short.MAX_VALUE - 100]", (int s) -> {
1061 return fill(s * BUFFER_REPS,
1062 i -> (short)(Short.MAX_VALUE - 100));
1063 }),
1064 withToString("short[-1]", (int s) -> {
1065 return fill(s * BUFFER_REPS,
1066 i -> (short)(-1));
1067 })
1068 );
1069
1070 // Create combinations of pairs
1071 // @@@ Might be sensitive to order e.g. div by 0
1072 static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_PAIRS =
1073 Stream.of(SHORT_GENERATORS.get(0)).
1074 flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1075 collect(Collectors.toList());
1076
1077 static final List<List<IntFunction<short[]>>> SHORT_SATURATING_GENERATOR_PAIRS =
1078 Stream.of(SHORT_GENERATORS.get(0)).
1079 flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).
1080 collect(Collectors.toList());
1081
1082 static final List<List<IntFunction<short[]>>> SHORT_SATURATING_GENERATOR_TRIPLETS =
1083 Stream.of(SHORT_GENERATORS.get(1))
1084 .flatMap(fa -> SHORT_SATURATING_GENERATORS_ASSOC.stream().map(fb -> List.of(fa, fb)))
1085 .flatMap(pair -> SHORT_SATURATING_GENERATORS_ASSOC.stream().map(f -> List.of(pair.get(0), pair.get(1), f)))
1086 .collect(Collectors.toList());
1087
1088 @DataProvider
1089 public Object[][] boolUnaryOpProvider() {
1090 return BOOL_ARRAY_GENERATORS.stream().
1091 map(f -> new Object[]{f}).
1092 toArray(Object[][]::new);
1093 }
1094
1095 static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_TRIPLES =
1096 SHORT_GENERATOR_PAIRS.stream().
1097 flatMap(pair -> SHORT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1098 collect(Collectors.toList());
1099
1100 static final List<IntFunction<short[]>> SELECT_FROM_INDEX_GENERATORS = List.of(
1101 withToString("short[0..VECLEN*2)", (int s) -> {
1102 return fill(s * BUFFER_REPS,
1103 i -> (short)(RAND.nextInt()));
1104 })
1105 );
1106
1107 static final List<List<IntFunction<short[]>>> SHORT_GENERATOR_SELECT_FROM_TRIPLES =
1108 SHORT_GENERATOR_PAIRS.stream().
1109 flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).
1110 collect(Collectors.toList());
1111
1112 @DataProvider
1113 public Object[][] shortBinaryOpProvider() {
1114 return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
1115 toArray(Object[][]::new);
1116 }
1117
1118 @DataProvider
1119 public Object[][] shortSaturatingBinaryOpProvider() {
1120 return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray).
1121 toArray(Object[][]::new);
1122 }
1123
1124 @DataProvider
1125 public Object[][] shortSaturatingBinaryOpAssocProvider() {
1126 return SHORT_SATURATING_GENERATOR_TRIPLETS.stream().map(List::toArray).
1127 toArray(Object[][]::new);
1128 }
1129
1130 @DataProvider
1131 public Object[][] shortSaturatingBinaryOpAssocMaskProvider() {
1132 return BOOLEAN_MASK_GENERATORS.stream().
1133 flatMap(fm -> SHORT_SATURATING_GENERATOR_TRIPLETS.stream().map(lfa -> {
1134 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1135 })).
1136 toArray(Object[][]::new);
1137 }
1138
1139
1140 @DataProvider
1141 public Object[][] shortIndexedOpProvider() {
1142 return SHORT_GENERATOR_PAIRS.stream().map(List::toArray).
1143 toArray(Object[][]::new);
1144 }
1145
1146 @DataProvider
1147 public Object[][] shortSaturatingBinaryOpMaskProvider() {
1148 return BOOLEAN_MASK_GENERATORS.stream().
1149 flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> {
1150 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1151 })).
1152 toArray(Object[][]::new);
1153 }
1154
1155 @DataProvider
1156 public Object[][] shortSaturatingUnaryOpProvider() {
1157 return SHORT_SATURATING_GENERATORS.stream().
1158 map(f -> new Object[]{f}).
1159 toArray(Object[][]::new);
1160 }
1161
1162 @DataProvider
1163 public Object[][] shortSaturatingUnaryOpMaskProvider() {
1164 return BOOLEAN_MASK_GENERATORS.stream().
1165 flatMap(fm -> SHORT_SATURATING_GENERATORS.stream().map(fa -> {
1166 return new Object[] {fa, fm};
1167 })).
1168 toArray(Object[][]::new);
1169 }
1170
1171 @DataProvider
1172 public Object[][] shortBinaryOpMaskProvider() {
1173 return BOOLEAN_MASK_GENERATORS.stream().
1174 flatMap(fm -> SHORT_GENERATOR_PAIRS.stream().map(lfa -> {
1175 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1176 })).
1177 toArray(Object[][]::new);
1178 }
1179
1180 @DataProvider
1181 public Object[][] shortTernaryOpProvider() {
1182 return SHORT_GENERATOR_TRIPLES.stream().map(List::toArray).
1183 toArray(Object[][]::new);
1184 }
1185
1186 @DataProvider
1187 public Object[][] shortSelectFromTwoVectorOpProvider() {
1188 return SHORT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray).
1189 toArray(Object[][]::new);
1190 }
1191
1192 @DataProvider
1193 public Object[][] shortTernaryOpMaskProvider() {
1194 return BOOLEAN_MASK_GENERATORS.stream().
1195 flatMap(fm -> SHORT_GENERATOR_TRIPLES.stream().map(lfa -> {
1196 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1197 })).
1198 toArray(Object[][]::new);
1199 }
1200
1201 @DataProvider
1202 public Object[][] shortUnaryOpProvider() {
1203 return SHORT_GENERATORS.stream().
1204 map(f -> new Object[]{f}).
1205 toArray(Object[][]::new);
1206 }
1207
1208 @DataProvider
1209 public Object[][] shortUnaryOpMaskProvider() {
1210 return BOOLEAN_MASK_GENERATORS.stream().
1211 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> {
1212 return new Object[] {fa, fm};
1213 })).
1214 toArray(Object[][]::new);
1215 }
1216
1217 @DataProvider
1218 public Object[][] maskProvider() {
1219 return BOOLEAN_MASK_GENERATORS.stream().
1220 map(f -> new Object[]{f}).
1221 toArray(Object[][]::new);
1222 }
1223
1224 @DataProvider
1225 public Object[][] maskCompareOpProvider() {
1226 return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1227 toArray(Object[][]::new);
1228 }
1229
1230 @DataProvider
1231 public Object[][] shuffleProvider() {
1232 return INT_SHUFFLE_GENERATORS.stream().
1233 map(f -> new Object[]{f}).
1234 toArray(Object[][]::new);
1235 }
1236
1237 @DataProvider
1238 public Object[][] shuffleCompareOpProvider() {
1239 return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1240 toArray(Object[][]::new);
1241 }
1242
1243 @DataProvider
1244 public Object[][] shortUnaryOpShuffleProvider() {
1245 return INT_SHUFFLE_GENERATORS.stream().
1246 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1247 return new Object[] {fa, fs};
1248 })).
1249 toArray(Object[][]::new);
1250 }
1251
1252 @DataProvider
1253 public Object[][] shortUnaryOpShuffleMaskProvider() {
1254 return BOOLEAN_MASK_GENERATORS.stream().
1255 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1256 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1257 return new Object[] {fa, fs, fm};
1258 }))).
1259 toArray(Object[][]::new);
1260 }
1261
1262 static final List<BiFunction<Integer,Integer,short[]>> SHORT_SHUFFLE_GENERATORS = List.of(
1263 withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
1264 short[] a = new short[l];
1265 int upper = m;
1266 for (int i = 0; i < 1; i++) {
1267 a[i] = (short)RAND.nextInt(upper);
1268 }
1269 return a;
1270 })
1271 );
1272
1273 @DataProvider
1274 public Object[][] shortUnaryOpSelectFromProvider() {
1275 return SHORT_SHUFFLE_GENERATORS.stream().
1276 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1277 return new Object[] {fa, fs};
1278 })).
1279 toArray(Object[][]::new);
1280 }
1281
1282 @DataProvider
1283 public Object[][] shortUnaryOpSelectFromMaskProvider() {
1284 return BOOLEAN_MASK_GENERATORS.stream().
1285 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream().
1286 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1287 return new Object[] {fa, fs, fm};
1288 }))).
1289 toArray(Object[][]::new);
1290 }
1291
1292 static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
1293 withToString("short[i]", (int s) -> {
1294 return fill(s * BUFFER_REPS,
1295 i -> (short)i);
1296 }),
1297 withToString("short[i - length / 2]", (int s) -> {
1298 return fill(s * BUFFER_REPS,
1299 i -> (short)(i - (s * BUFFER_REPS / 2)));
1300 }),
1301 withToString("short[i + 1]", (int s) -> {
1302 return fill(s * BUFFER_REPS,
1303 i -> (short)(i + 1));
1304 }),
1305 withToString("short[i - 2]", (int s) -> {
1306 return fill(s * BUFFER_REPS,
1307 i -> (short)(i - 2));
1308 }),
1309 withToString("short[zigZag(i)]", (int s) -> {
1310 return fill(s * BUFFER_REPS,
1311 i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2)));
1312 }),
1313 withToString("short[cornerCaseValue(i)]", (int s) -> {
1314 return fill(s * BUFFER_REPS,
1315 i -> cornerCaseValue(i));
1316 })
1317 );
1318
1319 static final List<List<IntFunction<short[]>>> SHORT_TEST_GENERATOR_ARGS =
1320 SHORT_COMPARE_GENERATORS.stream().
1321 map(fa -> List.of(fa)).
1322 collect(Collectors.toList());
1323
1324 @DataProvider
1325 public Object[][] shortTestOpProvider() {
1326 return SHORT_TEST_GENERATOR_ARGS.stream().map(List::toArray).
1327 toArray(Object[][]::new);
1328 }
1329
1330 @DataProvider
1331 public Object[][] shortTestOpMaskProvider() {
1332 return BOOLEAN_MASK_GENERATORS.stream().
1333 flatMap(fm -> SHORT_TEST_GENERATOR_ARGS.stream().map(lfa -> {
1334 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1335 })).
1336 toArray(Object[][]::new);
1337 }
1338
1339 static final List<List<IntFunction<short[]>>> SHORT_COMPARE_GENERATOR_PAIRS =
1340 SHORT_COMPARE_GENERATORS.stream().
1341 flatMap(fa -> SHORT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).
1342 collect(Collectors.toList());
1343
1344 @DataProvider
1345 public Object[][] shortCompareOpProvider() {
1346 return SHORT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1347 toArray(Object[][]::new);
1348 }
1349
1350 @DataProvider
1351 public Object[][] shortCompareOpMaskProvider() {
1352 return BOOLEAN_MASK_GENERATORS.stream().
1353 flatMap(fm -> SHORT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {
1354 return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
1355 })).
1356 toArray(Object[][]::new);
1357 }
1358
1359 interface ToShortF {
1360 short apply(int i);
1361 }
1362
1363 static short[] fill(int s , ToShortF f) {
1364 return fill(new short[s], f);
1365 }
1366
1367 static short[] fill(short[] a, ToShortF f) {
1368 for (int i = 0; i < a.length; i++) {
1369 a[i] = f.apply(i);
1370 }
1371 return a;
1372 }
1373
1374 static short cornerCaseValue(int i) {
1375 switch(i % 5) {
1376 case 0:
1377 return Short.MAX_VALUE;
1378 case 1:
1379 return Short.MIN_VALUE;
1380 case 2:
1381 return Short.MIN_VALUE;
1382 case 3:
1383 return Short.MAX_VALUE;
1384 default:
1385 return (short)0;
1386 }
1387 }
1388
1389 static final IntFunction<short[]> fr = (vl) -> {
1390 int length = BUFFER_REPS * vl;
1391 return new short[length];
1392 };
1393
1394 static final IntFunction<boolean[]> fmr = (vl) -> {
1395 int length = BUFFER_REPS * vl;
1396 return new boolean[length];
1397 };
1398
1399 static final IntFunction<long[]> lfr = (vl) -> {
1400 int length = BUFFER_REPS * vl;
1401 return new long[length];
1402 };
1403
1404 static void replaceZero(short[] a, short v) {
1405 for (int i = 0; i < a.length; i++) {
1406 if (a[i] == 0) {
1407 a[i] = v;
1408 }
1409 }
1410 }
1411
1412 static void replaceZero(short[] a, boolean[] mask, short v) {
1413 for (int i = 0; i < a.length; i++) {
1414 if (mask[i % mask.length] && a[i] == 0) {
1415 a[i] = v;
1416 }
1417 }
1418 }
1419
1420 static short ROL_scalar(short a, short b) {
1421 return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15))));
1422 }
1423
1424 static short ROR_scalar(short a, short b) {
1425 return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
1426 }
1427
1428 static short TRAILING_ZEROS_COUNT_scalar(short a) {
1429 return (short) (a != 0 ? Integer.numberOfTrailingZeros(a) : 16);
1430 }
1431
1432 static short LEADING_ZEROS_COUNT_scalar(short a) {
1433 return (short) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 16 : 0);
1434 }
1435
1436 static short REVERSE_scalar(short a) {
1437 short b = ROL_scalar(a, (short) 8);
1438 b = (short) (((b & 0x5555) << 1) | ((b & 0xAAAA) >>> 1));
1439 b = (short) (((b & 0x3333) << 2) | ((b & 0xCCCC) >>> 2));
1440 b = (short) (((b & 0x0F0F) << 4) | ((b & 0xF0F0) >>> 4));
1441 return b;
1442 }
1443
1444 static boolean eq(short a, short b) {
1445 return a == b;
1446 }
1447
1448 static boolean neq(short a, short b) {
1449 return a != b;
1450 }
1451
1452 static boolean lt(short a, short b) {
1453 return a < b;
1454 }
1455
1456 static boolean le(short a, short b) {
1457 return a <= b;
1458 }
1459
1460 static boolean gt(short a, short b) {
1461 return a > b;
1462 }
1463
1464 static boolean ge(short a, short b) {
1465 return a >= b;
1466 }
1467
1468 static boolean ult(short a, short b) {
1469 return Short.compareUnsigned(a, b) < 0;
1470 }
1471
1472 static boolean ule(short a, short b) {
1473 return Short.compareUnsigned(a, b) <= 0;
1474 }
1475
1476 static boolean ugt(short a, short b) {
1477 return Short.compareUnsigned(a, b) > 0;
1478 }
1479
1480 static boolean uge(short a, short b) {
1481 return Short.compareUnsigned(a, b) >= 0;
1482 }
1483
1484 static short firstNonZero(short a, short b) {
1485 return Short.compare(a, (short) 0) != 0 ? a : b;
1486 }
1487
1488 @Test
1489 static void smokeTest1() {
1490 ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3);
1491 ShortVector three2 = (ShortVector) SPECIES.broadcast(-3);
1492 assert(three.eq(three2).allTrue());
1493 ShortVector three3 = three2.broadcast(1).broadcast(-3);
1494 assert(three.eq(three3).allTrue());
1495 int scale = 2;
1496 Class<?> ETYPE = short.class;
1497 if (ETYPE == double.class || ETYPE == long.class)
1498 scale = 1000000;
1499 else if (ETYPE == byte.class && SPECIES.length() >= 64)
1500 scale = 1;
1501 ShortVector higher = three.addIndex(scale);
1502 VectorMask<Short> m = three.compare(VectorOperators.LE, higher);
1503 assert(m.allTrue());
1504 m = higher.min((short)-1).test(VectorOperators.IS_NEGATIVE);
1505 assert(m.allTrue());
1506 short max = higher.reduceLanes(VectorOperators.MAX);
1507 assert(max == -3 + scale * (SPECIES.length()-1));
1508 }
1509
1510 private static short[]
1511 bothToArray(ShortVector a, ShortVector b) {
1512 short[] r = new short[a.length() + b.length()];
1513 a.intoArray(r, 0);
1514 b.intoArray(r, a.length());
1515 return r;
1516 }
1517
1518 @Test
1519 static void smokeTest2() {
1520 // Do some zipping and shuffling.
1521 ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1522 ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();
1523 Assert.assertEquals(io, io2);
1524 ShortVector a = io.add((short)1); //[1,2]
1525 ShortVector b = a.neg(); //[-1,-2]
1526 short[] abValues = bothToArray(a,b); //[1,2,-1,-2]
1527 VectorShuffle<Short> zip0 = VectorShuffle.makeZip(SPECIES, 0);
1528 VectorShuffle<Short> zip1 = VectorShuffle.makeZip(SPECIES, 1);
1529 ShortVector zab0 = a.rearrange(zip0,b); //[1,-1]
1530 ShortVector zab1 = a.rearrange(zip1,b); //[2,-2]
1531 short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]
1532 // manually zip
1533 short[] manual = new short[zabValues.length];
1534 for (int i = 0; i < manual.length; i += 2) {
1535 manual[i+0] = abValues[i/2];
1536 manual[i+1] = abValues[a.length() + i/2];
1537 }
1538 Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));
1539 VectorShuffle<Short> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);
1540 VectorShuffle<Short> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);
1541 ShortVector uab0 = zab0.rearrange(unz0,zab1);
1542 ShortVector uab1 = zab0.rearrange(unz1,zab1);
1543 short[] abValues1 = bothToArray(uab0, uab1);
1544 Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));
1545 }
1546
1547 static void iotaShuffle() {
1548 ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1549 ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();
1550 Assert.assertEquals(io, io2);
1551 }
1552
1553 @Test
1554 // Test all shuffle related operations.
1555 static void shuffleTest() {
1556 // To test backend instructions, make sure that C2 is used.
1557 for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {
1558 iotaShuffle();
1559 }
1560 }
1561
1562 @Test
1563 void viewAsIntegeralLanesTest() {
1564 Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();
1565 Assert.assertEquals(asIntegral.species(), SPECIES);
1566 }
1567
1568 @Test(expectedExceptions = UnsupportedOperationException.class)
1569 void viewAsFloatingLanesTest() {
1570 SPECIES.zero().viewAsFloatingLanes();
1571 }
1572
1573 @Test
1574 // Test div by 0.
1575 static void bitwiseDivByZeroSmokeTest() {
1576 try {
1577 ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1578 ShortVector b = (ShortVector) SPECIES.broadcast(0);
1579 a.div(b);
1580 Assert.fail();
1581 } catch (ArithmeticException e) {
1582 }
1583
1584 try {
1585 ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1586 ShortVector b = (ShortVector) SPECIES.broadcast(0);
1587 VectorMask<Short> m = a.lt((short) 1);
1588 a.div(b, m);
1589 Assert.fail();
1590 } catch (ArithmeticException e) {
1591 }
1592 }
1593
1594 static short ADD(short a, short b) {
1595 return (short)(a + b);
1596 }
1597
1598 @Test(dataProvider = "shortBinaryOpProvider")
1599 static void ADDShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1600 short[] a = fa.apply(SPECIES.length());
1601 short[] b = fb.apply(SPECIES.length());
1602 short[] r = fr.apply(SPECIES.length());
1603
1604 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1605 for (int i = 0; i < a.length; i += SPECIES.length()) {
1606 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1607 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1608 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1609 }
1610 }
1611
1612 assertArraysEquals(r, a, b, Short64VectorTests::ADD);
1613 }
1614
1615 static short add(short a, short b) {
1616 return (short)(a + b);
1617 }
1618
1619 @Test(dataProvider = "shortBinaryOpProvider")
1620 static void addShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1621 short[] a = fa.apply(SPECIES.length());
1622 short[] b = fb.apply(SPECIES.length());
1623 short[] r = fr.apply(SPECIES.length());
1624
1625 for (int i = 0; i < a.length; i += SPECIES.length()) {
1626 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1627 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1628 av.add(bv).intoArray(r, i);
1629 }
1630
1631 assertArraysEquals(r, a, b, Short64VectorTests::add);
1632 }
1633
1634 @Test(dataProvider = "shortBinaryOpMaskProvider")
1635 static void ADDShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1636 IntFunction<boolean[]> fm) {
1637 short[] a = fa.apply(SPECIES.length());
1638 short[] b = fb.apply(SPECIES.length());
1639 short[] r = fr.apply(SPECIES.length());
1640 boolean[] mask = fm.apply(SPECIES.length());
1641 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1642
1643 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1644 for (int i = 0; i < a.length; i += SPECIES.length()) {
1645 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1646 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1647 av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);
1648 }
1649 }
1650
1651 assertArraysEquals(r, a, b, mask, Short64VectorTests::ADD);
1652 }
1653
1654 @Test(dataProvider = "shortBinaryOpMaskProvider")
1655 static void addShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1656 IntFunction<boolean[]> fm) {
1657 short[] a = fa.apply(SPECIES.length());
1658 short[] b = fb.apply(SPECIES.length());
1659 short[] r = fr.apply(SPECIES.length());
1660 boolean[] mask = fm.apply(SPECIES.length());
1661 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1662
1663 for (int i = 0; i < a.length; i += SPECIES.length()) {
1664 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1665 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1666 av.add(bv, vmask).intoArray(r, i);
1667 }
1668
1669 assertArraysEquals(r, a, b, mask, Short64VectorTests::add);
1670 }
1671
1672 static short SUB(short a, short b) {
1673 return (short)(a - b);
1674 }
1675
1676 @Test(dataProvider = "shortBinaryOpProvider")
1677 static void SUBShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1678 short[] a = fa.apply(SPECIES.length());
1679 short[] b = fb.apply(SPECIES.length());
1680 short[] r = fr.apply(SPECIES.length());
1681
1682 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1683 for (int i = 0; i < a.length; i += SPECIES.length()) {
1684 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1685 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1686 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1687 }
1688 }
1689
1690 assertArraysEquals(r, a, b, Short64VectorTests::SUB);
1691 }
1692
1693 static short sub(short a, short b) {
1694 return (short)(a - b);
1695 }
1696
1697 @Test(dataProvider = "shortBinaryOpProvider")
1698 static void subShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1699 short[] a = fa.apply(SPECIES.length());
1700 short[] b = fb.apply(SPECIES.length());
1701 short[] r = fr.apply(SPECIES.length());
1702
1703 for (int i = 0; i < a.length; i += SPECIES.length()) {
1704 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1705 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1706 av.sub(bv).intoArray(r, i);
1707 }
1708
1709 assertArraysEquals(r, a, b, Short64VectorTests::sub);
1710 }
1711
1712 @Test(dataProvider = "shortBinaryOpMaskProvider")
1713 static void SUBShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1714 IntFunction<boolean[]> fm) {
1715 short[] a = fa.apply(SPECIES.length());
1716 short[] b = fb.apply(SPECIES.length());
1717 short[] r = fr.apply(SPECIES.length());
1718 boolean[] mask = fm.apply(SPECIES.length());
1719 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1720
1721 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1722 for (int i = 0; i < a.length; i += SPECIES.length()) {
1723 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1724 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1725 av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);
1726 }
1727 }
1728
1729 assertArraysEquals(r, a, b, mask, Short64VectorTests::SUB);
1730 }
1731
1732 @Test(dataProvider = "shortBinaryOpMaskProvider")
1733 static void subShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1734 IntFunction<boolean[]> fm) {
1735 short[] a = fa.apply(SPECIES.length());
1736 short[] b = fb.apply(SPECIES.length());
1737 short[] r = fr.apply(SPECIES.length());
1738 boolean[] mask = fm.apply(SPECIES.length());
1739 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1740
1741 for (int i = 0; i < a.length; i += SPECIES.length()) {
1742 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1743 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1744 av.sub(bv, vmask).intoArray(r, i);
1745 }
1746
1747 assertArraysEquals(r, a, b, mask, Short64VectorTests::sub);
1748 }
1749
1750 static short MUL(short a, short b) {
1751 return (short)(a * b);
1752 }
1753
1754 @Test(dataProvider = "shortBinaryOpProvider")
1755 static void MULShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1756 short[] a = fa.apply(SPECIES.length());
1757 short[] b = fb.apply(SPECIES.length());
1758 short[] r = fr.apply(SPECIES.length());
1759
1760 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1761 for (int i = 0; i < a.length; i += SPECIES.length()) {
1762 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1763 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1764 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1765 }
1766 }
1767
1768 assertArraysEquals(r, a, b, Short64VectorTests::MUL);
1769 }
1770
1771 static short mul(short a, short b) {
1772 return (short)(a * b);
1773 }
1774
1775 @Test(dataProvider = "shortBinaryOpProvider")
1776 static void mulShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1777 short[] a = fa.apply(SPECIES.length());
1778 short[] b = fb.apply(SPECIES.length());
1779 short[] r = fr.apply(SPECIES.length());
1780
1781 for (int i = 0; i < a.length; i += SPECIES.length()) {
1782 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1783 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1784 av.mul(bv).intoArray(r, i);
1785 }
1786
1787 assertArraysEquals(r, a, b, Short64VectorTests::mul);
1788 }
1789
1790 @Test(dataProvider = "shortBinaryOpMaskProvider")
1791 static void MULShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1792 IntFunction<boolean[]> fm) {
1793 short[] a = fa.apply(SPECIES.length());
1794 short[] b = fb.apply(SPECIES.length());
1795 short[] r = fr.apply(SPECIES.length());
1796 boolean[] mask = fm.apply(SPECIES.length());
1797 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1798
1799 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1800 for (int i = 0; i < a.length; i += SPECIES.length()) {
1801 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1802 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1803 av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);
1804 }
1805 }
1806
1807 assertArraysEquals(r, a, b, mask, Short64VectorTests::MUL);
1808 }
1809
1810 @Test(dataProvider = "shortBinaryOpMaskProvider")
1811 static void mulShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1812 IntFunction<boolean[]> fm) {
1813 short[] a = fa.apply(SPECIES.length());
1814 short[] b = fb.apply(SPECIES.length());
1815 short[] r = fr.apply(SPECIES.length());
1816 boolean[] mask = fm.apply(SPECIES.length());
1817 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1818
1819 for (int i = 0; i < a.length; i += SPECIES.length()) {
1820 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1821 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1822 av.mul(bv, vmask).intoArray(r, i);
1823 }
1824
1825 assertArraysEquals(r, a, b, mask, Short64VectorTests::mul);
1826 }
1827
1828 static short DIV(short a, short b) {
1829 return (short)(a / b);
1830 }
1831
1832 @Test(dataProvider = "shortBinaryOpProvider")
1833 static void DIVShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1834 short[] a = fa.apply(SPECIES.length());
1835 short[] b = fb.apply(SPECIES.length());
1836 short[] r = fr.apply(SPECIES.length());
1837
1838 replaceZero(b, (short) 1);
1839
1840 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1841 for (int i = 0; i < a.length; i += SPECIES.length()) {
1842 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1843 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1844 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1845 }
1846 }
1847
1848 assertArraysEquals(r, a, b, Short64VectorTests::DIV);
1849 }
1850
1851 static short div(short a, short b) {
1852 return (short)(a / b);
1853 }
1854
1855 @Test(dataProvider = "shortBinaryOpProvider")
1856 static void divShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1857 short[] a = fa.apply(SPECIES.length());
1858 short[] b = fb.apply(SPECIES.length());
1859 short[] r = fr.apply(SPECIES.length());
1860
1861 replaceZero(b, (short) 1);
1862
1863 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1864 for (int i = 0; i < a.length; i += SPECIES.length()) {
1865 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1866 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1867 av.div(bv).intoArray(r, i);
1868 }
1869 }
1870
1871 assertArraysEquals(r, a, b, Short64VectorTests::div);
1872 }
1873
1874 @Test(dataProvider = "shortBinaryOpMaskProvider")
1875 static void DIVShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1876 IntFunction<boolean[]> fm) {
1877 short[] a = fa.apply(SPECIES.length());
1878 short[] b = fb.apply(SPECIES.length());
1879 short[] r = fr.apply(SPECIES.length());
1880 boolean[] mask = fm.apply(SPECIES.length());
1881 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1882
1883 replaceZero(b, mask, (short) 1);
1884
1885 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1886 for (int i = 0; i < a.length; i += SPECIES.length()) {
1887 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1888 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1889 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1890 }
1891 }
1892
1893 assertArraysEquals(r, a, b, mask, Short64VectorTests::DIV);
1894 }
1895
1896 @Test(dataProvider = "shortBinaryOpMaskProvider")
1897 static void divShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1898 IntFunction<boolean[]> fm) {
1899 short[] a = fa.apply(SPECIES.length());
1900 short[] b = fb.apply(SPECIES.length());
1901 short[] r = fr.apply(SPECIES.length());
1902 boolean[] mask = fm.apply(SPECIES.length());
1903 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1904
1905 replaceZero(b, mask, (short) 1);
1906
1907 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1908 for (int i = 0; i < a.length; i += SPECIES.length()) {
1909 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1910 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1911 av.div(bv, vmask).intoArray(r, i);
1912 }
1913 }
1914
1915 assertArraysEquals(r, a, b, mask, Short64VectorTests::div);
1916 }
1917
1918 static short FIRST_NONZERO(short a, short b) {
1919 return (short)((a)!=0?a:b);
1920 }
1921
1922 @Test(dataProvider = "shortBinaryOpProvider")
1923 static void FIRST_NONZEROShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1924 short[] a = fa.apply(SPECIES.length());
1925 short[] b = fb.apply(SPECIES.length());
1926 short[] r = fr.apply(SPECIES.length());
1927
1928 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1929 for (int i = 0; i < a.length; i += SPECIES.length()) {
1930 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1931 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1932 av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);
1933 }
1934 }
1935
1936 assertArraysEquals(r, a, b, Short64VectorTests::FIRST_NONZERO);
1937 }
1938
1939 @Test(dataProvider = "shortBinaryOpMaskProvider")
1940 static void FIRST_NONZEROShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1941 IntFunction<boolean[]> fm) {
1942 short[] a = fa.apply(SPECIES.length());
1943 short[] b = fb.apply(SPECIES.length());
1944 short[] r = fr.apply(SPECIES.length());
1945 boolean[] mask = fm.apply(SPECIES.length());
1946 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1947
1948 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1949 for (int i = 0; i < a.length; i += SPECIES.length()) {
1950 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1951 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1952 av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);
1953 }
1954 }
1955
1956 assertArraysEquals(r, a, b, mask, Short64VectorTests::FIRST_NONZERO);
1957 }
1958
1959 static short AND(short a, short b) {
1960 return (short)(a & b);
1961 }
1962
1963 @Test(dataProvider = "shortBinaryOpProvider")
1964 static void ANDShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1965 short[] a = fa.apply(SPECIES.length());
1966 short[] b = fb.apply(SPECIES.length());
1967 short[] r = fr.apply(SPECIES.length());
1968
1969 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1970 for (int i = 0; i < a.length; i += SPECIES.length()) {
1971 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1972 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1973 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1974 }
1975 }
1976
1977 assertArraysEquals(r, a, b, Short64VectorTests::AND);
1978 }
1979
1980 static short and(short a, short b) {
1981 return (short)(a & b);
1982 }
1983
1984 @Test(dataProvider = "shortBinaryOpProvider")
1985 static void andShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1986 short[] a = fa.apply(SPECIES.length());
1987 short[] b = fb.apply(SPECIES.length());
1988 short[] r = fr.apply(SPECIES.length());
1989
1990 for (int i = 0; i < a.length; i += SPECIES.length()) {
1991 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1992 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1993 av.and(bv).intoArray(r, i);
1994 }
1995
1996 assertArraysEquals(r, a, b, Short64VectorTests::and);
1997 }
1998
1999 @Test(dataProvider = "shortBinaryOpMaskProvider")
2000 static void ANDShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2001 IntFunction<boolean[]> fm) {
2002 short[] a = fa.apply(SPECIES.length());
2003 short[] b = fb.apply(SPECIES.length());
2004 short[] r = fr.apply(SPECIES.length());
2005 boolean[] mask = fm.apply(SPECIES.length());
2006 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2007
2008 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2009 for (int i = 0; i < a.length; i += SPECIES.length()) {
2010 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2011 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2012 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
2013 }
2014 }
2015
2016 assertArraysEquals(r, a, b, mask, Short64VectorTests::AND);
2017 }
2018
2019 static short AND_NOT(short a, short b) {
2020 return (short)(a & ~b);
2021 }
2022
2023 @Test(dataProvider = "shortBinaryOpProvider")
2024 static void AND_NOTShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2025 short[] a = fa.apply(SPECIES.length());
2026 short[] b = fb.apply(SPECIES.length());
2027 short[] r = fr.apply(SPECIES.length());
2028
2029 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2030 for (int i = 0; i < a.length; i += SPECIES.length()) {
2031 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2032 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2033 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
2034 }
2035 }
2036
2037 assertArraysEquals(r, a, b, Short64VectorTests::AND_NOT);
2038 }
2039
2040 @Test(dataProvider = "shortBinaryOpMaskProvider")
2041 static void AND_NOTShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2042 IntFunction<boolean[]> fm) {
2043 short[] a = fa.apply(SPECIES.length());
2044 short[] b = fb.apply(SPECIES.length());
2045 short[] r = fr.apply(SPECIES.length());
2046 boolean[] mask = fm.apply(SPECIES.length());
2047 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2048
2049 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2050 for (int i = 0; i < a.length; i += SPECIES.length()) {
2051 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2052 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2053 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
2054 }
2055 }
2056
2057 assertArraysEquals(r, a, b, mask, Short64VectorTests::AND_NOT);
2058 }
2059
2060 static short OR(short a, short b) {
2061 return (short)(a | b);
2062 }
2063
2064 @Test(dataProvider = "shortBinaryOpProvider")
2065 static void ORShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2066 short[] a = fa.apply(SPECIES.length());
2067 short[] b = fb.apply(SPECIES.length());
2068 short[] r = fr.apply(SPECIES.length());
2069
2070 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2071 for (int i = 0; i < a.length; i += SPECIES.length()) {
2072 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2073 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2074 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
2075 }
2076 }
2077
2078 assertArraysEquals(r, a, b, Short64VectorTests::OR);
2079 }
2080
2081 static short or(short a, short b) {
2082 return (short)(a | b);
2083 }
2084
2085 @Test(dataProvider = "shortBinaryOpProvider")
2086 static void orShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2087 short[] a = fa.apply(SPECIES.length());
2088 short[] b = fb.apply(SPECIES.length());
2089 short[] r = fr.apply(SPECIES.length());
2090
2091 for (int i = 0; i < a.length; i += SPECIES.length()) {
2092 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2093 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2094 av.or(bv).intoArray(r, i);
2095 }
2096
2097 assertArraysEquals(r, a, b, Short64VectorTests::or);
2098 }
2099
2100 @Test(dataProvider = "shortBinaryOpMaskProvider")
2101 static void ORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2102 IntFunction<boolean[]> fm) {
2103 short[] a = fa.apply(SPECIES.length());
2104 short[] b = fb.apply(SPECIES.length());
2105 short[] r = fr.apply(SPECIES.length());
2106 boolean[] mask = fm.apply(SPECIES.length());
2107 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2108
2109 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2110 for (int i = 0; i < a.length; i += SPECIES.length()) {
2111 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2112 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2113 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
2114 }
2115 }
2116
2117 assertArraysEquals(r, a, b, mask, Short64VectorTests::OR);
2118 }
2119
2120 static short XOR(short a, short b) {
2121 return (short)(a ^ b);
2122 }
2123
2124 @Test(dataProvider = "shortBinaryOpProvider")
2125 static void XORShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2126 short[] a = fa.apply(SPECIES.length());
2127 short[] b = fb.apply(SPECIES.length());
2128 short[] r = fr.apply(SPECIES.length());
2129
2130 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2131 for (int i = 0; i < a.length; i += SPECIES.length()) {
2132 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2133 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2134 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
2135 }
2136 }
2137
2138 assertArraysEquals(r, a, b, Short64VectorTests::XOR);
2139 }
2140
2141 @Test(dataProvider = "shortBinaryOpMaskProvider")
2142 static void XORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2143 IntFunction<boolean[]> fm) {
2144 short[] a = fa.apply(SPECIES.length());
2145 short[] b = fb.apply(SPECIES.length());
2146 short[] r = fr.apply(SPECIES.length());
2147 boolean[] mask = fm.apply(SPECIES.length());
2148 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2149
2150 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2151 for (int i = 0; i < a.length; i += SPECIES.length()) {
2152 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2153 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2154 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
2155 }
2156 }
2157
2158 assertArraysEquals(r, a, b, mask, Short64VectorTests::XOR);
2159 }
2160
2161 @Test(dataProvider = "shortBinaryOpProvider")
2162 static void addShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2163 short[] a = fa.apply(SPECIES.length());
2164 short[] b = fb.apply(SPECIES.length());
2165 short[] r = fr.apply(SPECIES.length());
2166
2167 for (int i = 0; i < a.length; i += SPECIES.length()) {
2168 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2169 av.add(b[i]).intoArray(r, i);
2170 }
2171
2172 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::add);
2173 }
2174
2175 @Test(dataProvider = "shortBinaryOpMaskProvider")
2176 static void addShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2177 IntFunction<boolean[]> fm) {
2178 short[] a = fa.apply(SPECIES.length());
2179 short[] b = fb.apply(SPECIES.length());
2180 short[] r = fr.apply(SPECIES.length());
2181 boolean[] mask = fm.apply(SPECIES.length());
2182 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2183
2184 for (int i = 0; i < a.length; i += SPECIES.length()) {
2185 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2186 av.add(b[i], vmask).intoArray(r, i);
2187 }
2188
2189 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::add);
2190 }
2191
2192 @Test(dataProvider = "shortBinaryOpProvider")
2193 static void subShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2194 short[] a = fa.apply(SPECIES.length());
2195 short[] b = fb.apply(SPECIES.length());
2196 short[] r = fr.apply(SPECIES.length());
2197
2198 for (int i = 0; i < a.length; i += SPECIES.length()) {
2199 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2200 av.sub(b[i]).intoArray(r, i);
2201 }
2202
2203 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::sub);
2204 }
2205
2206 @Test(dataProvider = "shortBinaryOpMaskProvider")
2207 static void subShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2208 IntFunction<boolean[]> fm) {
2209 short[] a = fa.apply(SPECIES.length());
2210 short[] b = fb.apply(SPECIES.length());
2211 short[] r = fr.apply(SPECIES.length());
2212 boolean[] mask = fm.apply(SPECIES.length());
2213 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2214
2215 for (int i = 0; i < a.length; i += SPECIES.length()) {
2216 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2217 av.sub(b[i], vmask).intoArray(r, i);
2218 }
2219
2220 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::sub);
2221 }
2222
2223 @Test(dataProvider = "shortBinaryOpProvider")
2224 static void mulShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2225 short[] a = fa.apply(SPECIES.length());
2226 short[] b = fb.apply(SPECIES.length());
2227 short[] r = fr.apply(SPECIES.length());
2228
2229 for (int i = 0; i < a.length; i += SPECIES.length()) {
2230 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2231 av.mul(b[i]).intoArray(r, i);
2232 }
2233
2234 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::mul);
2235 }
2236
2237 @Test(dataProvider = "shortBinaryOpMaskProvider")
2238 static void mulShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2239 IntFunction<boolean[]> fm) {
2240 short[] a = fa.apply(SPECIES.length());
2241 short[] b = fb.apply(SPECIES.length());
2242 short[] r = fr.apply(SPECIES.length());
2243 boolean[] mask = fm.apply(SPECIES.length());
2244 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2245
2246 for (int i = 0; i < a.length; i += SPECIES.length()) {
2247 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2248 av.mul(b[i], vmask).intoArray(r, i);
2249 }
2250
2251 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::mul);
2252 }
2253
2254 @Test(dataProvider = "shortBinaryOpProvider")
2255 static void divShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2256 short[] a = fa.apply(SPECIES.length());
2257 short[] b = fb.apply(SPECIES.length());
2258 short[] r = fr.apply(SPECIES.length());
2259
2260 replaceZero(b, (short) 1);
2261
2262 for (int i = 0; i < a.length; i += SPECIES.length()) {
2263 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2264 av.div(b[i]).intoArray(r, i);
2265 }
2266
2267 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::div);
2268 }
2269
2270 @Test(dataProvider = "shortBinaryOpMaskProvider")
2271 static void divShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2272 IntFunction<boolean[]> fm) {
2273 short[] a = fa.apply(SPECIES.length());
2274 short[] b = fb.apply(SPECIES.length());
2275 short[] r = fr.apply(SPECIES.length());
2276 boolean[] mask = fm.apply(SPECIES.length());
2277 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2278
2279 replaceZero(b, (short) 1);
2280
2281 for (int i = 0; i < a.length; i += SPECIES.length()) {
2282 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2283 av.div(b[i], vmask).intoArray(r, i);
2284 }
2285
2286 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::div);
2287 }
2288
2289 @Test(dataProvider = "shortBinaryOpProvider")
2290 static void ORShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2291 short[] a = fa.apply(SPECIES.length());
2292 short[] b = fb.apply(SPECIES.length());
2293 short[] r = fr.apply(SPECIES.length());
2294
2295 for (int i = 0; i < a.length; i += SPECIES.length()) {
2296 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2297 av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2298 }
2299
2300 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::OR);
2301 }
2302
2303 @Test(dataProvider = "shortBinaryOpProvider")
2304 static void orShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2305 short[] a = fa.apply(SPECIES.length());
2306 short[] b = fb.apply(SPECIES.length());
2307 short[] r = fr.apply(SPECIES.length());
2308
2309 for (int i = 0; i < a.length; i += SPECIES.length()) {
2310 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2311 av.or(b[i]).intoArray(r, i);
2312 }
2313
2314 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::or);
2315 }
2316
2317 @Test(dataProvider = "shortBinaryOpMaskProvider")
2318 static void ORShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2319 IntFunction<boolean[]> fm) {
2320 short[] a = fa.apply(SPECIES.length());
2321 short[] b = fb.apply(SPECIES.length());
2322 short[] r = fr.apply(SPECIES.length());
2323 boolean[] mask = fm.apply(SPECIES.length());
2324 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2325
2326 for (int i = 0; i < a.length; i += SPECIES.length()) {
2327 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2328 av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2329 }
2330
2331 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::OR);
2332 }
2333
2334 @Test(dataProvider = "shortBinaryOpProvider")
2335 static void ANDShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2336 short[] a = fa.apply(SPECIES.length());
2337 short[] b = fb.apply(SPECIES.length());
2338 short[] r = fr.apply(SPECIES.length());
2339
2340 for (int i = 0; i < a.length; i += SPECIES.length()) {
2341 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2342 av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2343 }
2344
2345 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::AND);
2346 }
2347
2348 @Test(dataProvider = "shortBinaryOpProvider")
2349 static void andShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2350 short[] a = fa.apply(SPECIES.length());
2351 short[] b = fb.apply(SPECIES.length());
2352 short[] r = fr.apply(SPECIES.length());
2353
2354 for (int i = 0; i < a.length; i += SPECIES.length()) {
2355 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2356 av.and(b[i]).intoArray(r, i);
2357 }
2358
2359 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::and);
2360 }
2361
2362 @Test(dataProvider = "shortBinaryOpMaskProvider")
2363 static void ANDShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2364 IntFunction<boolean[]> fm) {
2365 short[] a = fa.apply(SPECIES.length());
2366 short[] b = fb.apply(SPECIES.length());
2367 short[] r = fr.apply(SPECIES.length());
2368 boolean[] mask = fm.apply(SPECIES.length());
2369 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2370
2371 for (int i = 0; i < a.length; i += SPECIES.length()) {
2372 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2373 av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2374 }
2375
2376 assertBroadcastArraysEquals(r, a, b, mask, Short64VectorTests::AND);
2377 }
2378
2379 @Test(dataProvider = "shortBinaryOpProvider")
2380 static void ORShort64VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2381 short[] a = fa.apply(SPECIES.length());
2382 short[] b = fb.apply(SPECIES.length());
2383 short[] r = fr.apply(SPECIES.length());
2384
2385 for (int i = 0; i < a.length; i += SPECIES.length()) {
2386 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2387 av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2388 }
2389
2390 assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::OR);
2391 }
2392
2393 @Test(dataProvider = "shortBinaryOpMaskProvider")
2394 static void ORShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2395 IntFunction<boolean[]> fm) {
2396 short[] a = fa.apply(SPECIES.length());
2397 short[] b = fb.apply(SPECIES.length());
2398 short[] r = fr.apply(SPECIES.length());
2399 boolean[] mask = fm.apply(SPECIES.length());
2400 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2401
2402 for (int i = 0; i < a.length; i += SPECIES.length()) {
2403 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2404 av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2405 }
2406
2407 assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::OR);
2408 }
2409
2410 @Test(dataProvider = "shortBinaryOpProvider")
2411 static void ADDShort64VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2412 short[] a = fa.apply(SPECIES.length());
2413 short[] b = fb.apply(SPECIES.length());
2414 short[] r = fr.apply(SPECIES.length());
2415
2416 for (int i = 0; i < a.length; i += SPECIES.length()) {
2417 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2418 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2419 }
2420
2421 assertBroadcastLongArraysEquals(r, a, b, Short64VectorTests::ADD);
2422 }
2423
2424 @Test(dataProvider = "shortBinaryOpMaskProvider")
2425 static void ADDShort64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2426 IntFunction<boolean[]> fm) {
2427 short[] a = fa.apply(SPECIES.length());
2428 short[] b = fb.apply(SPECIES.length());
2429 short[] r = fr.apply(SPECIES.length());
2430 boolean[] mask = fm.apply(SPECIES.length());
2431 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2432
2433 for (int i = 0; i < a.length; i += SPECIES.length()) {
2434 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2435 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2436 }
2437
2438 assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::ADD);
2439 }
2440
2441 static short LSHL(short a, short b) {
2442 return (short)((a << (b & 0xF)));
2443 }
2444
2445 @Test(dataProvider = "shortBinaryOpProvider")
2446 static void LSHLShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2447 short[] a = fa.apply(SPECIES.length());
2448 short[] b = fb.apply(SPECIES.length());
2449 short[] r = fr.apply(SPECIES.length());
2450
2451 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2452 for (int i = 0; i < a.length; i += SPECIES.length()) {
2453 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2454 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2455 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2456 }
2457 }
2458
2459 assertArraysEquals(r, a, b, Short64VectorTests::LSHL);
2460 }
2461
2462 @Test(dataProvider = "shortBinaryOpMaskProvider")
2463 static void LSHLShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2464 IntFunction<boolean[]> fm) {
2465 short[] a = fa.apply(SPECIES.length());
2466 short[] b = fb.apply(SPECIES.length());
2467 short[] r = fr.apply(SPECIES.length());
2468 boolean[] mask = fm.apply(SPECIES.length());
2469 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2470
2471 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2472 for (int i = 0; i < a.length; i += SPECIES.length()) {
2473 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2474 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2475 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2476 }
2477 }
2478
2479 assertArraysEquals(r, a, b, mask, Short64VectorTests::LSHL);
2480 }
2481
2482 static short ASHR(short a, short b) {
2483 return (short)((a >> (b & 0xF)));
2484 }
2485
2486 @Test(dataProvider = "shortBinaryOpProvider")
2487 static void ASHRShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2488 short[] a = fa.apply(SPECIES.length());
2489 short[] b = fb.apply(SPECIES.length());
2490 short[] r = fr.apply(SPECIES.length());
2491
2492 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2493 for (int i = 0; i < a.length; i += SPECIES.length()) {
2494 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2495 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2496 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2497 }
2498 }
2499
2500 assertArraysEquals(r, a, b, Short64VectorTests::ASHR);
2501 }
2502
2503 @Test(dataProvider = "shortBinaryOpMaskProvider")
2504 static void ASHRShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2505 IntFunction<boolean[]> fm) {
2506 short[] a = fa.apply(SPECIES.length());
2507 short[] b = fb.apply(SPECIES.length());
2508 short[] r = fr.apply(SPECIES.length());
2509 boolean[] mask = fm.apply(SPECIES.length());
2510 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2511
2512 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2513 for (int i = 0; i < a.length; i += SPECIES.length()) {
2514 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2515 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2516 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2517 }
2518 }
2519
2520 assertArraysEquals(r, a, b, mask, Short64VectorTests::ASHR);
2521 }
2522
2523 static short LSHR(short a, short b) {
2524 return (short)(((a & 0xFFFF) >>> (b & 0xF)));
2525 }
2526
2527 @Test(dataProvider = "shortBinaryOpProvider")
2528 static void LSHRShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2529 short[] a = fa.apply(SPECIES.length());
2530 short[] b = fb.apply(SPECIES.length());
2531 short[] r = fr.apply(SPECIES.length());
2532
2533 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2534 for (int i = 0; i < a.length; i += SPECIES.length()) {
2535 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2536 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2537 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2538 }
2539 }
2540
2541 assertArraysEquals(r, a, b, Short64VectorTests::LSHR);
2542 }
2543
2544 @Test(dataProvider = "shortBinaryOpMaskProvider")
2545 static void LSHRShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2546 IntFunction<boolean[]> fm) {
2547 short[] a = fa.apply(SPECIES.length());
2548 short[] b = fb.apply(SPECIES.length());
2549 short[] r = fr.apply(SPECIES.length());
2550 boolean[] mask = fm.apply(SPECIES.length());
2551 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2552
2553 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2554 for (int i = 0; i < a.length; i += SPECIES.length()) {
2555 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2556 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2557 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2558 }
2559 }
2560
2561 assertArraysEquals(r, a, b, mask, Short64VectorTests::LSHR);
2562 }
2563
2564 static short LSHL_unary(short a, short b) {
2565 return (short)((a << (b & 15)));
2566 }
2567
2568 @Test(dataProvider = "shortBinaryOpProvider")
2569 static void LSHLShort64VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2570 short[] a = fa.apply(SPECIES.length());
2571 short[] b = fb.apply(SPECIES.length());
2572 short[] r = fr.apply(SPECIES.length());
2573
2574 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2575 for (int i = 0; i < a.length; i += SPECIES.length()) {
2576 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2577 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2578 }
2579 }
2580
2581 assertShiftArraysEquals(r, a, b, Short64VectorTests::LSHL_unary);
2582 }
2583
2584 @Test(dataProvider = "shortBinaryOpMaskProvider")
2585 static void LSHLShort64VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2586 IntFunction<boolean[]> fm) {
2587 short[] a = fa.apply(SPECIES.length());
2588 short[] b = fb.apply(SPECIES.length());
2589 short[] r = fr.apply(SPECIES.length());
2590 boolean[] mask = fm.apply(SPECIES.length());
2591 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2592
2593 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2594 for (int i = 0; i < a.length; i += SPECIES.length()) {
2595 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2596 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2597 }
2598 }
2599
2600 assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::LSHL_unary);
2601 }
2602
2603 static short LSHR_unary(short a, short b) {
2604 return (short)(((a & 0xFFFF) >>> (b & 15)));
2605 }
2606
2607 @Test(dataProvider = "shortBinaryOpProvider")
2608 static void LSHRShort64VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2609 short[] a = fa.apply(SPECIES.length());
2610 short[] b = fb.apply(SPECIES.length());
2611 short[] r = fr.apply(SPECIES.length());
2612
2613 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2614 for (int i = 0; i < a.length; i += SPECIES.length()) {
2615 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2616 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2617 }
2618 }
2619
2620 assertShiftArraysEquals(r, a, b, Short64VectorTests::LSHR_unary);
2621 }
2622
2623 @Test(dataProvider = "shortBinaryOpMaskProvider")
2624 static void LSHRShort64VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2625 IntFunction<boolean[]> fm) {
2626 short[] a = fa.apply(SPECIES.length());
2627 short[] b = fb.apply(SPECIES.length());
2628 short[] r = fr.apply(SPECIES.length());
2629 boolean[] mask = fm.apply(SPECIES.length());
2630 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2631
2632 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2633 for (int i = 0; i < a.length; i += SPECIES.length()) {
2634 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2635 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2636 }
2637 }
2638
2639 assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::LSHR_unary);
2640 }
2641
2642 static short ASHR_unary(short a, short b) {
2643 return (short)((a >> (b & 15)));
2644 }
2645
2646 @Test(dataProvider = "shortBinaryOpProvider")
2647 static void ASHRShort64VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2648 short[] a = fa.apply(SPECIES.length());
2649 short[] b = fb.apply(SPECIES.length());
2650 short[] r = fr.apply(SPECIES.length());
2651
2652 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2653 for (int i = 0; i < a.length; i += SPECIES.length()) {
2654 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2655 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2656 }
2657 }
2658
2659 assertShiftArraysEquals(r, a, b, Short64VectorTests::ASHR_unary);
2660 }
2661
2662 @Test(dataProvider = "shortBinaryOpMaskProvider")
2663 static void ASHRShort64VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2664 IntFunction<boolean[]> fm) {
2665 short[] a = fa.apply(SPECIES.length());
2666 short[] b = fb.apply(SPECIES.length());
2667 short[] r = fr.apply(SPECIES.length());
2668 boolean[] mask = fm.apply(SPECIES.length());
2669 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2670
2671 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2672 for (int i = 0; i < a.length; i += SPECIES.length()) {
2673 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2674 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2675 }
2676 }
2677
2678 assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ASHR_unary);
2679 }
2680
2681 static short ROR(short a, short b) {
2682 return (short)(ROR_scalar(a,b));
2683 }
2684
2685 @Test(dataProvider = "shortBinaryOpProvider")
2686 static void RORShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2687 short[] a = fa.apply(SPECIES.length());
2688 short[] b = fb.apply(SPECIES.length());
2689 short[] r = fr.apply(SPECIES.length());
2690
2691 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2692 for (int i = 0; i < a.length; i += SPECIES.length()) {
2693 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2694 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2695 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2696 }
2697 }
2698
2699 assertArraysEquals(r, a, b, Short64VectorTests::ROR);
2700 }
2701
2702 @Test(dataProvider = "shortBinaryOpMaskProvider")
2703 static void RORShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2704 IntFunction<boolean[]> fm) {
2705 short[] a = fa.apply(SPECIES.length());
2706 short[] b = fb.apply(SPECIES.length());
2707 short[] r = fr.apply(SPECIES.length());
2708 boolean[] mask = fm.apply(SPECIES.length());
2709 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2710
2711 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2712 for (int i = 0; i < a.length; i += SPECIES.length()) {
2713 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2714 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2715 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2716 }
2717 }
2718
2719 assertArraysEquals(r, a, b, mask, Short64VectorTests::ROR);
2720 }
2721
2722 static short ROL(short a, short b) {
2723 return (short)(ROL_scalar(a,b));
2724 }
2725
2726 @Test(dataProvider = "shortBinaryOpProvider")
2727 static void ROLShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2728 short[] a = fa.apply(SPECIES.length());
2729 short[] b = fb.apply(SPECIES.length());
2730 short[] r = fr.apply(SPECIES.length());
2731
2732 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2733 for (int i = 0; i < a.length; i += SPECIES.length()) {
2734 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2735 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2736 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2737 }
2738 }
2739
2740 assertArraysEquals(r, a, b, Short64VectorTests::ROL);
2741 }
2742
2743 @Test(dataProvider = "shortBinaryOpMaskProvider")
2744 static void ROLShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2745 IntFunction<boolean[]> fm) {
2746 short[] a = fa.apply(SPECIES.length());
2747 short[] b = fb.apply(SPECIES.length());
2748 short[] r = fr.apply(SPECIES.length());
2749 boolean[] mask = fm.apply(SPECIES.length());
2750 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2751
2752 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2753 for (int i = 0; i < a.length; i += SPECIES.length()) {
2754 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2755 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2756 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2757 }
2758 }
2759
2760 assertArraysEquals(r, a, b, mask, Short64VectorTests::ROL);
2761 }
2762
2763 static short ROR_unary(short a, short b) {
2764 return (short)(ROR_scalar(a, b));
2765 }
2766
2767 @Test(dataProvider = "shortBinaryOpProvider")
2768 static void RORShort64VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2769 short[] a = fa.apply(SPECIES.length());
2770 short[] b = fb.apply(SPECIES.length());
2771 short[] r = fr.apply(SPECIES.length());
2772
2773 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2774 for (int i = 0; i < a.length; i += SPECIES.length()) {
2775 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2776 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2777 }
2778 }
2779
2780 assertShiftArraysEquals(r, a, b, Short64VectorTests::ROR_unary);
2781 }
2782
2783 @Test(dataProvider = "shortBinaryOpMaskProvider")
2784 static void RORShort64VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2785 IntFunction<boolean[]> fm) {
2786 short[] a = fa.apply(SPECIES.length());
2787 short[] b = fb.apply(SPECIES.length());
2788 short[] r = fr.apply(SPECIES.length());
2789 boolean[] mask = fm.apply(SPECIES.length());
2790 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2791
2792 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2793 for (int i = 0; i < a.length; i += SPECIES.length()) {
2794 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2795 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2796 }
2797 }
2798
2799 assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ROR_unary);
2800 }
2801
2802 static short ROL_unary(short a, short b) {
2803 return (short)(ROL_scalar(a, b));
2804 }
2805
2806 @Test(dataProvider = "shortBinaryOpProvider")
2807 static void ROLShort64VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2808 short[] a = fa.apply(SPECIES.length());
2809 short[] b = fb.apply(SPECIES.length());
2810 short[] r = fr.apply(SPECIES.length());
2811
2812 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2813 for (int i = 0; i < a.length; i += SPECIES.length()) {
2814 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2815 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2816 }
2817 }
2818
2819 assertShiftArraysEquals(r, a, b, Short64VectorTests::ROL_unary);
2820 }
2821
2822 @Test(dataProvider = "shortBinaryOpMaskProvider")
2823 static void ROLShort64VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2824 IntFunction<boolean[]> fm) {
2825 short[] a = fa.apply(SPECIES.length());
2826 short[] b = fb.apply(SPECIES.length());
2827 short[] r = fr.apply(SPECIES.length());
2828 boolean[] mask = fm.apply(SPECIES.length());
2829 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2830
2831 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2832 for (int i = 0; i < a.length; i += SPECIES.length()) {
2833 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2834 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2835 }
2836 }
2837
2838 assertShiftArraysEquals(r, a, b, mask, Short64VectorTests::ROL_unary);
2839 }
2840 static short LSHR_binary_const(short a) {
2841 return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
2842 }
2843
2844 @Test(dataProvider = "shortUnaryOpProvider")
2845 static void LSHRShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2846 short[] a = fa.apply(SPECIES.length());
2847 short[] r = fr.apply(SPECIES.length());
2848
2849 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2850 for (int i = 0; i < a.length; i += SPECIES.length()) {
2851 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2852 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2853 }
2854 }
2855
2856 assertShiftConstEquals(r, a, Short64VectorTests::LSHR_binary_const);
2857 }
2858
2859 @Test(dataProvider = "shortUnaryOpMaskProvider")
2860 static void LSHRShort64VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2861 IntFunction<boolean[]> fm) {
2862 short[] a = fa.apply(SPECIES.length());
2863 short[] r = fr.apply(SPECIES.length());
2864 boolean[] mask = fm.apply(SPECIES.length());
2865 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2866
2867 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2868 for (int i = 0; i < a.length; i += SPECIES.length()) {
2869 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2870 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2871 }
2872 }
2873
2874 assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHR_binary_const);
2875 }
2876
2877 static short LSHL_binary_const(short a) {
2878 return (short)((a << CONST_SHIFT));
2879 }
2880
2881 @Test(dataProvider = "shortUnaryOpProvider")
2882 static void LSHLShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2883 short[] a = fa.apply(SPECIES.length());
2884 short[] r = fr.apply(SPECIES.length());
2885
2886 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2887 for (int i = 0; i < a.length; i += SPECIES.length()) {
2888 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2889 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2890 }
2891 }
2892
2893 assertShiftConstEquals(r, a, Short64VectorTests::LSHL_binary_const);
2894 }
2895
2896 @Test(dataProvider = "shortUnaryOpMaskProvider")
2897 static void LSHLShort64VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2898 IntFunction<boolean[]> fm) {
2899 short[] a = fa.apply(SPECIES.length());
2900 short[] r = fr.apply(SPECIES.length());
2901 boolean[] mask = fm.apply(SPECIES.length());
2902 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2903
2904 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2905 for (int i = 0; i < a.length; i += SPECIES.length()) {
2906 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2907 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2908 }
2909 }
2910
2911 assertShiftConstEquals(r, a, mask, Short64VectorTests::LSHL_binary_const);
2912 }
2913
2914 static short ASHR_binary_const(short a) {
2915 return (short)((a >> CONST_SHIFT));
2916 }
2917
2918 @Test(dataProvider = "shortUnaryOpProvider")
2919 static void ASHRShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2920 short[] a = fa.apply(SPECIES.length());
2921 short[] r = fr.apply(SPECIES.length());
2922
2923 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2924 for (int i = 0; i < a.length; i += SPECIES.length()) {
2925 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2926 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2927 }
2928 }
2929
2930 assertShiftConstEquals(r, a, Short64VectorTests::ASHR_binary_const);
2931 }
2932
2933 @Test(dataProvider = "shortUnaryOpMaskProvider")
2934 static void ASHRShort64VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2935 IntFunction<boolean[]> fm) {
2936 short[] a = fa.apply(SPECIES.length());
2937 short[] r = fr.apply(SPECIES.length());
2938 boolean[] mask = fm.apply(SPECIES.length());
2939 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2940
2941 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2942 for (int i = 0; i < a.length; i += SPECIES.length()) {
2943 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2944 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2945 }
2946 }
2947
2948 assertShiftConstEquals(r, a, mask, Short64VectorTests::ASHR_binary_const);
2949 }
2950
2951 static short ROR_binary_const(short a) {
2952 return (short)(ROR_scalar(a, CONST_SHIFT));
2953 }
2954
2955 @Test(dataProvider = "shortUnaryOpProvider")
2956 static void RORShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2957 short[] a = fa.apply(SPECIES.length());
2958 short[] r = fr.apply(SPECIES.length());
2959
2960 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2961 for (int i = 0; i < a.length; i += SPECIES.length()) {
2962 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2963 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2964 }
2965 }
2966
2967 assertShiftConstEquals(r, a, Short64VectorTests::ROR_binary_const);
2968 }
2969
2970 @Test(dataProvider = "shortUnaryOpMaskProvider")
2971 static void RORShort64VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2972 IntFunction<boolean[]> fm) {
2973 short[] a = fa.apply(SPECIES.length());
2974 short[] r = fr.apply(SPECIES.length());
2975 boolean[] mask = fm.apply(SPECIES.length());
2976 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2977
2978 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2979 for (int i = 0; i < a.length; i += SPECIES.length()) {
2980 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2981 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2982 }
2983 }
2984
2985 assertShiftConstEquals(r, a, mask, Short64VectorTests::ROR_binary_const);
2986 }
2987
2988 static short ROL_binary_const(short a) {
2989 return (short)(ROL_scalar(a, CONST_SHIFT));
2990 }
2991
2992 @Test(dataProvider = "shortUnaryOpProvider")
2993 static void ROLShort64VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2994 short[] a = fa.apply(SPECIES.length());
2995 short[] r = fr.apply(SPECIES.length());
2996
2997 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2998 for (int i = 0; i < a.length; i += SPECIES.length()) {
2999 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3000 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
3001 }
3002 }
3003
3004 assertShiftConstEquals(r, a, Short64VectorTests::ROL_binary_const);
3005 }
3006
3007 @Test(dataProvider = "shortUnaryOpMaskProvider")
3008 static void ROLShort64VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
3009 IntFunction<boolean[]> fm) {
3010 short[] a = fa.apply(SPECIES.length());
3011 short[] r = fr.apply(SPECIES.length());
3012 boolean[] mask = fm.apply(SPECIES.length());
3013 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3014
3015 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3016 for (int i = 0; i < a.length; i += SPECIES.length()) {
3017 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3018 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
3019 }
3020 }
3021
3022 assertShiftConstEquals(r, a, mask, Short64VectorTests::ROL_binary_const);
3023 }
3024
3025
3026 static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10);
3027
3028 @Test(dataProvider = "shortUnaryOpProvider")
3029 static void MINShort64VectorTestsWithMemOp(IntFunction<short[]> fa) {
3030 short[] a = fa.apply(SPECIES.length());
3031 short[] r = fr.apply(SPECIES.length());
3032
3033 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3034 for (int i = 0; i < a.length; i += SPECIES.length()) {
3035 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3036 av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i);
3037 }
3038 }
3039
3040 assertArraysEquals(r, a, (short)10, Short64VectorTests::MIN);
3041 }
3042
3043 static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10);
3044
3045 @Test(dataProvider = "shortUnaryOpProvider")
3046 static void minShort64VectorTestsWithMemOp(IntFunction<short[]> fa) {
3047 short[] a = fa.apply(SPECIES.length());
3048 short[] r = fr.apply(SPECIES.length());
3049
3050 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3051 for (int i = 0; i < a.length; i += SPECIES.length()) {
3052 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3053 av.min(bv_min).intoArray(r, i);
3054 }
3055 }
3056
3057 assertArraysEquals(r, a, (short)10, Short64VectorTests::min);
3058 }
3059
3060 static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10);
3061
3062 @Test(dataProvider = "shortUnaryOpMaskProvider")
3063 static void MINShort64VectorTestsMaskedWithMemOp(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3064 short[] a = fa.apply(SPECIES.length());
3065 short[] r = fr.apply(SPECIES.length());
3066 boolean[] mask = fm.apply(SPECIES.length());
3067 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3068
3069 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3070 for (int i = 0; i < a.length; i += SPECIES.length()) {
3071 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3072 av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i);
3073 }
3074 }
3075
3076 assertArraysEquals(r, a, (short)10, mask, Short64VectorTests::MIN);
3077 }
3078
3079 static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10);
3080
3081 @Test(dataProvider = "shortUnaryOpProvider")
3082 static void MAXShort64VectorTestsWithMemOp(IntFunction<short[]> fa) {
3083 short[] a = fa.apply(SPECIES.length());
3084 short[] r = fr.apply(SPECIES.length());
3085
3086 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3087 for (int i = 0; i < a.length; i += SPECIES.length()) {
3088 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3089 av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i);
3090 }
3091 }
3092
3093 assertArraysEquals(r, a, (short)10, Short64VectorTests::MAX);
3094 }
3095
3096 static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10);
3097
3098 @Test(dataProvider = "shortUnaryOpProvider")
3099 static void maxShort64VectorTestsWithMemOp(IntFunction<short[]> fa) {
3100 short[] a = fa.apply(SPECIES.length());
3101 short[] r = fr.apply(SPECIES.length());
3102
3103 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3104 for (int i = 0; i < a.length; i += SPECIES.length()) {
3105 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3106 av.max(bv_max).intoArray(r, i);
3107 }
3108 }
3109
3110 assertArraysEquals(r, a, (short)10, Short64VectorTests::max);
3111 }
3112
3113 static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10);
3114
3115 @Test(dataProvider = "shortUnaryOpMaskProvider")
3116 static void MAXShort64VectorTestsMaskedWithMemOp(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3117 short[] a = fa.apply(SPECIES.length());
3118 short[] r = fr.apply(SPECIES.length());
3119 boolean[] mask = fm.apply(SPECIES.length());
3120 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3121
3122 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3123 for (int i = 0; i < a.length; i += SPECIES.length()) {
3124 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3125 av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i);
3126 }
3127 }
3128
3129 assertArraysEquals(r, a, (short)10, mask, Short64VectorTests::MAX);
3130 }
3131
3132 static short MIN(short a, short b) {
3133 return (short)(Math.min(a, b));
3134 }
3135
3136 @Test(dataProvider = "shortBinaryOpProvider")
3137 static void MINShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3138 short[] a = fa.apply(SPECIES.length());
3139 short[] b = fb.apply(SPECIES.length());
3140 short[] r = fr.apply(SPECIES.length());
3141
3142 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3143 for (int i = 0; i < a.length; i += SPECIES.length()) {
3144 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3145 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3146 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
3147 }
3148 }
3149
3150 assertArraysEquals(r, a, b, Short64VectorTests::MIN);
3151 }
3152
3153 static short min(short a, short b) {
3154 return (short)(Math.min(a, b));
3155 }
3156
3157 @Test(dataProvider = "shortBinaryOpProvider")
3158 static void minShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3159 short[] a = fa.apply(SPECIES.length());
3160 short[] b = fb.apply(SPECIES.length());
3161 short[] r = fr.apply(SPECIES.length());
3162
3163 for (int i = 0; i < a.length; i += SPECIES.length()) {
3164 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3165 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3166 av.min(bv).intoArray(r, i);
3167 }
3168
3169 assertArraysEquals(r, a, b, Short64VectorTests::min);
3170 }
3171
3172 static short MAX(short a, short b) {
3173 return (short)(Math.max(a, b));
3174 }
3175
3176 @Test(dataProvider = "shortBinaryOpProvider")
3177 static void MAXShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3178 short[] a = fa.apply(SPECIES.length());
3179 short[] b = fb.apply(SPECIES.length());
3180 short[] r = fr.apply(SPECIES.length());
3181
3182 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3183 for (int i = 0; i < a.length; i += SPECIES.length()) {
3184 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3185 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3186 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
3187 }
3188 }
3189
3190 assertArraysEquals(r, a, b, Short64VectorTests::MAX);
3191 }
3192
3193 static short max(short a, short b) {
3194 return (short)(Math.max(a, b));
3195 }
3196
3197 @Test(dataProvider = "shortBinaryOpProvider")
3198 static void maxShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3199 short[] a = fa.apply(SPECIES.length());
3200 short[] b = fb.apply(SPECIES.length());
3201 short[] r = fr.apply(SPECIES.length());
3202
3203 for (int i = 0; i < a.length; i += SPECIES.length()) {
3204 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3205 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3206 av.max(bv).intoArray(r, i);
3207 }
3208
3209 assertArraysEquals(r, a, b, Short64VectorTests::max);
3210 }
3211
3212 static short UMIN(short a, short b) {
3213 return (short)(VectorMath.minUnsigned(a, b));
3214 }
3215
3216 @Test(dataProvider = "shortBinaryOpProvider")
3217 static void UMINShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3218 short[] a = fa.apply(SPECIES.length());
3219 short[] b = fb.apply(SPECIES.length());
3220 short[] r = fr.apply(SPECIES.length());
3221
3222 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3223 for (int i = 0; i < a.length; i += SPECIES.length()) {
3224 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3225 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3226 av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i);
3227 }
3228 }
3229
3230 assertArraysEquals(r, a, b, Short64VectorTests::UMIN);
3231 }
3232
3233 @Test(dataProvider = "shortBinaryOpMaskProvider")
3234 static void UMINShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3235 IntFunction<boolean[]> fm) {
3236 short[] a = fa.apply(SPECIES.length());
3237 short[] b = fb.apply(SPECIES.length());
3238 short[] r = fr.apply(SPECIES.length());
3239 boolean[] mask = fm.apply(SPECIES.length());
3240 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3241
3242 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3243 for (int i = 0; i < a.length; i += SPECIES.length()) {
3244 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3245 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3246 av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i);
3247 }
3248 }
3249
3250 assertArraysEquals(r, a, b, mask, Short64VectorTests::UMIN);
3251 }
3252
3253 static short UMAX(short a, short b) {
3254 return (short)(VectorMath.maxUnsigned(a, b));
3255 }
3256
3257 @Test(dataProvider = "shortBinaryOpProvider")
3258 static void UMAXShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3259 short[] a = fa.apply(SPECIES.length());
3260 short[] b = fb.apply(SPECIES.length());
3261 short[] r = fr.apply(SPECIES.length());
3262
3263 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3264 for (int i = 0; i < a.length; i += SPECIES.length()) {
3265 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3266 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3267 av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i);
3268 }
3269 }
3270
3271 assertArraysEquals(r, a, b, Short64VectorTests::UMAX);
3272 }
3273
3274 @Test(dataProvider = "shortBinaryOpMaskProvider")
3275 static void UMAXShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3276 IntFunction<boolean[]> fm) {
3277 short[] a = fa.apply(SPECIES.length());
3278 short[] b = fb.apply(SPECIES.length());
3279 short[] r = fr.apply(SPECIES.length());
3280 boolean[] mask = fm.apply(SPECIES.length());
3281 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3282
3283 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3284 for (int i = 0; i < a.length; i += SPECIES.length()) {
3285 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3286 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3287 av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i);
3288 }
3289 }
3290
3291 assertArraysEquals(r, a, b, mask, Short64VectorTests::UMAX);
3292 }
3293
3294 static short SADD(short a, short b) {
3295 return (short)(VectorMath.addSaturating(a, b));
3296 }
3297
3298 @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3299 static void SADDShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3300 short[] a = fa.apply(SPECIES.length());
3301 short[] b = fb.apply(SPECIES.length());
3302 short[] r = fr.apply(SPECIES.length());
3303
3304 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3305 for (int i = 0; i < a.length; i += SPECIES.length()) {
3306 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3307 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3308 av.lanewise(VectorOperators.SADD, bv).intoArray(r, i);
3309 }
3310 }
3311
3312 assertArraysEquals(r, a, b, Short64VectorTests::SADD);
3313 }
3314
3315 @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3316 static void SADDShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3317 IntFunction<boolean[]> fm) {
3318 short[] a = fa.apply(SPECIES.length());
3319 short[] b = fb.apply(SPECIES.length());
3320 short[] r = fr.apply(SPECIES.length());
3321 boolean[] mask = fm.apply(SPECIES.length());
3322 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3323
3324 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3325 for (int i = 0; i < a.length; i += SPECIES.length()) {
3326 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3327 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3328 av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i);
3329 }
3330 }
3331
3332 assertArraysEquals(r, a, b, mask, Short64VectorTests::SADD);
3333 }
3334
3335 static short SSUB(short a, short b) {
3336 return (short)(VectorMath.subSaturating(a, b));
3337 }
3338
3339 @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3340 static void SSUBShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3341 short[] a = fa.apply(SPECIES.length());
3342 short[] b = fb.apply(SPECIES.length());
3343 short[] r = fr.apply(SPECIES.length());
3344
3345 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3346 for (int i = 0; i < a.length; i += SPECIES.length()) {
3347 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3348 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3349 av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i);
3350 }
3351 }
3352
3353 assertArraysEquals(r, a, b, Short64VectorTests::SSUB);
3354 }
3355
3356 @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3357 static void SSUBShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3358 IntFunction<boolean[]> fm) {
3359 short[] a = fa.apply(SPECIES.length());
3360 short[] b = fb.apply(SPECIES.length());
3361 short[] r = fr.apply(SPECIES.length());
3362 boolean[] mask = fm.apply(SPECIES.length());
3363 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3364
3365 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3366 for (int i = 0; i < a.length; i += SPECIES.length()) {
3367 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3368 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3369 av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i);
3370 }
3371 }
3372
3373 assertArraysEquals(r, a, b, mask, Short64VectorTests::SSUB);
3374 }
3375
3376 static short SUADD(short a, short b) {
3377 return (short)(VectorMath.addSaturatingUnsigned(a, b));
3378 }
3379
3380 @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3381 static void SUADDShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3382 short[] a = fa.apply(SPECIES.length());
3383 short[] b = fb.apply(SPECIES.length());
3384 short[] r = fr.apply(SPECIES.length());
3385
3386 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3387 for (int i = 0; i < a.length; i += SPECIES.length()) {
3388 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3389 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3390 av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i);
3391 }
3392 }
3393
3394 assertArraysEquals(r, a, b, Short64VectorTests::SUADD);
3395 }
3396
3397 @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3398 static void SUADDShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3399 IntFunction<boolean[]> fm) {
3400 short[] a = fa.apply(SPECIES.length());
3401 short[] b = fb.apply(SPECIES.length());
3402 short[] r = fr.apply(SPECIES.length());
3403 boolean[] mask = fm.apply(SPECIES.length());
3404 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3405
3406 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3407 for (int i = 0; i < a.length; i += SPECIES.length()) {
3408 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3409 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3410 av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i);
3411 }
3412 }
3413
3414 assertArraysEquals(r, a, b, mask, Short64VectorTests::SUADD);
3415 }
3416
3417 static short SUSUB(short a, short b) {
3418 return (short)(VectorMath.subSaturatingUnsigned(a, b));
3419 }
3420
3421 @Test(dataProvider = "shortSaturatingBinaryOpProvider")
3422 static void SUSUBShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3423 short[] a = fa.apply(SPECIES.length());
3424 short[] b = fb.apply(SPECIES.length());
3425 short[] r = fr.apply(SPECIES.length());
3426
3427 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3428 for (int i = 0; i < a.length; i += SPECIES.length()) {
3429 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3430 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3431 av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i);
3432 }
3433 }
3434
3435 assertArraysEquals(r, a, b, Short64VectorTests::SUSUB);
3436 }
3437
3438 @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider")
3439 static void SUSUBShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3440 IntFunction<boolean[]> fm) {
3441 short[] a = fa.apply(SPECIES.length());
3442 short[] b = fb.apply(SPECIES.length());
3443 short[] r = fr.apply(SPECIES.length());
3444 boolean[] mask = fm.apply(SPECIES.length());
3445 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3446
3447 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3448 for (int i = 0; i < a.length; i += SPECIES.length()) {
3449 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3450 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3451 av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i);
3452 }
3453 }
3454
3455 assertArraysEquals(r, a, b, mask, Short64VectorTests::SUSUB);
3456 }
3457
3458 @Test(dataProvider = "shortBinaryOpProvider")
3459 static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3460 short[] a = fa.apply(SPECIES.length());
3461 short[] b = fb.apply(SPECIES.length());
3462 short[] r = fr.apply(SPECIES.length());
3463
3464 for (int i = 0; i < a.length; i += SPECIES.length()) {
3465 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3466 av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);
3467 }
3468
3469 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MIN);
3470 }
3471
3472 @Test(dataProvider = "shortBinaryOpProvider")
3473 static void minShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3474 short[] a = fa.apply(SPECIES.length());
3475 short[] b = fb.apply(SPECIES.length());
3476 short[] r = fr.apply(SPECIES.length());
3477
3478 for (int i = 0; i < a.length; i += SPECIES.length()) {
3479 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3480 av.min(b[i]).intoArray(r, i);
3481 }
3482
3483 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::min);
3484 }
3485
3486 @Test(dataProvider = "shortBinaryOpProvider")
3487 static void MAXShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3488 short[] a = fa.apply(SPECIES.length());
3489 short[] b = fb.apply(SPECIES.length());
3490 short[] r = fr.apply(SPECIES.length());
3491
3492 for (int i = 0; i < a.length; i += SPECIES.length()) {
3493 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3494 av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);
3495 }
3496
3497 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::MAX);
3498 }
3499
3500 @Test(dataProvider = "shortBinaryOpProvider")
3501 static void maxShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3502 short[] a = fa.apply(SPECIES.length());
3503 short[] b = fb.apply(SPECIES.length());
3504 short[] r = fr.apply(SPECIES.length());
3505
3506 for (int i = 0; i < a.length; i += SPECIES.length()) {
3507 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3508 av.max(b[i]).intoArray(r, i);
3509 }
3510
3511 assertBroadcastArraysEquals(r, a, b, Short64VectorTests::max);
3512 }
3513 @Test(dataProvider = "shortSaturatingBinaryOpAssocProvider")
3514 static void SUADDAssocShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
3515 short[] a = fa.apply(SPECIES.length());
3516 short[] b = fb.apply(SPECIES.length());
3517 short[] c = fc.apply(SPECIES.length());
3518 short[] rl = fr.apply(SPECIES.length());
3519 short[] rr = fr.apply(SPECIES.length());
3520
3521 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3522 for (int i = 0; i < a.length; i += SPECIES.length()) {
3523 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3524 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3525 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3526 av.lanewise(VectorOperators.SUADD, bv).lanewise(VectorOperators.SUADD, cv).intoArray(rl, i);
3527 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv)).intoArray(rr, i);
3528 }
3529 }
3530
3531 assertArraysEqualsAssociative(rl, rr, a, b, c, Short64VectorTests::SUADD);
3532 }
3533
3534 @Test(dataProvider = "shortSaturatingBinaryOpAssocMaskProvider")
3535 static void SUADDAssocShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
3536 IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
3537 short[] a = fa.apply(SPECIES.length());
3538 short[] b = fb.apply(SPECIES.length());
3539 short[] c = fc.apply(SPECIES.length());
3540 boolean[] mask = fm.apply(SPECIES.length());
3541 short[] rl = fr.apply(SPECIES.length());
3542 short[] rr = fr.apply(SPECIES.length());
3543
3544 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3545
3546 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3547 for (int i = 0; i < a.length; i += SPECIES.length()) {
3548 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3549 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3550 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
3551 av.lanewise(VectorOperators.SUADD, bv, vmask).lanewise(VectorOperators.SUADD, cv, vmask).intoArray(rl, i);
3552 av.lanewise(VectorOperators.SUADD, bv.lanewise(VectorOperators.SUADD, cv, vmask), vmask).intoArray(rr, i);
3553 }
3554 }
3555
3556 assertArraysEqualsAssociative(rl, rr, a, b, c, mask, Short64VectorTests::SUADD);
3557 }
3558
3559 static short ANDReduce(short[] a, int idx) {
3560 short res = -1;
3561 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3562 res &= a[i];
3563 }
3564
3565 return res;
3566 }
3567
3568 static short ANDReduceAll(short[] a) {
3569 short res = -1;
3570 for (int i = 0; i < a.length; i += SPECIES.length()) {
3571 res &= ANDReduce(a, i);
3572 }
3573
3574 return res;
3575 }
3576
3577 @Test(dataProvider = "shortUnaryOpProvider")
3578 static void ANDReduceShort64VectorTests(IntFunction<short[]> fa) {
3579 short[] a = fa.apply(SPECIES.length());
3580 short[] r = fr.apply(SPECIES.length());
3581 short ra = -1;
3582
3583 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3584 for (int i = 0; i < a.length; i += SPECIES.length()) {
3585 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3586 r[i] = av.reduceLanes(VectorOperators.AND);
3587 }
3588 }
3589
3590 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3591 ra = -1;
3592 for (int i = 0; i < a.length; i += SPECIES.length()) {
3593 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3594 ra &= av.reduceLanes(VectorOperators.AND);
3595 }
3596 }
3597
3598 assertReductionArraysEquals(r, ra, a,
3599 Short64VectorTests::ANDReduce, Short64VectorTests::ANDReduceAll);
3600 }
3601
3602 static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
3603 short res = -1;
3604 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3605 if (mask[i % SPECIES.length()])
3606 res &= a[i];
3607 }
3608
3609 return res;
3610 }
3611
3612 static short ANDReduceAllMasked(short[] a, boolean[] mask) {
3613 short res = -1;
3614 for (int i = 0; i < a.length; i += SPECIES.length()) {
3615 res &= ANDReduceMasked(a, i, mask);
3616 }
3617
3618 return res;
3619 }
3620
3621 @Test(dataProvider = "shortUnaryOpMaskProvider")
3622 static void ANDReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3623 short[] a = fa.apply(SPECIES.length());
3624 short[] r = fr.apply(SPECIES.length());
3625 boolean[] mask = fm.apply(SPECIES.length());
3626 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3627 short ra = -1;
3628
3629 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3630 for (int i = 0; i < a.length; i += SPECIES.length()) {
3631 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3632 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3633 }
3634 }
3635
3636 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3637 ra = -1;
3638 for (int i = 0; i < a.length; i += SPECIES.length()) {
3639 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3640 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3641 }
3642 }
3643
3644 assertReductionArraysEqualsMasked(r, ra, a, mask,
3645 Short64VectorTests::ANDReduceMasked, Short64VectorTests::ANDReduceAllMasked);
3646 }
3647
3648 static short ORReduce(short[] a, int idx) {
3649 short res = 0;
3650 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3651 res |= a[i];
3652 }
3653
3654 return res;
3655 }
3656
3657 static short ORReduceAll(short[] a) {
3658 short res = 0;
3659 for (int i = 0; i < a.length; i += SPECIES.length()) {
3660 res |= ORReduce(a, i);
3661 }
3662
3663 return res;
3664 }
3665
3666 @Test(dataProvider = "shortUnaryOpProvider")
3667 static void ORReduceShort64VectorTests(IntFunction<short[]> fa) {
3668 short[] a = fa.apply(SPECIES.length());
3669 short[] r = fr.apply(SPECIES.length());
3670 short ra = 0;
3671
3672 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3673 for (int i = 0; i < a.length; i += SPECIES.length()) {
3674 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3675 r[i] = av.reduceLanes(VectorOperators.OR);
3676 }
3677 }
3678
3679 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3680 ra = 0;
3681 for (int i = 0; i < a.length; i += SPECIES.length()) {
3682 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3683 ra |= av.reduceLanes(VectorOperators.OR);
3684 }
3685 }
3686
3687 assertReductionArraysEquals(r, ra, a,
3688 Short64VectorTests::ORReduce, Short64VectorTests::ORReduceAll);
3689 }
3690
3691 static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
3692 short res = 0;
3693 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3694 if (mask[i % SPECIES.length()])
3695 res |= a[i];
3696 }
3697
3698 return res;
3699 }
3700
3701 static short ORReduceAllMasked(short[] a, boolean[] mask) {
3702 short res = 0;
3703 for (int i = 0; i < a.length; i += SPECIES.length()) {
3704 res |= ORReduceMasked(a, i, mask);
3705 }
3706
3707 return res;
3708 }
3709
3710 @Test(dataProvider = "shortUnaryOpMaskProvider")
3711 static void ORReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3712 short[] a = fa.apply(SPECIES.length());
3713 short[] r = fr.apply(SPECIES.length());
3714 boolean[] mask = fm.apply(SPECIES.length());
3715 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3716 short ra = 0;
3717
3718 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3719 for (int i = 0; i < a.length; i += SPECIES.length()) {
3720 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3721 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3722 }
3723 }
3724
3725 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3726 ra = 0;
3727 for (int i = 0; i < a.length; i += SPECIES.length()) {
3728 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3729 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3730 }
3731 }
3732
3733 assertReductionArraysEqualsMasked(r, ra, a, mask,
3734 Short64VectorTests::ORReduceMasked, Short64VectorTests::ORReduceAllMasked);
3735 }
3736
3737 static short XORReduce(short[] a, int idx) {
3738 short res = 0;
3739 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3740 res ^= a[i];
3741 }
3742
3743 return res;
3744 }
3745
3746 static short XORReduceAll(short[] a) {
3747 short res = 0;
3748 for (int i = 0; i < a.length; i += SPECIES.length()) {
3749 res ^= XORReduce(a, i);
3750 }
3751
3752 return res;
3753 }
3754
3755 @Test(dataProvider = "shortUnaryOpProvider")
3756 static void XORReduceShort64VectorTests(IntFunction<short[]> fa) {
3757 short[] a = fa.apply(SPECIES.length());
3758 short[] r = fr.apply(SPECIES.length());
3759 short ra = 0;
3760
3761 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3762 for (int i = 0; i < a.length; i += SPECIES.length()) {
3763 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3764 r[i] = av.reduceLanes(VectorOperators.XOR);
3765 }
3766 }
3767
3768 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3769 ra = 0;
3770 for (int i = 0; i < a.length; i += SPECIES.length()) {
3771 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3772 ra ^= av.reduceLanes(VectorOperators.XOR);
3773 }
3774 }
3775
3776 assertReductionArraysEquals(r, ra, a,
3777 Short64VectorTests::XORReduce, Short64VectorTests::XORReduceAll);
3778 }
3779
3780 static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
3781 short res = 0;
3782 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3783 if (mask[i % SPECIES.length()])
3784 res ^= a[i];
3785 }
3786
3787 return res;
3788 }
3789
3790 static short XORReduceAllMasked(short[] a, boolean[] mask) {
3791 short res = 0;
3792 for (int i = 0; i < a.length; i += SPECIES.length()) {
3793 res ^= XORReduceMasked(a, i, mask);
3794 }
3795
3796 return res;
3797 }
3798
3799 @Test(dataProvider = "shortUnaryOpMaskProvider")
3800 static void XORReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3801 short[] a = fa.apply(SPECIES.length());
3802 short[] r = fr.apply(SPECIES.length());
3803 boolean[] mask = fm.apply(SPECIES.length());
3804 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3805 short ra = 0;
3806
3807 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3808 for (int i = 0; i < a.length; i += SPECIES.length()) {
3809 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3810 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3811 }
3812 }
3813
3814 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3815 ra = 0;
3816 for (int i = 0; i < a.length; i += SPECIES.length()) {
3817 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3818 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3819 }
3820 }
3821
3822 assertReductionArraysEqualsMasked(r, ra, a, mask,
3823 Short64VectorTests::XORReduceMasked, Short64VectorTests::XORReduceAllMasked);
3824 }
3825
3826 static short ADDReduce(short[] a, int idx) {
3827 short res = 0;
3828 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3829 res += a[i];
3830 }
3831
3832 return res;
3833 }
3834
3835 static short ADDReduceAll(short[] a) {
3836 short res = 0;
3837 for (int i = 0; i < a.length; i += SPECIES.length()) {
3838 res += ADDReduce(a, i);
3839 }
3840
3841 return res;
3842 }
3843
3844 @Test(dataProvider = "shortUnaryOpProvider")
3845 static void ADDReduceShort64VectorTests(IntFunction<short[]> fa) {
3846 short[] a = fa.apply(SPECIES.length());
3847 short[] r = fr.apply(SPECIES.length());
3848 short ra = 0;
3849
3850 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3851 for (int i = 0; i < a.length; i += SPECIES.length()) {
3852 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3853 r[i] = av.reduceLanes(VectorOperators.ADD);
3854 }
3855 }
3856
3857 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3858 ra = 0;
3859 for (int i = 0; i < a.length; i += SPECIES.length()) {
3860 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3861 ra += av.reduceLanes(VectorOperators.ADD);
3862 }
3863 }
3864
3865 assertReductionArraysEquals(r, ra, a,
3866 Short64VectorTests::ADDReduce, Short64VectorTests::ADDReduceAll);
3867 }
3868
3869 static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
3870 short res = 0;
3871 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3872 if (mask[i % SPECIES.length()])
3873 res += a[i];
3874 }
3875
3876 return res;
3877 }
3878
3879 static short ADDReduceAllMasked(short[] a, boolean[] mask) {
3880 short res = 0;
3881 for (int i = 0; i < a.length; i += SPECIES.length()) {
3882 res += ADDReduceMasked(a, i, mask);
3883 }
3884
3885 return res;
3886 }
3887
3888 @Test(dataProvider = "shortUnaryOpMaskProvider")
3889 static void ADDReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3890 short[] a = fa.apply(SPECIES.length());
3891 short[] r = fr.apply(SPECIES.length());
3892 boolean[] mask = fm.apply(SPECIES.length());
3893 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3894 short ra = 0;
3895
3896 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3897 for (int i = 0; i < a.length; i += SPECIES.length()) {
3898 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3899 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3900 }
3901 }
3902
3903 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3904 ra = 0;
3905 for (int i = 0; i < a.length; i += SPECIES.length()) {
3906 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3907 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3908 }
3909 }
3910
3911 assertReductionArraysEqualsMasked(r, ra, a, mask,
3912 Short64VectorTests::ADDReduceMasked, Short64VectorTests::ADDReduceAllMasked);
3913 }
3914
3915 static short MULReduce(short[] a, int idx) {
3916 short res = 1;
3917 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3918 res *= a[i];
3919 }
3920
3921 return res;
3922 }
3923
3924 static short MULReduceAll(short[] a) {
3925 short res = 1;
3926 for (int i = 0; i < a.length; i += SPECIES.length()) {
3927 res *= MULReduce(a, i);
3928 }
3929
3930 return res;
3931 }
3932
3933 @Test(dataProvider = "shortUnaryOpProvider")
3934 static void MULReduceShort64VectorTests(IntFunction<short[]> fa) {
3935 short[] a = fa.apply(SPECIES.length());
3936 short[] r = fr.apply(SPECIES.length());
3937 short ra = 1;
3938
3939 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3940 for (int i = 0; i < a.length; i += SPECIES.length()) {
3941 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3942 r[i] = av.reduceLanes(VectorOperators.MUL);
3943 }
3944 }
3945
3946 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3947 ra = 1;
3948 for (int i = 0; i < a.length; i += SPECIES.length()) {
3949 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3950 ra *= av.reduceLanes(VectorOperators.MUL);
3951 }
3952 }
3953
3954 assertReductionArraysEquals(r, ra, a,
3955 Short64VectorTests::MULReduce, Short64VectorTests::MULReduceAll);
3956 }
3957
3958 static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
3959 short res = 1;
3960 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3961 if (mask[i % SPECIES.length()])
3962 res *= a[i];
3963 }
3964
3965 return res;
3966 }
3967
3968 static short MULReduceAllMasked(short[] a, boolean[] mask) {
3969 short res = 1;
3970 for (int i = 0; i < a.length; i += SPECIES.length()) {
3971 res *= MULReduceMasked(a, i, mask);
3972 }
3973
3974 return res;
3975 }
3976
3977 @Test(dataProvider = "shortUnaryOpMaskProvider")
3978 static void MULReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3979 short[] a = fa.apply(SPECIES.length());
3980 short[] r = fr.apply(SPECIES.length());
3981 boolean[] mask = fm.apply(SPECIES.length());
3982 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3983 short ra = 1;
3984
3985 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3986 for (int i = 0; i < a.length; i += SPECIES.length()) {
3987 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3988 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3989 }
3990 }
3991
3992 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3993 ra = 1;
3994 for (int i = 0; i < a.length; i += SPECIES.length()) {
3995 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3996 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3997 }
3998 }
3999
4000 assertReductionArraysEqualsMasked(r, ra, a, mask,
4001 Short64VectorTests::MULReduceMasked, Short64VectorTests::MULReduceAllMasked);
4002 }
4003
4004 static short MINReduce(short[] a, int idx) {
4005 short res = Short.MAX_VALUE;
4006 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4007 res = (short) Math.min(res, a[i]);
4008 }
4009
4010 return res;
4011 }
4012
4013 static short MINReduceAll(short[] a) {
4014 short res = Short.MAX_VALUE;
4015 for (int i = 0; i < a.length; i += SPECIES.length()) {
4016 res = (short) Math.min(res, MINReduce(a, i));
4017 }
4018
4019 return res;
4020 }
4021
4022 @Test(dataProvider = "shortUnaryOpProvider")
4023 static void MINReduceShort64VectorTests(IntFunction<short[]> fa) {
4024 short[] a = fa.apply(SPECIES.length());
4025 short[] r = fr.apply(SPECIES.length());
4026 short ra = Short.MAX_VALUE;
4027
4028 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4029 for (int i = 0; i < a.length; i += SPECIES.length()) {
4030 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4031 r[i] = av.reduceLanes(VectorOperators.MIN);
4032 }
4033 }
4034
4035 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4036 ra = Short.MAX_VALUE;
4037 for (int i = 0; i < a.length; i += SPECIES.length()) {
4038 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4039 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
4040 }
4041 }
4042
4043 assertReductionArraysEquals(r, ra, a,
4044 Short64VectorTests::MINReduce, Short64VectorTests::MINReduceAll);
4045 }
4046
4047 static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
4048 short res = Short.MAX_VALUE;
4049 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4050 if (mask[i % SPECIES.length()])
4051 res = (short) Math.min(res, a[i]);
4052 }
4053
4054 return res;
4055 }
4056
4057 static short MINReduceAllMasked(short[] a, boolean[] mask) {
4058 short res = Short.MAX_VALUE;
4059 for (int i = 0; i < a.length; i += SPECIES.length()) {
4060 res = (short) Math.min(res, MINReduceMasked(a, i, mask));
4061 }
4062
4063 return res;
4064 }
4065
4066 @Test(dataProvider = "shortUnaryOpMaskProvider")
4067 static void MINReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4068 short[] a = fa.apply(SPECIES.length());
4069 short[] r = fr.apply(SPECIES.length());
4070 boolean[] mask = fm.apply(SPECIES.length());
4071 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4072 short ra = Short.MAX_VALUE;
4073
4074 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4075 for (int i = 0; i < a.length; i += SPECIES.length()) {
4076 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4077 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
4078 }
4079 }
4080
4081 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4082 ra = Short.MAX_VALUE;
4083 for (int i = 0; i < a.length; i += SPECIES.length()) {
4084 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4085 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
4086 }
4087 }
4088
4089 assertReductionArraysEqualsMasked(r, ra, a, mask,
4090 Short64VectorTests::MINReduceMasked, Short64VectorTests::MINReduceAllMasked);
4091 }
4092
4093 static short MAXReduce(short[] a, int idx) {
4094 short res = Short.MIN_VALUE;
4095 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4096 res = (short) Math.max(res, a[i]);
4097 }
4098
4099 return res;
4100 }
4101
4102 static short MAXReduceAll(short[] a) {
4103 short res = Short.MIN_VALUE;
4104 for (int i = 0; i < a.length; i += SPECIES.length()) {
4105 res = (short) Math.max(res, MAXReduce(a, i));
4106 }
4107
4108 return res;
4109 }
4110
4111 @Test(dataProvider = "shortUnaryOpProvider")
4112 static void MAXReduceShort64VectorTests(IntFunction<short[]> fa) {
4113 short[] a = fa.apply(SPECIES.length());
4114 short[] r = fr.apply(SPECIES.length());
4115 short ra = Short.MIN_VALUE;
4116
4117 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4118 for (int i = 0; i < a.length; i += SPECIES.length()) {
4119 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4120 r[i] = av.reduceLanes(VectorOperators.MAX);
4121 }
4122 }
4123
4124 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4125 ra = Short.MIN_VALUE;
4126 for (int i = 0; i < a.length; i += SPECIES.length()) {
4127 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4128 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
4129 }
4130 }
4131
4132 assertReductionArraysEquals(r, ra, a,
4133 Short64VectorTests::MAXReduce, Short64VectorTests::MAXReduceAll);
4134 }
4135
4136 static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
4137 short res = Short.MIN_VALUE;
4138 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4139 if (mask[i % SPECIES.length()])
4140 res = (short) Math.max(res, a[i]);
4141 }
4142
4143 return res;
4144 }
4145
4146 static short MAXReduceAllMasked(short[] a, boolean[] mask) {
4147 short res = Short.MIN_VALUE;
4148 for (int i = 0; i < a.length; i += SPECIES.length()) {
4149 res = (short) Math.max(res, MAXReduceMasked(a, i, mask));
4150 }
4151
4152 return res;
4153 }
4154
4155 @Test(dataProvider = "shortUnaryOpMaskProvider")
4156 static void MAXReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4157 short[] a = fa.apply(SPECIES.length());
4158 short[] r = fr.apply(SPECIES.length());
4159 boolean[] mask = fm.apply(SPECIES.length());
4160 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4161 short ra = Short.MIN_VALUE;
4162
4163 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4164 for (int i = 0; i < a.length; i += SPECIES.length()) {
4165 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4166 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
4167 }
4168 }
4169
4170 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4171 ra = Short.MIN_VALUE;
4172 for (int i = 0; i < a.length; i += SPECIES.length()) {
4173 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4174 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
4175 }
4176 }
4177
4178 assertReductionArraysEqualsMasked(r, ra, a, mask,
4179 Short64VectorTests::MAXReduceMasked, Short64VectorTests::MAXReduceAllMasked);
4180 }
4181
4182 static short UMINReduce(short[] a, int idx) {
4183 short res = Short.MAX_VALUE;
4184 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4185 res = (short) VectorMath.minUnsigned(res, a[i]);
4186 }
4187
4188 return res;
4189 }
4190
4191 static short UMINReduceAll(short[] a) {
4192 short res = Short.MAX_VALUE;
4193 for (int i = 0; i < a.length; i += SPECIES.length()) {
4194 res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
4195 }
4196
4197 return res;
4198 }
4199
4200 @Test(dataProvider = "shortUnaryOpProvider")
4201 static void UMINReduceShort64VectorTests(IntFunction<short[]> fa) {
4202 short[] a = fa.apply(SPECIES.length());
4203 short[] r = fr.apply(SPECIES.length());
4204 short ra = Short.MAX_VALUE;
4205
4206 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4207 for (int i = 0; i < a.length; i += SPECIES.length()) {
4208 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4209 r[i] = av.reduceLanes(VectorOperators.UMIN);
4210 }
4211 }
4212
4213 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4214 ra = Short.MAX_VALUE;
4215 for (int i = 0; i < a.length; i += SPECIES.length()) {
4216 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4217 ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
4218 }
4219 }
4220
4221 assertReductionArraysEquals(r, ra, a,
4222 Short64VectorTests::UMINReduce, Short64VectorTests::UMINReduceAll);
4223 }
4224
4225 static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
4226 short res = Short.MAX_VALUE;
4227 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4228 if (mask[i % SPECIES.length()])
4229 res = (short) VectorMath.minUnsigned(res, a[i]);
4230 }
4231
4232 return res;
4233 }
4234
4235 static short UMINReduceAllMasked(short[] a, boolean[] mask) {
4236 short res = Short.MAX_VALUE;
4237 for (int i = 0; i < a.length; i += SPECIES.length()) {
4238 res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
4239 }
4240
4241 return res;
4242 }
4243
4244 @Test(dataProvider = "shortUnaryOpMaskProvider")
4245 static void UMINReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4246 short[] a = fa.apply(SPECIES.length());
4247 short[] r = fr.apply(SPECIES.length());
4248 boolean[] mask = fm.apply(SPECIES.length());
4249 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4250 short ra = Short.MAX_VALUE;
4251
4252 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4253 for (int i = 0; i < a.length; i += SPECIES.length()) {
4254 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4255 r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
4256 }
4257 }
4258
4259 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4260 ra = Short.MAX_VALUE;
4261 for (int i = 0; i < a.length; i += SPECIES.length()) {
4262 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4263 ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
4264 }
4265 }
4266
4267 assertReductionArraysEqualsMasked(r, ra, a, mask,
4268 Short64VectorTests::UMINReduceMasked, Short64VectorTests::UMINReduceAllMasked);
4269 }
4270
4271 static short UMAXReduce(short[] a, int idx) {
4272 short res = Short.MIN_VALUE;
4273 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4274 res = (short) VectorMath.maxUnsigned(res, a[i]);
4275 }
4276
4277 return res;
4278 }
4279
4280 static short UMAXReduceAll(short[] a) {
4281 short res = Short.MIN_VALUE;
4282 for (int i = 0; i < a.length; i += SPECIES.length()) {
4283 res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
4284 }
4285
4286 return res;
4287 }
4288
4289 @Test(dataProvider = "shortUnaryOpProvider")
4290 static void UMAXReduceShort64VectorTests(IntFunction<short[]> fa) {
4291 short[] a = fa.apply(SPECIES.length());
4292 short[] r = fr.apply(SPECIES.length());
4293 short ra = Short.MIN_VALUE;
4294
4295 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4296 for (int i = 0; i < a.length; i += SPECIES.length()) {
4297 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4298 r[i] = av.reduceLanes(VectorOperators.UMAX);
4299 }
4300 }
4301
4302 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4303 ra = Short.MIN_VALUE;
4304 for (int i = 0; i < a.length; i += SPECIES.length()) {
4305 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4306 ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
4307 }
4308 }
4309
4310 assertReductionArraysEquals(r, ra, a,
4311 Short64VectorTests::UMAXReduce, Short64VectorTests::UMAXReduceAll);
4312 }
4313
4314 static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
4315 short res = Short.MIN_VALUE;
4316 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4317 if (mask[i % SPECIES.length()])
4318 res = (short) VectorMath.maxUnsigned(res, a[i]);
4319 }
4320
4321 return res;
4322 }
4323
4324 static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
4325 short res = Short.MIN_VALUE;
4326 for (int i = 0; i < a.length; i += SPECIES.length()) {
4327 res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
4328 }
4329
4330 return res;
4331 }
4332
4333 @Test(dataProvider = "shortUnaryOpMaskProvider")
4334 static void UMAXReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4335 short[] a = fa.apply(SPECIES.length());
4336 short[] r = fr.apply(SPECIES.length());
4337 boolean[] mask = fm.apply(SPECIES.length());
4338 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4339 short ra = Short.MIN_VALUE;
4340
4341 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4342 for (int i = 0; i < a.length; i += SPECIES.length()) {
4343 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4344 r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
4345 }
4346 }
4347
4348 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4349 ra = Short.MIN_VALUE;
4350 for (int i = 0; i < a.length; i += SPECIES.length()) {
4351 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4352 ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
4353 }
4354 }
4355
4356 assertReductionArraysEqualsMasked(r, ra, a, mask,
4357 Short64VectorTests::UMAXReduceMasked, Short64VectorTests::UMAXReduceAllMasked);
4358 }
4359
4360 static short FIRST_NONZEROReduce(short[] a, int idx) {
4361 short res = (short) 0;
4362 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4363 res = firstNonZero(res, a[i]);
4364 }
4365
4366 return res;
4367 }
4368
4369 static short FIRST_NONZEROReduceAll(short[] a) {
4370 short res = (short) 0;
4371 for (int i = 0; i < a.length; i += SPECIES.length()) {
4372 res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
4373 }
4374
4375 return res;
4376 }
4377
4378 @Test(dataProvider = "shortUnaryOpProvider")
4379 static void FIRST_NONZEROReduceShort64VectorTests(IntFunction<short[]> fa) {
4380 short[] a = fa.apply(SPECIES.length());
4381 short[] r = fr.apply(SPECIES.length());
4382 short ra = (short) 0;
4383
4384 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4385 for (int i = 0; i < a.length; i += SPECIES.length()) {
4386 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4387 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
4388 }
4389 }
4390
4391 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4392 ra = (short) 0;
4393 for (int i = 0; i < a.length; i += SPECIES.length()) {
4394 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4395 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
4396 }
4397 }
4398
4399 assertReductionArraysEquals(r, ra, a,
4400 Short64VectorTests::FIRST_NONZEROReduce, Short64VectorTests::FIRST_NONZEROReduceAll);
4401 }
4402
4403 static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) {
4404 short res = (short) 0;
4405 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4406 if (mask[i % SPECIES.length()])
4407 res = firstNonZero(res, a[i]);
4408 }
4409
4410 return res;
4411 }
4412
4413 static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) {
4414 short res = (short) 0;
4415 for (int i = 0; i < a.length; i += SPECIES.length()) {
4416 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
4417 }
4418
4419 return res;
4420 }
4421
4422 @Test(dataProvider = "shortUnaryOpMaskProvider")
4423 static void FIRST_NONZEROReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4424 short[] a = fa.apply(SPECIES.length());
4425 short[] r = fr.apply(SPECIES.length());
4426 boolean[] mask = fm.apply(SPECIES.length());
4427 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4428 short ra = (short) 0;
4429
4430 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4431 for (int i = 0; i < a.length; i += SPECIES.length()) {
4432 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4433 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
4434 }
4435 }
4436
4437 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4438 ra = (short) 0;
4439 for (int i = 0; i < a.length; i += SPECIES.length()) {
4440 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4441 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
4442 }
4443 }
4444
4445 assertReductionArraysEqualsMasked(r, ra, a, mask,
4446 Short64VectorTests::FIRST_NONZEROReduceMasked, Short64VectorTests::FIRST_NONZEROReduceAllMasked);
4447 }
4448
4449 static boolean anyTrue(boolean[] a, int idx) {
4450 boolean res = false;
4451 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4452 res |= a[i];
4453 }
4454
4455 return res;
4456 }
4457
4458 @Test(dataProvider = "boolUnaryOpProvider")
4459 static void anyTrueShort64VectorTests(IntFunction<boolean[]> fm) {
4460 boolean[] mask = fm.apply(SPECIES.length());
4461 boolean[] r = fmr.apply(SPECIES.length());
4462
4463 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4464 for (int i = 0; i < mask.length; i += SPECIES.length()) {
4465 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
4466 r[i] = vmask.anyTrue();
4467 }
4468 }
4469
4470 assertReductionBoolArraysEquals(r, mask, Short64VectorTests::anyTrue);
4471 }
4472
4473 static boolean allTrue(boolean[] a, int idx) {
4474 boolean res = true;
4475 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4476 res &= a[i];
4477 }
4478
4479 return res;
4480 }
4481
4482 @Test(dataProvider = "boolUnaryOpProvider")
4483 static void allTrueShort64VectorTests(IntFunction<boolean[]> fm) {
4484 boolean[] mask = fm.apply(SPECIES.length());
4485 boolean[] r = fmr.apply(SPECIES.length());
4486
4487 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4488 for (int i = 0; i < mask.length; i += SPECIES.length()) {
4489 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
4490 r[i] = vmask.allTrue();
4491 }
4492 }
4493
4494 assertReductionBoolArraysEquals(r, mask, Short64VectorTests::allTrue);
4495 }
4496
4497 static short SUADDReduce(short[] a, int idx) {
4498 short res = 0;
4499 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4500 res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
4501 }
4502
4503 return res;
4504 }
4505
4506 static short SUADDReduceAll(short[] a) {
4507 short res = 0;
4508 for (int i = 0; i < a.length; i += SPECIES.length()) {
4509 res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i));
4510 }
4511
4512 return res;
4513 }
4514
4515 @Test(dataProvider = "shortSaturatingUnaryOpProvider")
4516 static void SUADDReduceShort64VectorTests(IntFunction<short[]> fa) {
4517 short[] a = fa.apply(SPECIES.length());
4518 short[] r = fr.apply(SPECIES.length());
4519 short ra = 0;
4520
4521 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4522 for (int i = 0; i < a.length; i += SPECIES.length()) {
4523 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4524 r[i] = av.reduceLanes(VectorOperators.SUADD);
4525 }
4526 }
4527
4528 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4529 ra = 0;
4530 for (int i = 0; i < a.length; i += SPECIES.length()) {
4531 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4532 ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD));
4533 }
4534 }
4535
4536 assertReductionArraysEquals(r, ra, a,
4537 Short64VectorTests::SUADDReduce, Short64VectorTests::SUADDReduceAll);
4538 }
4539
4540 static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) {
4541 short res = 0;
4542 for (int i = idx; i < (idx + SPECIES.length()); i++) {
4543 if (mask[i % SPECIES.length()])
4544 res = (short) VectorMath.addSaturatingUnsigned(res, a[i]);
4545 }
4546
4547 return res;
4548 }
4549
4550 static short SUADDReduceAllMasked(short[] a, boolean[] mask) {
4551 short res = 0;
4552 for (int i = 0; i < a.length; i += SPECIES.length()) {
4553 res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask));
4554 }
4555
4556 return res;
4557 }
4558 @Test(dataProvider = "shortSaturatingUnaryOpMaskProvider")
4559 static void SUADDReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
4560 short[] a = fa.apply(SPECIES.length());
4561 short[] r = fr.apply(SPECIES.length());
4562 boolean[] mask = fm.apply(SPECIES.length());
4563 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4564 short ra = 0;
4565
4566 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4567 for (int i = 0; i < a.length; i += SPECIES.length()) {
4568 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4569 r[i] = av.reduceLanes(VectorOperators.SUADD, vmask);
4570 }
4571 }
4572
4573 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4574 ra = 0;
4575 for (int i = 0; i < a.length; i += SPECIES.length()) {
4576 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4577 ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask));
4578 }
4579 }
4580
4581 assertReductionArraysEqualsMasked(r, ra, a, mask,
4582 Short64VectorTests::SUADDReduceMasked, Short64VectorTests::SUADDReduceAllMasked);
4583 }
4584
4585 @Test(dataProvider = "shortBinaryOpProvider")
4586 static void withShort64VectorTests(IntFunction<short []> fa, IntFunction<short []> fb) {
4587 short[] a = fa.apply(SPECIES.length());
4588 short[] b = fb.apply(SPECIES.length());
4589 short[] r = fr.apply(SPECIES.length());
4590
4591 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4592 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
4593 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4594 av.withLane(j, b[i + j]).intoArray(r, i);
4595 a[i + j] = b[i + j];
4596 j = (j + 1) & (SPECIES.length() - 1);
4597 }
4598 }
4599
4600
4601 assertArraysStrictlyEquals(r, a);
4602 }
4603
4604 static boolean testIS_DEFAULT(short a) {
4605 return bits(a)==0;
4606 }
4607
4608 @Test(dataProvider = "shortTestOpProvider")
4609 static void IS_DEFAULTShort64VectorTests(IntFunction<short[]> fa) {
4610 short[] a = fa.apply(SPECIES.length());
4611
4612 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4613 for (int i = 0; i < a.length; i += SPECIES.length()) {
4614 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4615 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT);
4616
4617 // Check results as part of computation.
4618 for (int j = 0; j < SPECIES.length(); j++) {
4619 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
4620 }
4621 }
4622 }
4623 }
4624
4625 @Test(dataProvider = "shortTestOpMaskProvider")
4626 static void IS_DEFAULTMaskedShort64VectorTests(IntFunction<short[]> fa,
4627 IntFunction<boolean[]> fm) {
4628 short[] a = fa.apply(SPECIES.length());
4629 boolean[] mask = fm.apply(SPECIES.length());
4630 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4631
4632 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4633 for (int i = 0; i < a.length; i += SPECIES.length()) {
4634 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4635 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
4636
4637 // Check results as part of computation.
4638 for (int j = 0; j < SPECIES.length(); j++) {
4639 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
4640 }
4641 }
4642 }
4643 }
4644
4645 static boolean testIS_NEGATIVE(short a) {
4646 return bits(a)<0;
4647 }
4648
4649 @Test(dataProvider = "shortTestOpProvider")
4650 static void IS_NEGATIVEShort64VectorTests(IntFunction<short[]> fa) {
4651 short[] a = fa.apply(SPECIES.length());
4652
4653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4654 for (int i = 0; i < a.length; i += SPECIES.length()) {
4655 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4656 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE);
4657
4658 // Check results as part of computation.
4659 for (int j = 0; j < SPECIES.length(); j++) {
4660 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
4661 }
4662 }
4663 }
4664 }
4665
4666 @Test(dataProvider = "shortTestOpMaskProvider")
4667 static void IS_NEGATIVEMaskedShort64VectorTests(IntFunction<short[]> fa,
4668 IntFunction<boolean[]> fm) {
4669 short[] a = fa.apply(SPECIES.length());
4670 boolean[] mask = fm.apply(SPECIES.length());
4671 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4672
4673 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4674 for (int i = 0; i < a.length; i += SPECIES.length()) {
4675 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4676 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
4677
4678 // Check results as part of computation.
4679 for (int j = 0; j < SPECIES.length(); j++) {
4680 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
4681 }
4682 }
4683 }
4684 }
4685
4686 @Test(dataProvider = "shortCompareOpProvider")
4687 static void LTShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4688 short[] a = fa.apply(SPECIES.length());
4689 short[] b = fb.apply(SPECIES.length());
4690
4691 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4692 for (int i = 0; i < a.length; i += SPECIES.length()) {
4693 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4694 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4695 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv);
4696
4697 // Check results as part of computation.
4698 for (int j = 0; j < SPECIES.length(); j++) {
4699 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4700 }
4701 }
4702 }
4703 }
4704
4705 @Test(dataProvider = "shortCompareOpProvider")
4706 static void ltShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4707 short[] a = fa.apply(SPECIES.length());
4708 short[] b = fb.apply(SPECIES.length());
4709
4710 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4711 for (int i = 0; i < a.length; i += SPECIES.length()) {
4712 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4713 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4714 VectorMask<Short> mv = av.lt(bv);
4715
4716 // Check results as part of computation.
4717 for (int j = 0; j < SPECIES.length(); j++) {
4718 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
4719 }
4720 }
4721 }
4722 }
4723
4724 @Test(dataProvider = "shortCompareOpMaskProvider")
4725 static void LTShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4726 IntFunction<boolean[]> fm) {
4727 short[] a = fa.apply(SPECIES.length());
4728 short[] b = fb.apply(SPECIES.length());
4729 boolean[] mask = fm.apply(SPECIES.length());
4730
4731 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4732
4733 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4734 for (int i = 0; i < a.length; i += SPECIES.length()) {
4735 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4736 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4737 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask);
4738
4739 // Check results as part of computation.
4740 for (int j = 0; j < SPECIES.length(); j++) {
4741 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
4742 }
4743 }
4744 }
4745 }
4746
4747 @Test(dataProvider = "shortCompareOpProvider")
4748 static void GTShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4749 short[] a = fa.apply(SPECIES.length());
4750 short[] b = fb.apply(SPECIES.length());
4751
4752 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4753 for (int i = 0; i < a.length; i += SPECIES.length()) {
4754 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4755 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4756 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv);
4757
4758 // Check results as part of computation.
4759 for (int j = 0; j < SPECIES.length(); j++) {
4760 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
4761 }
4762 }
4763 }
4764 }
4765
4766 @Test(dataProvider = "shortCompareOpMaskProvider")
4767 static void GTShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4768 IntFunction<boolean[]> fm) {
4769 short[] a = fa.apply(SPECIES.length());
4770 short[] b = fb.apply(SPECIES.length());
4771 boolean[] mask = fm.apply(SPECIES.length());
4772
4773 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4774
4775 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4776 for (int i = 0; i < a.length; i += SPECIES.length()) {
4777 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4778 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4779 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask);
4780
4781 // Check results as part of computation.
4782 for (int j = 0; j < SPECIES.length(); j++) {
4783 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
4784 }
4785 }
4786 }
4787 }
4788
4789 @Test(dataProvider = "shortCompareOpProvider")
4790 static void EQShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4791 short[] a = fa.apply(SPECIES.length());
4792 short[] b = fb.apply(SPECIES.length());
4793
4794 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4795 for (int i = 0; i < a.length; i += SPECIES.length()) {
4796 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4797 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4798 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv);
4799
4800 // Check results as part of computation.
4801 for (int j = 0; j < SPECIES.length(); j++) {
4802 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4803 }
4804 }
4805 }
4806 }
4807
4808 @Test(dataProvider = "shortCompareOpProvider")
4809 static void eqShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4810 short[] a = fa.apply(SPECIES.length());
4811 short[] b = fb.apply(SPECIES.length());
4812
4813 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4814 for (int i = 0; i < a.length; i += SPECIES.length()) {
4815 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4816 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4817 VectorMask<Short> mv = av.eq(bv);
4818
4819 // Check results as part of computation.
4820 for (int j = 0; j < SPECIES.length(); j++) {
4821 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4822 }
4823 }
4824 }
4825 }
4826
4827 @Test(dataProvider = "shortCompareOpMaskProvider")
4828 static void EQShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4829 IntFunction<boolean[]> fm) {
4830 short[] a = fa.apply(SPECIES.length());
4831 short[] b = fb.apply(SPECIES.length());
4832 boolean[] mask = fm.apply(SPECIES.length());
4833
4834 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4835
4836 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4837 for (int i = 0; i < a.length; i += SPECIES.length()) {
4838 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4839 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4840 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask);
4841
4842 // Check results as part of computation.
4843 for (int j = 0; j < SPECIES.length(); j++) {
4844 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4845 }
4846 }
4847 }
4848 }
4849
4850 @Test(dataProvider = "shortCompareOpProvider")
4851 static void NEShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4852 short[] a = fa.apply(SPECIES.length());
4853 short[] b = fb.apply(SPECIES.length());
4854
4855 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4856 for (int i = 0; i < a.length; i += SPECIES.length()) {
4857 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4858 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4859 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv);
4860
4861 // Check results as part of computation.
4862 for (int j = 0; j < SPECIES.length(); j++) {
4863 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4864 }
4865 }
4866 }
4867 }
4868
4869 @Test(dataProvider = "shortCompareOpMaskProvider")
4870 static void NEShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4871 IntFunction<boolean[]> fm) {
4872 short[] a = fa.apply(SPECIES.length());
4873 short[] b = fb.apply(SPECIES.length());
4874 boolean[] mask = fm.apply(SPECIES.length());
4875
4876 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4877
4878 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4879 for (int i = 0; i < a.length; i += SPECIES.length()) {
4880 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4881 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4882 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask);
4883
4884 // Check results as part of computation.
4885 for (int j = 0; j < SPECIES.length(); j++) {
4886 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4887 }
4888 }
4889 }
4890 }
4891
4892 @Test(dataProvider = "shortCompareOpProvider")
4893 static void LEShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4894 short[] a = fa.apply(SPECIES.length());
4895 short[] b = fb.apply(SPECIES.length());
4896
4897 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4898 for (int i = 0; i < a.length; i += SPECIES.length()) {
4899 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4900 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4901 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv);
4902
4903 // Check results as part of computation.
4904 for (int j = 0; j < SPECIES.length(); j++) {
4905 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4906 }
4907 }
4908 }
4909 }
4910
4911 @Test(dataProvider = "shortCompareOpMaskProvider")
4912 static void LEShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4913 IntFunction<boolean[]> fm) {
4914 short[] a = fa.apply(SPECIES.length());
4915 short[] b = fb.apply(SPECIES.length());
4916 boolean[] mask = fm.apply(SPECIES.length());
4917
4918 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4919
4920 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4921 for (int i = 0; i < a.length; i += SPECIES.length()) {
4922 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4923 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4924 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask);
4925
4926 // Check results as part of computation.
4927 for (int j = 0; j < SPECIES.length(); j++) {
4928 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4929 }
4930 }
4931 }
4932 }
4933
4934 @Test(dataProvider = "shortCompareOpProvider")
4935 static void GEShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4936 short[] a = fa.apply(SPECIES.length());
4937 short[] b = fb.apply(SPECIES.length());
4938
4939 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4940 for (int i = 0; i < a.length; i += SPECIES.length()) {
4941 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4942 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4943 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv);
4944
4945 // Check results as part of computation.
4946 for (int j = 0; j < SPECIES.length(); j++) {
4947 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4948 }
4949 }
4950 }
4951 }
4952
4953 @Test(dataProvider = "shortCompareOpMaskProvider")
4954 static void GEShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4955 IntFunction<boolean[]> fm) {
4956 short[] a = fa.apply(SPECIES.length());
4957 short[] b = fb.apply(SPECIES.length());
4958 boolean[] mask = fm.apply(SPECIES.length());
4959
4960 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4961
4962 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4963 for (int i = 0; i < a.length; i += SPECIES.length()) {
4964 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4965 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4966 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask);
4967
4968 // Check results as part of computation.
4969 for (int j = 0; j < SPECIES.length(); j++) {
4970 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4971 }
4972 }
4973 }
4974 }
4975
4976 @Test(dataProvider = "shortCompareOpProvider")
4977 static void ULTShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4978 short[] a = fa.apply(SPECIES.length());
4979 short[] b = fb.apply(SPECIES.length());
4980
4981 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4982 for (int i = 0; i < a.length; i += SPECIES.length()) {
4983 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4984 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4985 VectorMask<Short> mv = av.compare(VectorOperators.ULT, bv);
4986
4987 // Check results as part of computation.
4988 for (int j = 0; j < SPECIES.length(); j++) {
4989 Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4990 }
4991 }
4992 }
4993 }
4994
4995 @Test(dataProvider = "shortCompareOpMaskProvider")
4996 static void ULTShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4997 IntFunction<boolean[]> fm) {
4998 short[] a = fa.apply(SPECIES.length());
4999 short[] b = fb.apply(SPECIES.length());
5000 boolean[] mask = fm.apply(SPECIES.length());
5001
5002 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5003
5004 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5005 for (int i = 0; i < a.length; i += SPECIES.length()) {
5006 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5007 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5008 VectorMask<Short> mv = av.compare(VectorOperators.ULT, bv, vmask);
5009
5010 // Check results as part of computation.
5011 for (int j = 0; j < SPECIES.length(); j++) {
5012 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
5013 }
5014 }
5015 }
5016 }
5017
5018 @Test(dataProvider = "shortCompareOpProvider")
5019 static void UGTShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5020 short[] a = fa.apply(SPECIES.length());
5021 short[] b = fb.apply(SPECIES.length());
5022
5023 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5024 for (int i = 0; i < a.length; i += SPECIES.length()) {
5025 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5026 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5027 VectorMask<Short> mv = av.compare(VectorOperators.UGT, bv);
5028
5029 // Check results as part of computation.
5030 for (int j = 0; j < SPECIES.length(); j++) {
5031 Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
5032 }
5033 }
5034 }
5035 }
5036
5037 @Test(dataProvider = "shortCompareOpMaskProvider")
5038 static void UGTShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5039 IntFunction<boolean[]> fm) {
5040 short[] a = fa.apply(SPECIES.length());
5041 short[] b = fb.apply(SPECIES.length());
5042 boolean[] mask = fm.apply(SPECIES.length());
5043
5044 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5045
5046 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5047 for (int i = 0; i < a.length; i += SPECIES.length()) {
5048 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5049 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5050 VectorMask<Short> mv = av.compare(VectorOperators.UGT, bv, vmask);
5051
5052 // Check results as part of computation.
5053 for (int j = 0; j < SPECIES.length(); j++) {
5054 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
5055 }
5056 }
5057 }
5058 }
5059
5060 @Test(dataProvider = "shortCompareOpProvider")
5061 static void ULEShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5062 short[] a = fa.apply(SPECIES.length());
5063 short[] b = fb.apply(SPECIES.length());
5064
5065 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5066 for (int i = 0; i < a.length; i += SPECIES.length()) {
5067 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5068 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5069 VectorMask<Short> mv = av.compare(VectorOperators.ULE, bv);
5070
5071 // Check results as part of computation.
5072 for (int j = 0; j < SPECIES.length(); j++) {
5073 Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
5074 }
5075 }
5076 }
5077 }
5078
5079 @Test(dataProvider = "shortCompareOpMaskProvider")
5080 static void ULEShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5081 IntFunction<boolean[]> fm) {
5082 short[] a = fa.apply(SPECIES.length());
5083 short[] b = fb.apply(SPECIES.length());
5084 boolean[] mask = fm.apply(SPECIES.length());
5085
5086 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5087
5088 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5089 for (int i = 0; i < a.length; i += SPECIES.length()) {
5090 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5091 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5092 VectorMask<Short> mv = av.compare(VectorOperators.ULE, bv, vmask);
5093
5094 // Check results as part of computation.
5095 for (int j = 0; j < SPECIES.length(); j++) {
5096 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
5097 }
5098 }
5099 }
5100 }
5101
5102 @Test(dataProvider = "shortCompareOpProvider")
5103 static void UGEShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5104 short[] a = fa.apply(SPECIES.length());
5105 short[] b = fb.apply(SPECIES.length());
5106
5107 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5108 for (int i = 0; i < a.length; i += SPECIES.length()) {
5109 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5110 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5111 VectorMask<Short> mv = av.compare(VectorOperators.UGE, bv);
5112
5113 // Check results as part of computation.
5114 for (int j = 0; j < SPECIES.length(); j++) {
5115 Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
5116 }
5117 }
5118 }
5119 }
5120
5121 @Test(dataProvider = "shortCompareOpMaskProvider")
5122 static void UGEShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5123 IntFunction<boolean[]> fm) {
5124 short[] a = fa.apply(SPECIES.length());
5125 short[] b = fb.apply(SPECIES.length());
5126 boolean[] mask = fm.apply(SPECIES.length());
5127
5128 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5129
5130 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5131 for (int i = 0; i < a.length; i += SPECIES.length()) {
5132 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5133 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5134 VectorMask<Short> mv = av.compare(VectorOperators.UGE, bv, vmask);
5135
5136 // Check results as part of computation.
5137 for (int j = 0; j < SPECIES.length(); j++) {
5138 Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
5139 }
5140 }
5141 }
5142 }
5143
5144 @Test(dataProvider = "shortCompareOpProvider")
5145 static void LTShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5146 short[] a = fa.apply(SPECIES.length());
5147 short[] b = fb.apply(SPECIES.length());
5148
5149 for (int i = 0; i < a.length; i += SPECIES.length()) {
5150 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5151 VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]);
5152
5153 // Check results as part of computation.
5154 for (int j = 0; j < SPECIES.length(); j++) {
5155 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5156 }
5157 }
5158 }
5159
5160 @Test(dataProvider = "shortCompareOpMaskProvider")
5161 static void LTShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
5162 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5163 short[] a = fa.apply(SPECIES.length());
5164 short[] b = fb.apply(SPECIES.length());
5165 boolean[] mask = fm.apply(SPECIES.length());
5166
5167 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5168
5169 for (int i = 0; i < a.length; i += SPECIES.length()) {
5170 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5171 VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask);
5172
5173 // Check results as part of computation.
5174 for (int j = 0; j < SPECIES.length(); j++) {
5175 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
5176 }
5177 }
5178 }
5179
5180 @Test(dataProvider = "shortCompareOpProvider")
5181 static void LTShort64VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5182 short[] a = fa.apply(SPECIES.length());
5183 short[] b = fb.apply(SPECIES.length());
5184
5185 for (int i = 0; i < a.length; i += SPECIES.length()) {
5186 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5187 VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]);
5188
5189 // Check results as part of computation.
5190 for (int j = 0; j < SPECIES.length(); j++) {
5191 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
5192 }
5193 }
5194 }
5195
5196 @Test(dataProvider = "shortCompareOpMaskProvider")
5197 static void LTShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
5198 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5199 short[] a = fa.apply(SPECIES.length());
5200 short[] b = fb.apply(SPECIES.length());
5201 boolean[] mask = fm.apply(SPECIES.length());
5202
5203 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5204
5205 for (int i = 0; i < a.length; i += SPECIES.length()) {
5206 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5207 VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
5208
5209 // Check results as part of computation.
5210 for (int j = 0; j < SPECIES.length(); j++) {
5211 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i])));
5212 }
5213 }
5214 }
5215
5216 @Test(dataProvider = "shortCompareOpProvider")
5217 static void EQShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5218 short[] a = fa.apply(SPECIES.length());
5219 short[] b = fb.apply(SPECIES.length());
5220
5221 for (int i = 0; i < a.length; i += SPECIES.length()) {
5222 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5223 VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]);
5224
5225 // Check results as part of computation.
5226 for (int j = 0; j < SPECIES.length(); j++) {
5227 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
5228 }
5229 }
5230 }
5231
5232 @Test(dataProvider = "shortCompareOpMaskProvider")
5233 static void EQShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
5234 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5235 short[] a = fa.apply(SPECIES.length());
5236 short[] b = fb.apply(SPECIES.length());
5237 boolean[] mask = fm.apply(SPECIES.length());
5238
5239 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5240
5241 for (int i = 0; i < a.length; i += SPECIES.length()) {
5242 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5243 VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask);
5244
5245 // Check results as part of computation.
5246 for (int j = 0; j < SPECIES.length(); j++) {
5247 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
5248 }
5249 }
5250 }
5251
5252 @Test(dataProvider = "shortCompareOpProvider")
5253 static void EQShort64VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5254 short[] a = fa.apply(SPECIES.length());
5255 short[] b = fb.apply(SPECIES.length());
5256
5257 for (int i = 0; i < a.length; i += SPECIES.length()) {
5258 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5259 VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]);
5260
5261 // Check results as part of computation.
5262 for (int j = 0; j < SPECIES.length(); j++) {
5263 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
5264 }
5265 }
5266 }
5267
5268 @Test(dataProvider = "shortCompareOpMaskProvider")
5269 static void EQShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
5270 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
5271 short[] a = fa.apply(SPECIES.length());
5272 short[] b = fb.apply(SPECIES.length());
5273 boolean[] mask = fm.apply(SPECIES.length());
5274
5275 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5276
5277 for (int i = 0; i < a.length; i += SPECIES.length()) {
5278 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5279 VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
5280
5281 // Check results as part of computation.
5282 for (int j = 0; j < SPECIES.length(); j++) {
5283 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i])));
5284 }
5285 }
5286 }
5287
5288 static short blend(short a, short b, boolean mask) {
5289 return mask ? b : a;
5290 }
5291
5292 @Test(dataProvider = "shortBinaryOpMaskProvider")
5293 static void blendShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
5294 IntFunction<boolean[]> fm) {
5295 short[] a = fa.apply(SPECIES.length());
5296 short[] b = fb.apply(SPECIES.length());
5297 short[] r = fr.apply(SPECIES.length());
5298 boolean[] mask = fm.apply(SPECIES.length());
5299 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5300
5301 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5302 for (int i = 0; i < a.length; i += SPECIES.length()) {
5303 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5304 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5305 av.blend(bv, vmask).intoArray(r, i);
5306 }
5307 }
5308
5309 assertArraysEquals(r, a, b, mask, Short64VectorTests::blend);
5310 }
5311
5312 @Test(dataProvider = "shortUnaryOpShuffleProvider")
5313 static void RearrangeShort64VectorTests(IntFunction<short[]> fa,
5314 BiFunction<Integer,Integer,int[]> fs) {
5315 short[] a = fa.apply(SPECIES.length());
5316 int[] order = fs.apply(a.length, SPECIES.length());
5317 short[] r = fr.apply(SPECIES.length());
5318
5319 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5320 for (int i = 0; i < a.length; i += SPECIES.length()) {
5321 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5322 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
5323 }
5324 }
5325
5326 assertRearrangeArraysEquals(r, a, order, SPECIES.length());
5327 }
5328
5329 @Test(dataProvider = "shortUnaryOpShuffleMaskProvider")
5330 static void RearrangeShort64VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
5331 BiFunction<Integer,Integer,int[]> fs,
5332 IntFunction<boolean[]> fm) {
5333 short[] a = fa.apply(SPECIES.length());
5334 int[] order = fs.apply(a.length, SPECIES.length());
5335 short[] r = fr.apply(SPECIES.length());
5336 boolean[] mask = fm.apply(SPECIES.length());
5337 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5338
5339 for (int i = 0; i < a.length; i += SPECIES.length()) {
5340 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5341 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
5342 }
5343
5344 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
5345 }
5346
5347 @Test(dataProvider = "shortUnaryOpMaskProvider")
5348 static void compressShort64VectorTests(IntFunction<short[]> fa,
5349 IntFunction<boolean[]> fm) {
5350 short[] a = fa.apply(SPECIES.length());
5351 short[] r = fr.apply(SPECIES.length());
5352 boolean[] mask = fm.apply(SPECIES.length());
5353 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5354
5355 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5356 for (int i = 0; i < a.length; i += SPECIES.length()) {
5357 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5358 av.compress(vmask).intoArray(r, i);
5359 }
5360 }
5361
5362 assertcompressArraysEquals(r, a, mask, SPECIES.length());
5363 }
5364
5365 @Test(dataProvider = "shortUnaryOpMaskProvider")
5366 static void expandShort64VectorTests(IntFunction<short[]> fa,
5367 IntFunction<boolean[]> fm) {
5368 short[] a = fa.apply(SPECIES.length());
5369 short[] r = fr.apply(SPECIES.length());
5370 boolean[] mask = fm.apply(SPECIES.length());
5371 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5372
5373 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5374 for (int i = 0; i < a.length; i += SPECIES.length()) {
5375 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5376 av.expand(vmask).intoArray(r, i);
5377 }
5378 }
5379
5380 assertexpandArraysEquals(r, a, mask, SPECIES.length());
5381 }
5382
5383 @Test(dataProvider = "shortUnaryOpProvider")
5384 static void getShort64VectorTests(IntFunction<short[]> fa) {
5385 short[] a = fa.apply(SPECIES.length());
5386 short[] r = fr.apply(SPECIES.length());
5387
5388 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5389 for (int i = 0; i < a.length; i += SPECIES.length()) {
5390 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5391 int num_lanes = SPECIES.length();
5392 // Manually unroll because full unroll happens after intrinsification.
5393 // Unroll is needed because get intrinsic requires for index to be a known constant.
5394 if (num_lanes == 1) {
5395 r[i]=av.lane(0);
5396 } else if (num_lanes == 2) {
5397 r[i]=av.lane(0);
5398 r[i+1]=av.lane(1);
5399 } else if (num_lanes == 4) {
5400 r[i]=av.lane(0);
5401 r[i+1]=av.lane(1);
5402 r[i+2]=av.lane(2);
5403 r[i+3]=av.lane(3);
5404 } else if (num_lanes == 8) {
5405 r[i]=av.lane(0);
5406 r[i+1]=av.lane(1);
5407 r[i+2]=av.lane(2);
5408 r[i+3]=av.lane(3);
5409 r[i+4]=av.lane(4);
5410 r[i+5]=av.lane(5);
5411 r[i+6]=av.lane(6);
5412 r[i+7]=av.lane(7);
5413 } else if (num_lanes == 16) {
5414 r[i]=av.lane(0);
5415 r[i+1]=av.lane(1);
5416 r[i+2]=av.lane(2);
5417 r[i+3]=av.lane(3);
5418 r[i+4]=av.lane(4);
5419 r[i+5]=av.lane(5);
5420 r[i+6]=av.lane(6);
5421 r[i+7]=av.lane(7);
5422 r[i+8]=av.lane(8);
5423 r[i+9]=av.lane(9);
5424 r[i+10]=av.lane(10);
5425 r[i+11]=av.lane(11);
5426 r[i+12]=av.lane(12);
5427 r[i+13]=av.lane(13);
5428 r[i+14]=av.lane(14);
5429 r[i+15]=av.lane(15);
5430 } else if (num_lanes == 32) {
5431 r[i]=av.lane(0);
5432 r[i+1]=av.lane(1);
5433 r[i+2]=av.lane(2);
5434 r[i+3]=av.lane(3);
5435 r[i+4]=av.lane(4);
5436 r[i+5]=av.lane(5);
5437 r[i+6]=av.lane(6);
5438 r[i+7]=av.lane(7);
5439 r[i+8]=av.lane(8);
5440 r[i+9]=av.lane(9);
5441 r[i+10]=av.lane(10);
5442 r[i+11]=av.lane(11);
5443 r[i+12]=av.lane(12);
5444 r[i+13]=av.lane(13);
5445 r[i+14]=av.lane(14);
5446 r[i+15]=av.lane(15);
5447 r[i+16]=av.lane(16);
5448 r[i+17]=av.lane(17);
5449 r[i+18]=av.lane(18);
5450 r[i+19]=av.lane(19);
5451 r[i+20]=av.lane(20);
5452 r[i+21]=av.lane(21);
5453 r[i+22]=av.lane(22);
5454 r[i+23]=av.lane(23);
5455 r[i+24]=av.lane(24);
5456 r[i+25]=av.lane(25);
5457 r[i+26]=av.lane(26);
5458 r[i+27]=av.lane(27);
5459 r[i+28]=av.lane(28);
5460 r[i+29]=av.lane(29);
5461 r[i+30]=av.lane(30);
5462 r[i+31]=av.lane(31);
5463 } else if (num_lanes == 64) {
5464 r[i]=av.lane(0);
5465 r[i+1]=av.lane(1);
5466 r[i+2]=av.lane(2);
5467 r[i+3]=av.lane(3);
5468 r[i+4]=av.lane(4);
5469 r[i+5]=av.lane(5);
5470 r[i+6]=av.lane(6);
5471 r[i+7]=av.lane(7);
5472 r[i+8]=av.lane(8);
5473 r[i+9]=av.lane(9);
5474 r[i+10]=av.lane(10);
5475 r[i+11]=av.lane(11);
5476 r[i+12]=av.lane(12);
5477 r[i+13]=av.lane(13);
5478 r[i+14]=av.lane(14);
5479 r[i+15]=av.lane(15);
5480 r[i+16]=av.lane(16);
5481 r[i+17]=av.lane(17);
5482 r[i+18]=av.lane(18);
5483 r[i+19]=av.lane(19);
5484 r[i+20]=av.lane(20);
5485 r[i+21]=av.lane(21);
5486 r[i+22]=av.lane(22);
5487 r[i+23]=av.lane(23);
5488 r[i+24]=av.lane(24);
5489 r[i+25]=av.lane(25);
5490 r[i+26]=av.lane(26);
5491 r[i+27]=av.lane(27);
5492 r[i+28]=av.lane(28);
5493 r[i+29]=av.lane(29);
5494 r[i+30]=av.lane(30);
5495 r[i+31]=av.lane(31);
5496 r[i+32]=av.lane(32);
5497 r[i+33]=av.lane(33);
5498 r[i+34]=av.lane(34);
5499 r[i+35]=av.lane(35);
5500 r[i+36]=av.lane(36);
5501 r[i+37]=av.lane(37);
5502 r[i+38]=av.lane(38);
5503 r[i+39]=av.lane(39);
5504 r[i+40]=av.lane(40);
5505 r[i+41]=av.lane(41);
5506 r[i+42]=av.lane(42);
5507 r[i+43]=av.lane(43);
5508 r[i+44]=av.lane(44);
5509 r[i+45]=av.lane(45);
5510 r[i+46]=av.lane(46);
5511 r[i+47]=av.lane(47);
5512 r[i+48]=av.lane(48);
5513 r[i+49]=av.lane(49);
5514 r[i+50]=av.lane(50);
5515 r[i+51]=av.lane(51);
5516 r[i+52]=av.lane(52);
5517 r[i+53]=av.lane(53);
5518 r[i+54]=av.lane(54);
5519 r[i+55]=av.lane(55);
5520 r[i+56]=av.lane(56);
5521 r[i+57]=av.lane(57);
5522 r[i+58]=av.lane(58);
5523 r[i+59]=av.lane(59);
5524 r[i+60]=av.lane(60);
5525 r[i+61]=av.lane(61);
5526 r[i+62]=av.lane(62);
5527 r[i+63]=av.lane(63);
5528 } else {
5529 for (int j = 0; j < SPECIES.length(); j++) {
5530 r[i+j]=av.lane(j);
5531 }
5532 }
5533 }
5534 }
5535
5536 assertArraysStrictlyEquals(r, a);
5537 }
5538
5539 @Test(dataProvider = "shortUnaryOpProvider")
5540 static void BroadcastShort64VectorTests(IntFunction<short[]> fa) {
5541 short[] a = fa.apply(SPECIES.length());
5542 short[] r = new short[a.length];
5543
5544 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5545 for (int i = 0; i < a.length; i += SPECIES.length()) {
5546 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i);
5547 }
5548 }
5549
5550 assertBroadcastArraysEquals(r, a);
5551 }
5552
5553 @Test(dataProvider = "shortUnaryOpProvider")
5554 static void ZeroShort64VectorTests(IntFunction<short[]> fa) {
5555 short[] a = fa.apply(SPECIES.length());
5556 short[] r = new short[a.length];
5557
5558 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5559 for (int i = 0; i < a.length; i += SPECIES.length()) {
5560 ShortVector.zero(SPECIES).intoArray(a, i);
5561 }
5562 }
5563
5564 Assert.assertEquals(a, r);
5565 }
5566
5567 static short[] sliceUnary(short[] a, int origin, int idx) {
5568 short[] res = new short[SPECIES.length()];
5569 for (int i = 0; i < SPECIES.length(); i++){
5570 if(i+origin < SPECIES.length())
5571 res[i] = a[idx+i+origin];
5572 else
5573 res[i] = (short)0;
5574 }
5575 return res;
5576 }
5577
5578 @Test(dataProvider = "shortUnaryOpProvider")
5579 static void sliceUnaryShort64VectorTests(IntFunction<short[]> fa) {
5580 short[] a = fa.apply(SPECIES.length());
5581 short[] r = new short[a.length];
5582 int origin = RAND.nextInt(SPECIES.length());
5583 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5584 for (int i = 0; i < a.length; i += SPECIES.length()) {
5585 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5586 av.slice(origin).intoArray(r, i);
5587 }
5588 }
5589
5590 assertArraysEquals(r, a, origin, Short64VectorTests::sliceUnary);
5591 }
5592
5593 static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
5594 short[] res = new short[SPECIES.length()];
5595 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5596 if(i+origin < SPECIES.length())
5597 res[i] = a[idx+i+origin];
5598 else {
5599 res[i] = b[idx+j];
5600 j++;
5601 }
5602 }
5603 return res;
5604 }
5605
5606 @Test(dataProvider = "shortBinaryOpProvider")
5607 static void sliceBinaryShort64VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5608 short[] a = fa.apply(SPECIES.length());
5609 short[] b = fb.apply(SPECIES.length());
5610 short[] r = new short[a.length];
5611 int origin = RAND.nextInt(SPECIES.length());
5612 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5613 for (int i = 0; i < a.length; i += SPECIES.length()) {
5614 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5615 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5616 av.slice(origin, bv).intoArray(r, i);
5617 }
5618 }
5619
5620 assertArraysEquals(r, a, b, origin, Short64VectorTests::sliceBinary);
5621 }
5622
5623 static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
5624 short[] res = new short[SPECIES.length()];
5625 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5626 if(i+origin < SPECIES.length())
5627 res[i] = mask[i] ? a[idx+i+origin] : (short)0;
5628 else {
5629 res[i] = mask[i] ? b[idx+j] : (short)0;
5630 j++;
5631 }
5632 }
5633 return res;
5634 }
5635
5636 @Test(dataProvider = "shortBinaryOpMaskProvider")
5637 static void sliceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5638 IntFunction<boolean[]> fm) {
5639 short[] a = fa.apply(SPECIES.length());
5640 short[] b = fb.apply(SPECIES.length());
5641 boolean[] mask = fm.apply(SPECIES.length());
5642 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5643
5644 short[] r = new short[a.length];
5645 int origin = RAND.nextInt(SPECIES.length());
5646 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5647 for (int i = 0; i < a.length; i += SPECIES.length()) {
5648 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5649 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5650 av.slice(origin, bv, vmask).intoArray(r, i);
5651 }
5652 }
5653
5654 assertArraysEquals(r, a, b, origin, mask, Short64VectorTests::slice);
5655 }
5656
5657 static short[] unsliceUnary(short[] a, int origin, int idx) {
5658 short[] res = new short[SPECIES.length()];
5659 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5660 if(i < origin)
5661 res[i] = (short)0;
5662 else {
5663 res[i] = a[idx+j];
5664 j++;
5665 }
5666 }
5667 return res;
5668 }
5669
5670 @Test(dataProvider = "shortUnaryOpProvider")
5671 static void unsliceUnaryShort64VectorTests(IntFunction<short[]> fa) {
5672 short[] a = fa.apply(SPECIES.length());
5673 short[] r = new short[a.length];
5674 int origin = RAND.nextInt(SPECIES.length());
5675 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5676 for (int i = 0; i < a.length; i += SPECIES.length()) {
5677 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5678 av.unslice(origin).intoArray(r, i);
5679 }
5680 }
5681
5682 assertArraysEquals(r, a, origin, Short64VectorTests::unsliceUnary);
5683 }
5684
5685 static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
5686 short[] res = new short[SPECIES.length()];
5687 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5688 if (part == 0) {
5689 if (i < origin)
5690 res[i] = b[idx+i];
5691 else {
5692 res[i] = a[idx+j];
5693 j++;
5694 }
5695 } else if (part == 1) {
5696 if (i < origin)
5697 res[i] = a[idx+SPECIES.length()-origin+i];
5698 else {
5699 res[i] = b[idx+origin+j];
5700 j++;
5701 }
5702 }
5703 }
5704 return res;
5705 }
5706
5707 @Test(dataProvider = "shortBinaryOpProvider")
5708 static void unsliceBinaryShort64VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5709 short[] a = fa.apply(SPECIES.length());
5710 short[] b = fb.apply(SPECIES.length());
5711 short[] r = new short[a.length];
5712 int origin = RAND.nextInt(SPECIES.length());
5713 int part = RAND.nextInt(2);
5714 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5715 for (int i = 0; i < a.length; i += SPECIES.length()) {
5716 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5717 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5718 av.unslice(origin, bv, part).intoArray(r, i);
5719 }
5720 }
5721
5722 assertArraysEquals(r, a, b, origin, part, Short64VectorTests::unsliceBinary);
5723 }
5724
5725 static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
5726 short[] res = new short[SPECIES.length()];
5727 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5728 if(i+origin < SPECIES.length())
5729 res[i] = b[idx+i+origin];
5730 else {
5731 res[i] = b[idx+j];
5732 j++;
5733 }
5734 }
5735 for (int i = 0; i < SPECIES.length(); i++){
5736 res[i] = mask[i] ? a[idx+i] : res[i];
5737 }
5738 short[] res1 = new short[SPECIES.length()];
5739 if (part == 0) {
5740 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5741 if (i < origin)
5742 res1[i] = b[idx+i];
5743 else {
5744 res1[i] = res[j];
5745 j++;
5746 }
5747 }
5748 } else if (part == 1) {
5749 for (int i = 0, j = 0; i < SPECIES.length(); i++){
5750 if (i < origin)
5751 res1[i] = res[SPECIES.length()-origin+i];
5752 else {
5753 res1[i] = b[idx+origin+j];
5754 j++;
5755 }
5756 }
5757 }
5758 return res1;
5759 }
5760
5761 @Test(dataProvider = "shortBinaryOpMaskProvider")
5762 static void unsliceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5763 IntFunction<boolean[]> fm) {
5764 short[] a = fa.apply(SPECIES.length());
5765 short[] b = fb.apply(SPECIES.length());
5766 boolean[] mask = fm.apply(SPECIES.length());
5767 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5768 short[] r = new short[a.length];
5769 int origin = RAND.nextInt(SPECIES.length());
5770 int part = RAND.nextInt(2);
5771 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5772 for (int i = 0; i < a.length; i += SPECIES.length()) {
5773 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5774 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5775 av.unslice(origin, bv, part, vmask).intoArray(r, i);
5776 }
5777 }
5778
5779 assertArraysEquals(r, a, b, origin, part, mask, Short64VectorTests::unslice);
5780 }
5781
5782 static short BITWISE_BLEND(short a, short b, short c) {
5783 return (short)((a&~(c))|(b&c));
5784 }
5785
5786 static short bitwiseBlend(short a, short b, short c) {
5787 return (short)((a&~(c))|(b&c));
5788 }
5789
5790 @Test(dataProvider = "shortTernaryOpProvider")
5791 static void BITWISE_BLENDShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5792 short[] a = fa.apply(SPECIES.length());
5793 short[] b = fb.apply(SPECIES.length());
5794 short[] c = fc.apply(SPECIES.length());
5795 short[] r = fr.apply(SPECIES.length());
5796
5797 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5798 for (int i = 0; i < a.length; i += SPECIES.length()) {
5799 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5800 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5801 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5802 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5803 }
5804 }
5805
5806 assertArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND);
5807 }
5808
5809 @Test(dataProvider = "shortTernaryOpProvider")
5810 static void bitwiseBlendShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5811 short[] a = fa.apply(SPECIES.length());
5812 short[] b = fb.apply(SPECIES.length());
5813 short[] c = fc.apply(SPECIES.length());
5814 short[] r = fr.apply(SPECIES.length());
5815
5816 for (int i = 0; i < a.length; i += SPECIES.length()) {
5817 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5818 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5819 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5820 av.bitwiseBlend(bv, cv).intoArray(r, i);
5821 }
5822
5823 assertArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend);
5824 }
5825
5826 @Test(dataProvider = "shortTernaryOpMaskProvider")
5827 static void BITWISE_BLENDShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5828 IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5829 short[] a = fa.apply(SPECIES.length());
5830 short[] b = fb.apply(SPECIES.length());
5831 short[] c = fc.apply(SPECIES.length());
5832 short[] r = fr.apply(SPECIES.length());
5833 boolean[] mask = fm.apply(SPECIES.length());
5834 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5835
5836 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5837 for (int i = 0; i < a.length; i += SPECIES.length()) {
5838 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5839 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5840 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5841 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5842 }
5843 }
5844
5845 assertArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND);
5846 }
5847
5848 @Test(dataProvider = "shortTernaryOpProvider")
5849 static void BITWISE_BLENDShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5850 short[] a = fa.apply(SPECIES.length());
5851 short[] b = fb.apply(SPECIES.length());
5852 short[] c = fc.apply(SPECIES.length());
5853 short[] r = fr.apply(SPECIES.length());
5854
5855 for (int i = 0; i < a.length; i += SPECIES.length()) {
5856 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5857 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5858 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5859 }
5860 assertBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND);
5861 }
5862
5863 @Test(dataProvider = "shortTernaryOpProvider")
5864 static void BITWISE_BLENDShort64VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5865 short[] a = fa.apply(SPECIES.length());
5866 short[] b = fb.apply(SPECIES.length());
5867 short[] c = fc.apply(SPECIES.length());
5868 short[] r = fr.apply(SPECIES.length());
5869
5870 for (int i = 0; i < a.length; i += SPECIES.length()) {
5871 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5872 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5873 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5874 }
5875 assertAltBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND);
5876 }
5877
5878 @Test(dataProvider = "shortTernaryOpProvider")
5879 static void bitwiseBlendShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5880 short[] a = fa.apply(SPECIES.length());
5881 short[] b = fb.apply(SPECIES.length());
5882 short[] c = fc.apply(SPECIES.length());
5883 short[] r = fr.apply(SPECIES.length());
5884
5885 for (int i = 0; i < a.length; i += SPECIES.length()) {
5886 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5887 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5888 av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5889 }
5890 assertBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend);
5891 }
5892
5893 @Test(dataProvider = "shortTernaryOpProvider")
5894 static void bitwiseBlendShort64VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5895 short[] a = fa.apply(SPECIES.length());
5896 short[] b = fb.apply(SPECIES.length());
5897 short[] c = fc.apply(SPECIES.length());
5898 short[] r = fr.apply(SPECIES.length());
5899
5900 for (int i = 0; i < a.length; i += SPECIES.length()) {
5901 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5902 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5903 av.bitwiseBlend(b[i], cv).intoArray(r, i);
5904 }
5905 assertAltBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend);
5906 }
5907
5908 @Test(dataProvider = "shortTernaryOpMaskProvider")
5909 static void BITWISE_BLENDShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5910 IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5911 short[] a = fa.apply(SPECIES.length());
5912 short[] b = fb.apply(SPECIES.length());
5913 short[] c = fc.apply(SPECIES.length());
5914 short[] r = fr.apply(SPECIES.length());
5915 boolean[] mask = fm.apply(SPECIES.length());
5916 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5917
5918 for (int i = 0; i < a.length; i += SPECIES.length()) {
5919 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5920 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5921 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5922 }
5923
5924 assertBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND);
5925 }
5926
5927 @Test(dataProvider = "shortTernaryOpMaskProvider")
5928 static void BITWISE_BLENDShort64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5929 IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5930 short[] a = fa.apply(SPECIES.length());
5931 short[] b = fb.apply(SPECIES.length());
5932 short[] c = fc.apply(SPECIES.length());
5933 short[] r = fr.apply(SPECIES.length());
5934 boolean[] mask = fm.apply(SPECIES.length());
5935 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5936
5937 for (int i = 0; i < a.length; i += SPECIES.length()) {
5938 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5939 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5940 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5941 }
5942
5943 assertAltBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND);
5944 }
5945
5946 @Test(dataProvider = "shortTernaryOpProvider")
5947 static void BITWISE_BLENDShort64VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5948 short[] a = fa.apply(SPECIES.length());
5949 short[] b = fb.apply(SPECIES.length());
5950 short[] c = fc.apply(SPECIES.length());
5951 short[] r = fr.apply(SPECIES.length());
5952
5953 for (int i = 0; i < a.length; i += SPECIES.length()) {
5954 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5955 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5956 }
5957
5958 assertDoubleBroadcastArraysEquals(r, a, b, c, Short64VectorTests::BITWISE_BLEND);
5959 }
5960
5961 @Test(dataProvider = "shortTernaryOpProvider")
5962 static void bitwiseBlendShort64VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5963 short[] a = fa.apply(SPECIES.length());
5964 short[] b = fb.apply(SPECIES.length());
5965 short[] c = fc.apply(SPECIES.length());
5966 short[] r = fr.apply(SPECIES.length());
5967
5968 for (int i = 0; i < a.length; i += SPECIES.length()) {
5969 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5970 av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5971 }
5972
5973 assertDoubleBroadcastArraysEquals(r, a, b, c, Short64VectorTests::bitwiseBlend);
5974 }
5975
5976 @Test(dataProvider = "shortTernaryOpMaskProvider")
5977 static void BITWISE_BLENDShort64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5978 IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5979 short[] a = fa.apply(SPECIES.length());
5980 short[] b = fb.apply(SPECIES.length());
5981 short[] c = fc.apply(SPECIES.length());
5982 short[] r = fr.apply(SPECIES.length());
5983 boolean[] mask = fm.apply(SPECIES.length());
5984 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5985
5986 for (int i = 0; i < a.length; i += SPECIES.length()) {
5987 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5988 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5989 }
5990
5991 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short64VectorTests::BITWISE_BLEND);
5992 }
5993
5994 static short NEG(short a) {
5995 return (short)(-((short)a));
5996 }
5997
5998 static short neg(short a) {
5999 return (short)(-((short)a));
6000 }
6001
6002 @Test(dataProvider = "shortUnaryOpProvider")
6003 static void NEGShort64VectorTests(IntFunction<short[]> fa) {
6004 short[] a = fa.apply(SPECIES.length());
6005 short[] r = fr.apply(SPECIES.length());
6006
6007 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6008 for (int i = 0; i < a.length; i += SPECIES.length()) {
6009 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6010 av.lanewise(VectorOperators.NEG).intoArray(r, i);
6011 }
6012 }
6013
6014 assertArraysEquals(r, a, Short64VectorTests::NEG);
6015 }
6016
6017 @Test(dataProvider = "shortUnaryOpProvider")
6018 static void negShort64VectorTests(IntFunction<short[]> fa) {
6019 short[] a = fa.apply(SPECIES.length());
6020 short[] r = fr.apply(SPECIES.length());
6021
6022 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6023 for (int i = 0; i < a.length; i += SPECIES.length()) {
6024 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6025 av.neg().intoArray(r, i);
6026 }
6027 }
6028
6029 assertArraysEquals(r, a, Short64VectorTests::neg);
6030 }
6031
6032 @Test(dataProvider = "shortUnaryOpMaskProvider")
6033 static void NEGMaskedShort64VectorTests(IntFunction<short[]> fa,
6034 IntFunction<boolean[]> fm) {
6035 short[] a = fa.apply(SPECIES.length());
6036 short[] r = fr.apply(SPECIES.length());
6037 boolean[] mask = fm.apply(SPECIES.length());
6038 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6039
6040 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6041 for (int i = 0; i < a.length; i += SPECIES.length()) {
6042 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6043 av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);
6044 }
6045 }
6046
6047 assertArraysEquals(r, a, mask, Short64VectorTests::NEG);
6048 }
6049
6050 static short ABS(short a) {
6051 return (short)(Math.abs((short)a));
6052 }
6053
6054 static short abs(short a) {
6055 return (short)(Math.abs((short)a));
6056 }
6057
6058 @Test(dataProvider = "shortUnaryOpProvider")
6059 static void ABSShort64VectorTests(IntFunction<short[]> fa) {
6060 short[] a = fa.apply(SPECIES.length());
6061 short[] r = fr.apply(SPECIES.length());
6062
6063 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6064 for (int i = 0; i < a.length; i += SPECIES.length()) {
6065 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6066 av.lanewise(VectorOperators.ABS).intoArray(r, i);
6067 }
6068 }
6069
6070 assertArraysEquals(r, a, Short64VectorTests::ABS);
6071 }
6072
6073 @Test(dataProvider = "shortUnaryOpProvider")
6074 static void absShort64VectorTests(IntFunction<short[]> fa) {
6075 short[] a = fa.apply(SPECIES.length());
6076 short[] r = fr.apply(SPECIES.length());
6077
6078 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6079 for (int i = 0; i < a.length; i += SPECIES.length()) {
6080 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6081 av.abs().intoArray(r, i);
6082 }
6083 }
6084
6085 assertArraysEquals(r, a, Short64VectorTests::abs);
6086 }
6087
6088 @Test(dataProvider = "shortUnaryOpMaskProvider")
6089 static void ABSMaskedShort64VectorTests(IntFunction<short[]> fa,
6090 IntFunction<boolean[]> fm) {
6091 short[] a = fa.apply(SPECIES.length());
6092 short[] r = fr.apply(SPECIES.length());
6093 boolean[] mask = fm.apply(SPECIES.length());
6094 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6095
6096 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6097 for (int i = 0; i < a.length; i += SPECIES.length()) {
6098 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6099 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
6100 }
6101 }
6102
6103 assertArraysEquals(r, a, mask, Short64VectorTests::ABS);
6104 }
6105
6106 static short NOT(short a) {
6107 return (short)(~((short)a));
6108 }
6109
6110 static short not(short a) {
6111 return (short)(~((short)a));
6112 }
6113
6114 @Test(dataProvider = "shortUnaryOpProvider")
6115 static void NOTShort64VectorTests(IntFunction<short[]> fa) {
6116 short[] a = fa.apply(SPECIES.length());
6117 short[] r = fr.apply(SPECIES.length());
6118
6119 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6120 for (int i = 0; i < a.length; i += SPECIES.length()) {
6121 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6122 av.lanewise(VectorOperators.NOT).intoArray(r, i);
6123 }
6124 }
6125
6126 assertArraysEquals(r, a, Short64VectorTests::NOT);
6127 }
6128
6129 @Test(dataProvider = "shortUnaryOpProvider")
6130 static void notShort64VectorTests(IntFunction<short[]> fa) {
6131 short[] a = fa.apply(SPECIES.length());
6132 short[] r = fr.apply(SPECIES.length());
6133
6134 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6135 for (int i = 0; i < a.length; i += SPECIES.length()) {
6136 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6137 av.not().intoArray(r, i);
6138 }
6139 }
6140
6141 assertArraysEquals(r, a, Short64VectorTests::not);
6142 }
6143
6144 @Test(dataProvider = "shortUnaryOpMaskProvider")
6145 static void NOTMaskedShort64VectorTests(IntFunction<short[]> fa,
6146 IntFunction<boolean[]> fm) {
6147 short[] a = fa.apply(SPECIES.length());
6148 short[] r = fr.apply(SPECIES.length());
6149 boolean[] mask = fm.apply(SPECIES.length());
6150 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6151
6152 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6153 for (int i = 0; i < a.length; i += SPECIES.length()) {
6154 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6155 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
6156 }
6157 }
6158
6159 assertArraysEquals(r, a, mask, Short64VectorTests::NOT);
6160 }
6161
6162 static short ZOMO(short a) {
6163 return (short)((a==0?0:-1));
6164 }
6165
6166 @Test(dataProvider = "shortUnaryOpProvider")
6167 static void ZOMOShort64VectorTests(IntFunction<short[]> fa) {
6168 short[] a = fa.apply(SPECIES.length());
6169 short[] r = fr.apply(SPECIES.length());
6170
6171 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6172 for (int i = 0; i < a.length; i += SPECIES.length()) {
6173 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6174 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
6175 }
6176 }
6177
6178 assertArraysEquals(r, a, Short64VectorTests::ZOMO);
6179 }
6180
6181 @Test(dataProvider = "shortUnaryOpMaskProvider")
6182 static void ZOMOMaskedShort64VectorTests(IntFunction<short[]> fa,
6183 IntFunction<boolean[]> fm) {
6184 short[] a = fa.apply(SPECIES.length());
6185 short[] r = fr.apply(SPECIES.length());
6186 boolean[] mask = fm.apply(SPECIES.length());
6187 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6188
6189 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6190 for (int i = 0; i < a.length; i += SPECIES.length()) {
6191 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6192 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
6193 }
6194 }
6195
6196 assertArraysEquals(r, a, mask, Short64VectorTests::ZOMO);
6197 }
6198
6199 static short BIT_COUNT(short a) {
6200 return (short)(Integer.bitCount((int)a & 0xFFFF));
6201 }
6202
6203 @Test(dataProvider = "shortUnaryOpProvider")
6204 static void BIT_COUNTShort64VectorTests(IntFunction<short[]> fa) {
6205 short[] a = fa.apply(SPECIES.length());
6206 short[] r = fr.apply(SPECIES.length());
6207
6208 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6209 for (int i = 0; i < a.length; i += SPECIES.length()) {
6210 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6211 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
6212 }
6213 }
6214
6215 assertArraysEquals(r, a, Short64VectorTests::BIT_COUNT);
6216 }
6217
6218 @Test(dataProvider = "shortUnaryOpMaskProvider")
6219 static void BIT_COUNTMaskedShort64VectorTests(IntFunction<short[]> fa,
6220 IntFunction<boolean[]> fm) {
6221 short[] a = fa.apply(SPECIES.length());
6222 short[] r = fr.apply(SPECIES.length());
6223 boolean[] mask = fm.apply(SPECIES.length());
6224 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6225
6226 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6227 for (int i = 0; i < a.length; i += SPECIES.length()) {
6228 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6229 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
6230 }
6231 }
6232
6233 assertArraysEquals(r, a, mask, Short64VectorTests::BIT_COUNT);
6234 }
6235
6236 static short TRAILING_ZEROS_COUNT(short a) {
6237 return (short)(TRAILING_ZEROS_COUNT_scalar(a));
6238 }
6239
6240 @Test(dataProvider = "shortUnaryOpProvider")
6241 static void TRAILING_ZEROS_COUNTShort64VectorTests(IntFunction<short[]> fa) {
6242 short[] a = fa.apply(SPECIES.length());
6243 short[] r = fr.apply(SPECIES.length());
6244
6245 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6246 for (int i = 0; i < a.length; i += SPECIES.length()) {
6247 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6248 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
6249 }
6250 }
6251
6252 assertArraysEquals(r, a, Short64VectorTests::TRAILING_ZEROS_COUNT);
6253 }
6254
6255 @Test(dataProvider = "shortUnaryOpMaskProvider")
6256 static void TRAILING_ZEROS_COUNTMaskedShort64VectorTests(IntFunction<short[]> fa,
6257 IntFunction<boolean[]> fm) {
6258 short[] a = fa.apply(SPECIES.length());
6259 short[] r = fr.apply(SPECIES.length());
6260 boolean[] mask = fm.apply(SPECIES.length());
6261 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6262
6263 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6264 for (int i = 0; i < a.length; i += SPECIES.length()) {
6265 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6266 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
6267 }
6268 }
6269
6270 assertArraysEquals(r, a, mask, Short64VectorTests::TRAILING_ZEROS_COUNT);
6271 }
6272
6273 static short LEADING_ZEROS_COUNT(short a) {
6274 return (short)(LEADING_ZEROS_COUNT_scalar(a));
6275 }
6276
6277 @Test(dataProvider = "shortUnaryOpProvider")
6278 static void LEADING_ZEROS_COUNTShort64VectorTests(IntFunction<short[]> fa) {
6279 short[] a = fa.apply(SPECIES.length());
6280 short[] r = fr.apply(SPECIES.length());
6281
6282 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6283 for (int i = 0; i < a.length; i += SPECIES.length()) {
6284 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6285 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
6286 }
6287 }
6288
6289 assertArraysEquals(r, a, Short64VectorTests::LEADING_ZEROS_COUNT);
6290 }
6291
6292 @Test(dataProvider = "shortUnaryOpMaskProvider")
6293 static void LEADING_ZEROS_COUNTMaskedShort64VectorTests(IntFunction<short[]> fa,
6294 IntFunction<boolean[]> fm) {
6295 short[] a = fa.apply(SPECIES.length());
6296 short[] r = fr.apply(SPECIES.length());
6297 boolean[] mask = fm.apply(SPECIES.length());
6298 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6299
6300 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6301 for (int i = 0; i < a.length; i += SPECIES.length()) {
6302 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6303 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
6304 }
6305 }
6306
6307 assertArraysEquals(r, a, mask, Short64VectorTests::LEADING_ZEROS_COUNT);
6308 }
6309
6310 static short REVERSE(short a) {
6311 return (short)(REVERSE_scalar(a));
6312 }
6313
6314 @Test(dataProvider = "shortUnaryOpProvider")
6315 static void REVERSEShort64VectorTests(IntFunction<short[]> fa) {
6316 short[] a = fa.apply(SPECIES.length());
6317 short[] r = fr.apply(SPECIES.length());
6318
6319 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6320 for (int i = 0; i < a.length; i += SPECIES.length()) {
6321 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6322 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
6323 }
6324 }
6325
6326 assertArraysEquals(r, a, Short64VectorTests::REVERSE);
6327 }
6328
6329 @Test(dataProvider = "shortUnaryOpMaskProvider")
6330 static void REVERSEMaskedShort64VectorTests(IntFunction<short[]> fa,
6331 IntFunction<boolean[]> fm) {
6332 short[] a = fa.apply(SPECIES.length());
6333 short[] r = fr.apply(SPECIES.length());
6334 boolean[] mask = fm.apply(SPECIES.length());
6335 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6336
6337 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6338 for (int i = 0; i < a.length; i += SPECIES.length()) {
6339 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6340 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
6341 }
6342 }
6343
6344 assertArraysEquals(r, a, mask, Short64VectorTests::REVERSE);
6345 }
6346
6347 static short REVERSE_BYTES(short a) {
6348 return (short)(Short.reverseBytes(a));
6349 }
6350
6351 @Test(dataProvider = "shortUnaryOpProvider")
6352 static void REVERSE_BYTESShort64VectorTests(IntFunction<short[]> fa) {
6353 short[] a = fa.apply(SPECIES.length());
6354 short[] r = fr.apply(SPECIES.length());
6355
6356 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6357 for (int i = 0; i < a.length; i += SPECIES.length()) {
6358 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6359 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
6360 }
6361 }
6362
6363 assertArraysEquals(r, a, Short64VectorTests::REVERSE_BYTES);
6364 }
6365
6366 @Test(dataProvider = "shortUnaryOpMaskProvider")
6367 static void REVERSE_BYTESMaskedShort64VectorTests(IntFunction<short[]> fa,
6368 IntFunction<boolean[]> fm) {
6369 short[] a = fa.apply(SPECIES.length());
6370 short[] r = fr.apply(SPECIES.length());
6371 boolean[] mask = fm.apply(SPECIES.length());
6372 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6373
6374 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6375 for (int i = 0; i < a.length; i += SPECIES.length()) {
6376 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6377 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
6378 }
6379 }
6380
6381 assertArraysEquals(r, a, mask, Short64VectorTests::REVERSE_BYTES);
6382 }
6383
6384 @Test(dataProvider = "shortCompareOpProvider")
6385 static void ltShort64VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
6386 short[] a = fa.apply(SPECIES.length());
6387 short[] b = fb.apply(SPECIES.length());
6388
6389 for (int i = 0; i < a.length; i += SPECIES.length()) {
6390 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6391 VectorMask<Short> mv = av.lt(b[i]);
6392
6393 // Check results as part of computation.
6394 for (int j = 0; j < SPECIES.length(); j++) {
6395 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
6396 }
6397 }
6398 }
6399
6400 @Test(dataProvider = "shortCompareOpProvider")
6401 static void eqShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
6402 short[] a = fa.apply(SPECIES.length());
6403 short[] b = fb.apply(SPECIES.length());
6404
6405 for (int i = 0; i < a.length; i += SPECIES.length()) {
6406 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6407 VectorMask<Short> mv = av.eq(b[i]);
6408
6409 // Check results as part of computation.
6410 for (int j = 0; j < SPECIES.length(); j++) {
6411 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
6412 }
6413 }
6414 }
6415
6416 @Test(dataProvider = "shortUnaryOpProvider")
6417 static void toIntArrayShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6418 short[] a = fa.apply(SPECIES.length());
6419
6420 for (int i = 0; i < a.length; i += SPECIES.length()) {
6421 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6422 int[] r = av.toIntArray();
6423 assertArraysEquals(r, a, i);
6424 }
6425 }
6426
6427 @Test(dataProvider = "shortUnaryOpProvider")
6428 static void toLongArrayShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6429 short[] a = fa.apply(SPECIES.length());
6430
6431 for (int i = 0; i < a.length; i += SPECIES.length()) {
6432 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6433 long[] r = av.toLongArray();
6434 assertArraysEquals(r, a, i);
6435 }
6436 }
6437
6438 @Test(dataProvider = "shortUnaryOpProvider")
6439 static void toDoubleArrayShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6440 short[] a = fa.apply(SPECIES.length());
6441
6442 for (int i = 0; i < a.length; i += SPECIES.length()) {
6443 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6444 double[] r = av.toDoubleArray();
6445 assertArraysEquals(r, a, i);
6446 }
6447 }
6448
6449 @Test(dataProvider = "shortUnaryOpProvider")
6450 static void toStringShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6451 short[] a = fa.apply(SPECIES.length());
6452
6453 for (int i = 0; i < a.length; i += SPECIES.length()) {
6454 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6455 String str = av.toString();
6456
6457 short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6458 Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6459 }
6460 }
6461
6462 @Test(dataProvider = "shortUnaryOpProvider")
6463 static void hashCodeShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6464 short[] a = fa.apply(SPECIES.length());
6465
6466 for (int i = 0; i < a.length; i += SPECIES.length()) {
6467 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6468 int hash = av.hashCode();
6469
6470 short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6471 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6472 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6473 }
6474 }
6475
6476
6477 static long ADDReduceLong(short[] a, int idx) {
6478 short res = 0;
6479 for (int i = idx; i < (idx + SPECIES.length()); i++) {
6480 res += a[i];
6481 }
6482
6483 return (long)res;
6484 }
6485
6486 static long ADDReduceAllLong(short[] a) {
6487 long res = 0;
6488 for (int i = 0; i < a.length; i += SPECIES.length()) {
6489 res += ADDReduceLong(a, i);
6490 }
6491
6492 return res;
6493 }
6494
6495 @Test(dataProvider = "shortUnaryOpProvider")
6496 static void ADDReduceLongShort64VectorTests(IntFunction<short[]> fa) {
6497 short[] a = fa.apply(SPECIES.length());
6498 long[] r = lfr.apply(SPECIES.length());
6499 long ra = 0;
6500
6501 for (int i = 0; i < a.length; i += SPECIES.length()) {
6502 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6503 r[i] = av.reduceLanesToLong(VectorOperators.ADD);
6504 }
6505
6506 ra = 0;
6507 for (int i = 0; i < a.length; i ++) {
6508 ra += r[i];
6509 }
6510
6511 assertReductionLongArraysEquals(r, ra, a,
6512 Short64VectorTests::ADDReduceLong, Short64VectorTests::ADDReduceAllLong);
6513 }
6514
6515 static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) {
6516 short res = 0;
6517 for (int i = idx; i < (idx + SPECIES.length()); i++) {
6518 if(mask[i % SPECIES.length()])
6519 res += a[i];
6520 }
6521
6522 return (long)res;
6523 }
6524
6525 static long ADDReduceAllLongMasked(short[] a, boolean[] mask) {
6526 long res = 0;
6527 for (int i = 0; i < a.length; i += SPECIES.length()) {
6528 res += ADDReduceLongMasked(a, i, mask);
6529 }
6530
6531 return res;
6532 }
6533
6534 @Test(dataProvider = "shortUnaryOpMaskProvider")
6535 static void ADDReduceLongShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
6536 short[] a = fa.apply(SPECIES.length());
6537 long[] r = lfr.apply(SPECIES.length());
6538 boolean[] mask = fm.apply(SPECIES.length());
6539 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6540 long ra = 0;
6541
6542 for (int i = 0; i < a.length; i += SPECIES.length()) {
6543 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6544 r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);
6545 }
6546
6547 ra = 0;
6548 for (int i = 0; i < a.length; i ++) {
6549 ra += r[i];
6550 }
6551
6552 assertReductionLongArraysEqualsMasked(r, ra, a, mask,
6553 Short64VectorTests::ADDReduceLongMasked, Short64VectorTests::ADDReduceAllLongMasked);
6554 }
6555
6556 @Test(dataProvider = "shortUnaryOpProvider")
6557 static void BroadcastLongShort64VectorTestsSmokeTest(IntFunction<short[]> fa) {
6558 short[] a = fa.apply(SPECIES.length());
6559 short[] r = new short[a.length];
6560
6561 for (int i = 0; i < a.length; i += SPECIES.length()) {
6562 ShortVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);
6563 }
6564 assertBroadcastArraysEquals(r, a);
6565 }
6566
6567 @Test(dataProvider = "shortBinaryOpMaskProvider")
6568 static void blendShort64VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
6569 IntFunction<boolean[]> fm) {
6570 short[] a = fa.apply(SPECIES.length());
6571 short[] b = fb.apply(SPECIES.length());
6572 short[] r = fr.apply(SPECIES.length());
6573 boolean[] mask = fm.apply(SPECIES.length());
6574 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6575
6576 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6577 for (int i = 0; i < a.length; i += SPECIES.length()) {
6578 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6579 av.blend((long)b[i], vmask).intoArray(r, i);
6580 }
6581 }
6582 assertBroadcastLongArraysEquals(r, a, b, mask, Short64VectorTests::blend);
6583 }
6584
6585
6586 @Test(dataProvider = "shortUnaryOpSelectFromProvider")
6587 static void SelectFromShort64VectorTests(IntFunction<short[]> fa,
6588 BiFunction<Integer,Integer,short[]> fs) {
6589 short[] a = fa.apply(SPECIES.length());
6590 short[] order = fs.apply(a.length, SPECIES.length());
6591 short[] r = fr.apply(SPECIES.length());
6592
6593 for (int i = 0; i < a.length; i += SPECIES.length()) {
6594 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6595 ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
6596 bv.selectFrom(av).intoArray(r, i);
6597 }
6598
6599 assertSelectFromArraysEquals(r, a, order, SPECIES.length());
6600 }
6601
6602 @Test(dataProvider = "shortSelectFromTwoVectorOpProvider")
6603 static void SelectFromTwoVectorShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
6604 short[] a = fa.apply(SPECIES.length());
6605 short[] b = fb.apply(SPECIES.length());
6606 short[] idx = fc.apply(SPECIES.length());
6607 short[] r = fr.apply(SPECIES.length());
6608
6609 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6610 for (int i = 0; i < idx.length; i += SPECIES.length()) {
6611 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6612 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
6613 ShortVector idxv = ShortVector.fromArray(SPECIES, idx, i);
6614 idxv.selectFrom(av, bv).intoArray(r, i);
6615 }
6616 }
6617 assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length());
6618 }
6619
6620 @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider")
6621 static void SelectFromShort64VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
6622 BiFunction<Integer,Integer,short[]> fs,
6623 IntFunction<boolean[]> fm) {
6624 short[] a = fa.apply(SPECIES.length());
6625 short[] order = fs.apply(a.length, SPECIES.length());
6626 short[] r = fr.apply(SPECIES.length());
6627 boolean[] mask = fm.apply(SPECIES.length());
6628 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
6629
6630 for (int i = 0; i < a.length; i += SPECIES.length()) {
6631 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
6632 ShortVector bv = ShortVector.fromArray(SPECIES, order, i);
6633 bv.selectFrom(av, vmask).intoArray(r, i);
6634 }
6635
6636 assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());
6637 }
6638
6639 @Test(dataProvider = "shuffleProvider")
6640 static void shuffleMiscellaneousShort64VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6641 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6642
6643 for (int i = 0; i < a.length; i += SPECIES.length()) {
6644 var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6645 int hash = shuffle.hashCode();
6646 int length = shuffle.length();
6647
6648 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6649 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6650 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6651 Assert.assertEquals(length, SPECIES.length());
6652 }
6653 }
6654
6655 @Test(dataProvider = "shuffleProvider")
6656 static void shuffleToStringShort64VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {
6657 int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6658
6659 for (int i = 0; i < a.length; i += SPECIES.length()) {
6660 var shuffle = VectorShuffle.fromArray(SPECIES, a, i);
6661 String str = shuffle.toString();
6662
6663 int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6664 Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +
6665 i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);
6666 }
6667 }
6668
6669 @Test(dataProvider = "shuffleCompareOpProvider")
6670 static void shuffleEqualsShort64VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {
6671 int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6672 int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());
6673
6674 for (int i = 0; i < a.length; i += SPECIES.length()) {
6675 var av = VectorShuffle.fromArray(SPECIES, a, i);
6676 var bv = VectorShuffle.fromArray(SPECIES, b, i);
6677 boolean eq = av.equals(bv);
6678 int to = i + SPECIES.length();
6679 Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));
6680 }
6681 }
6682
6683 @Test(dataProvider = "maskCompareOpProvider")
6684 static void maskEqualsShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6685 boolean[] a = fa.apply(SPECIES.length());
6686 boolean[] b = fb.apply(SPECIES.length());
6687
6688 for (int i = 0; i < a.length; i += SPECIES.length()) {
6689 var av = SPECIES.loadMask(a, i);
6690 var bv = SPECIES.loadMask(b, i);
6691 boolean equals = av.equals(bv);
6692 int to = i + SPECIES.length();
6693 Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));
6694 }
6695 }
6696
6697 static boolean band(boolean a, boolean b) {
6698 return a & b;
6699 }
6700
6701 @Test(dataProvider = "maskCompareOpProvider")
6702 static void maskAndShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6703 boolean[] a = fa.apply(SPECIES.length());
6704 boolean[] b = fb.apply(SPECIES.length());
6705 boolean[] r = new boolean[a.length];
6706
6707 for (int i = 0; i < a.length; i += SPECIES.length()) {
6708 var av = SPECIES.loadMask(a, i);
6709 var bv = SPECIES.loadMask(b, i);
6710 var cv = av.and(bv);
6711 cv.intoArray(r, i);
6712 }
6713 assertArraysEquals(r, a, b, Short64VectorTests::band);
6714 }
6715
6716 static boolean bor(boolean a, boolean b) {
6717 return a | b;
6718 }
6719
6720 @Test(dataProvider = "maskCompareOpProvider")
6721 static void maskOrShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6722 boolean[] a = fa.apply(SPECIES.length());
6723 boolean[] b = fb.apply(SPECIES.length());
6724 boolean[] r = new boolean[a.length];
6725
6726 for (int i = 0; i < a.length; i += SPECIES.length()) {
6727 var av = SPECIES.loadMask(a, i);
6728 var bv = SPECIES.loadMask(b, i);
6729 var cv = av.or(bv);
6730 cv.intoArray(r, i);
6731 }
6732 assertArraysEquals(r, a, b, Short64VectorTests::bor);
6733 }
6734
6735 static boolean bxor(boolean a, boolean b) {
6736 return a != b;
6737 }
6738
6739 @Test(dataProvider = "maskCompareOpProvider")
6740 static void maskXorShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6741 boolean[] a = fa.apply(SPECIES.length());
6742 boolean[] b = fb.apply(SPECIES.length());
6743 boolean[] r = new boolean[a.length];
6744
6745 for (int i = 0; i < a.length; i += SPECIES.length()) {
6746 var av = SPECIES.loadMask(a, i);
6747 var bv = SPECIES.loadMask(b, i);
6748 var cv = av.xor(bv);
6749 cv.intoArray(r, i);
6750 }
6751 assertArraysEquals(r, a, b, Short64VectorTests::bxor);
6752 }
6753
6754 static boolean bandNot(boolean a, boolean b) {
6755 return a & !b;
6756 }
6757
6758 @Test(dataProvider = "maskCompareOpProvider")
6759 static void maskAndNotShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6760 boolean[] a = fa.apply(SPECIES.length());
6761 boolean[] b = fb.apply(SPECIES.length());
6762 boolean[] r = new boolean[a.length];
6763
6764 for (int i = 0; i < a.length; i += SPECIES.length()) {
6765 var av = SPECIES.loadMask(a, i);
6766 var bv = SPECIES.loadMask(b, i);
6767 var cv = av.andNot(bv);
6768 cv.intoArray(r, i);
6769 }
6770 assertArraysEquals(r, a, b, Short64VectorTests::bandNot);
6771 }
6772
6773 static boolean beq(boolean a, boolean b) {
6774 return (a == b);
6775 }
6776
6777 @Test(dataProvider = "maskCompareOpProvider")
6778 static void maskEqShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {
6779 boolean[] a = fa.apply(SPECIES.length());
6780 boolean[] b = fb.apply(SPECIES.length());
6781 boolean[] r = new boolean[a.length];
6782
6783 for (int i = 0; i < a.length; i += SPECIES.length()) {
6784 var av = SPECIES.loadMask(a, i);
6785 var bv = SPECIES.loadMask(b, i);
6786 var cv = av.eq(bv);
6787 cv.intoArray(r, i);
6788 }
6789 assertArraysEquals(r, a, b, Short64VectorTests::beq);
6790 }
6791
6792 @Test(dataProvider = "maskProvider")
6793 static void maskHashCodeShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6794 boolean[] a = fa.apply(SPECIES.length());
6795
6796 for (int i = 0; i < a.length; i += SPECIES.length()) {
6797 var vmask = SPECIES.loadMask(a, i);
6798 int hash = vmask.hashCode();
6799
6800 boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());
6801 int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));
6802 Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);
6803 }
6804 }
6805
6806 static int maskTrueCount(boolean[] a, int idx) {
6807 int trueCount = 0;
6808 for (int i = idx; i < idx + SPECIES.length(); i++) {
6809 trueCount += a[i] ? 1 : 0;
6810 }
6811 return trueCount;
6812 }
6813
6814 @Test(dataProvider = "maskProvider")
6815 static void maskTrueCountShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6816 boolean[] a = fa.apply(SPECIES.length());
6817 int[] r = new int[a.length];
6818
6819 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6820 for (int i = 0; i < a.length; i += SPECIES.length()) {
6821 var vmask = SPECIES.loadMask(a, i);
6822 r[i] = vmask.trueCount();
6823 }
6824 }
6825
6826 assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskTrueCount);
6827 }
6828
6829 static int maskLastTrue(boolean[] a, int idx) {
6830 int i = idx + SPECIES.length() - 1;
6831 for (; i >= idx; i--) {
6832 if (a[i]) {
6833 break;
6834 }
6835 }
6836 return i - idx;
6837 }
6838
6839 @Test(dataProvider = "maskProvider")
6840 static void maskLastTrueShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6841 boolean[] a = fa.apply(SPECIES.length());
6842 int[] r = new int[a.length];
6843
6844 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6845 for (int i = 0; i < a.length; i += SPECIES.length()) {
6846 var vmask = SPECIES.loadMask(a, i);
6847 r[i] = vmask.lastTrue();
6848 }
6849 }
6850
6851 assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskLastTrue);
6852 }
6853
6854 static int maskFirstTrue(boolean[] a, int idx) {
6855 int i = idx;
6856 for (; i < idx + SPECIES.length(); i++) {
6857 if (a[i]) {
6858 break;
6859 }
6860 }
6861 return i - idx;
6862 }
6863
6864 @Test(dataProvider = "maskProvider")
6865 static void maskFirstTrueShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6866 boolean[] a = fa.apply(SPECIES.length());
6867 int[] r = new int[a.length];
6868
6869 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6870 for (int i = 0; i < a.length; i += SPECIES.length()) {
6871 var vmask = SPECIES.loadMask(a, i);
6872 r[i] = vmask.firstTrue();
6873 }
6874 }
6875
6876 assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskFirstTrue);
6877 }
6878
6879 @Test(dataProvider = "maskProvider")
6880 static void maskCompressShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
6881 int trueCount = 0;
6882 boolean[] a = fa.apply(SPECIES.length());
6883
6884 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6885 for (int i = 0; i < a.length; i += SPECIES.length()) {
6886 var vmask = SPECIES.loadMask(a, i);
6887 trueCount = vmask.trueCount();
6888 var rmask = vmask.compress();
6889 for (int j = 0; j < SPECIES.length(); j++) {
6890 Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
6891 }
6892 }
6893 }
6894 }
6895
6896 @DataProvider
6897 public static Object[][] longMaskProvider() {
6898 return new Object[][]{
6899 {0xFFFFFFFFFFFFFFFFL},
6900 {0x0000000000000000L},
6901 {0x5555555555555555L},
6902 {0x0123456789abcdefL},
6903 };
6904 }
6905
6906 @Test(dataProvider = "longMaskProvider")
6907 static void maskFromToLongShort64VectorTestsSmokeTest(long inputLong) {
6908 var vmask = VectorMask.fromLong(SPECIES, inputLong);
6909 long outputLong = vmask.toLong();
6910 Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
6911 }
6912
6913 @DataProvider
6914 public static Object[][] offsetProvider() {
6915 return new Object[][]{
6916 {0},
6917 {-1},
6918 {+1},
6919 {+2},
6920 {-2},
6921 };
6922 }
6923
6924 @Test(dataProvider = "offsetProvider")
6925 static void indexInRangeShort64VectorTestsSmokeTest(int offset) {
6926 int limit = SPECIES.length() * BUFFER_REPS;
6927 for (int i = 0; i < limit; i += SPECIES.length()) {
6928 var actualMask = SPECIES.indexInRange(i + offset, limit);
6929 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6930 assert(actualMask.equals(expectedMask));
6931 for (int j = 0; j < SPECIES.length(); j++) {
6932 int index = i + j + offset;
6933 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6934 }
6935 }
6936 }
6937
6938 @Test(dataProvider = "offsetProvider")
6939 static void indexInRangeLongShort64VectorTestsSmokeTest(int offset) {
6940 long limit = SPECIES.length() * BUFFER_REPS;
6941 for (long i = 0; i < limit; i += SPECIES.length()) {
6942 var actualMask = SPECIES.indexInRange(i + offset, limit);
6943 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6944 assert(actualMask.equals(expectedMask));
6945 for (int j = 0; j < SPECIES.length(); j++) {
6946 long index = i + j + offset;
6947 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6948 }
6949 }
6950 }
6951
6952 @DataProvider
6953 public static Object[][] lengthProvider() {
6954 return new Object[][]{
6955 {0},
6956 {1},
6957 {32},
6958 {37},
6959 {1024},
6960 {1024+1},
6961 {1024+5},
6962 };
6963 }
6964
6965 @Test(dataProvider = "lengthProvider")
6966 static void loopBoundShort64VectorTestsSmokeTest(int length) {
6967 int actualLoopBound = SPECIES.loopBound(length);
6968 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6969 Assert.assertEquals(actualLoopBound, expectedLoopBound);
6970 }
6971
6972 @Test(dataProvider = "lengthProvider")
6973 static void loopBoundLongShort64VectorTestsSmokeTest(int _length) {
6974 long length = _length;
6975 long actualLoopBound = SPECIES.loopBound(length);
6976 long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6977 Assert.assertEquals(actualLoopBound, expectedLoopBound);
6978 }
6979
6980 @Test
6981 static void ElementSizeShort64VectorTestsSmokeTest() {
6982 ShortVector av = ShortVector.zero(SPECIES);
6983 int elsize = av.elementSize();
6984 Assert.assertEquals(elsize, Short.SIZE);
6985 }
6986
6987 @Test
6988 static void VectorShapeShort64VectorTestsSmokeTest() {
6989 ShortVector av = ShortVector.zero(SPECIES);
6990 VectorShape vsh = av.shape();
6991 assert(vsh.equals(VectorShape.S_64_BIT));
6992 }
6993
6994 @Test
6995 static void ShapeWithLanesShort64VectorTestsSmokeTest() {
6996 ShortVector av = ShortVector.zero(SPECIES);
6997 VectorShape vsh = av.shape();
6998 VectorSpecies species = vsh.withLanes(short.class);
6999 assert(species.equals(SPECIES));
7000 }
7001
7002 @Test
7003 static void ElementTypeShort64VectorTestsSmokeTest() {
7004 ShortVector av = ShortVector.zero(SPECIES);
7005 assert(av.species().elementType() == short.class);
7006 }
7007
7008 @Test
7009 static void SpeciesElementSizeShort64VectorTestsSmokeTest() {
7010 ShortVector av = ShortVector.zero(SPECIES);
7011 assert(av.species().elementSize() == Short.SIZE);
7012 }
7013
7014 @Test
7015 static void VectorTypeShort64VectorTestsSmokeTest() {
7016 ShortVector av = ShortVector.zero(SPECIES);
7017 assert(av.species().vectorType() == av.getClass());
7018 }
7019
7020 @Test
7021 static void WithLanesShort64VectorTestsSmokeTest() {
7022 ShortVector av = ShortVector.zero(SPECIES);
7023 VectorSpecies species = av.species().withLanes(short.class);
7024 assert(species.equals(SPECIES));
7025 }
7026
7027 @Test
7028 static void WithShapeShort64VectorTestsSmokeTest() {
7029 ShortVector av = ShortVector.zero(SPECIES);
7030 VectorShape vsh = av.shape();
7031 VectorSpecies species = av.species().withShape(vsh);
7032 assert(species.equals(SPECIES));
7033 }
7034
7035 @Test
7036 static void MaskAllTrueShort64VectorTestsSmokeTest() {
7037 for (int ic = 0; ic < INVOC_COUNT; ic++) {
7038 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
7039 }
7040 }
7041 }