1 /*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 package compiler.c2.irTests;
26
27 import compiler.lib.ir_framework.*;
28 import java.util.Random;
29 import jdk.test.lib.Asserts;
30 import jdk.test.lib.Utils;
31
32 /*
33 * @test
34 * @bug 8289422 8306088 8313720
35 * @key randomness
36 * @summary Auto-vectorization enhancement to support vector conditional move.
37 * @library /test/lib /
38 * @run driver compiler.c2.irTests.TestVectorConditionalMove
39 */
40
41 public class TestVectorConditionalMove {
42 final private static int SIZE = 1024;
43 private static final Random RANDOM = Utils.getRandomInstance();
44
45 public static void main(String[] args) {
46 // Cross-product: +-AlignVector and +-UseCompactObjectHeaders
47 TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov",
48 "-XX:-UseCompactObjectHeaders", "-XX:-AlignVector");
49 TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov",
50 "-XX:-UseCompactObjectHeaders", "-XX:+AlignVector");
51 TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov",
52 "-XX:+UseCompactObjectHeaders", "-XX:-AlignVector");
53 TestFramework.runWithFlags("-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov",
54 "-XX:+UseCompactObjectHeaders", "-XX:+AlignVector");
55 }
56
57 // Compare 2 values, and pick one of them
58 private float cmoveFloatGT(float a, float b) {
59 return (a > b) ? a : b;
60 }
61
62 private float cmoveFloatGTSwap(float a, float b) {
63 return (b > a) ? a : b;
64 }
65
66 private float cmoveFloatLT(float a, float b) {
67 return (a < b) ? a : b;
68 }
69
70 private float cmoveFloatLTSwap(float a, float b) {
71 return (b < a) ? a : b;
72 }
73
74 private float cmoveFloatEQ(float a, float b) {
75 return (a == b) ? a : b;
76 }
77
78 private double cmoveDoubleLE(double a, double b) {
79 return (a <= b) ? a : b;
80 }
81
82 private double cmoveDoubleLESwap(double a, double b) {
83 return (b <= a) ? a : b;
84 }
85
86 private double cmoveDoubleGE(double a, double b) {
87 return (a >= b) ? a : b;
88 }
89
90 private double cmoveDoubleGESwap(double a, double b) {
91 return (b >= a) ? a : b;
92 }
93
94 private double cmoveDoubleNE(double a, double b) {
95 return (a != b) ? a : b;
96 }
97
98 // Extensions: compare 2 values, and pick from 2 consts
99 private float cmoveFGTforFConst(float a, float b) {
100 return (a > b) ? 0.1f : -0.1f;
101 }
102
103 private float cmoveFGEforFConst(float a, float b) {
104 return (a >= b) ? 0.1f : -0.1f;
105 }
106
107 private float cmoveFLTforFConst(float a, float b) {
108 return (a < b) ? 0.1f : -0.1f;
109 }
110
111 private float cmoveFLEforFConst(float a, float b) {
112 return (a <= b) ? 0.1f : -0.1f;
113 }
114
115 private float cmoveFEQforFConst(float a, float b) {
116 return (a == b) ? 0.1f : -0.1f;
117 }
118
119 private float cmoveFNEQforFConst(float a, float b) {
120 return (a != b) ? 0.1f : -0.1f;
121 }
122
123 private double cmoveDGTforDConst(double a, double b) {
124 return (a > b) ? 0.1 : -0.1;
125 }
126
127 private double cmoveDGEforDConst(double a, double b) {
128 return (a >= b) ? 0.1 : -0.1;
129 }
130
131 private double cmoveDLTforDConst(double a, double b) {
132 return (a < b) ? 0.1 : -0.1;
133 }
134
135 private double cmoveDLEforDConst(double a, double b) {
136 return (a <= b) ? 0.1 : -0.1;
137 }
138
139 private double cmoveDEQforDConst(double a, double b) {
140 return (a == b) ? 0.1 : -0.1;
141 }
142
143 private double cmoveDNEQforDConst(double a, double b) {
144 return (a != b) ? 0.1 : -0.1;
145 }
146
147 // Extension: Compare 2 ILFD values, and pick from 2 ILFD values
148 // Signed comparison: I/L
149 // I for I
150 private int cmoveIEQforI(int a, int b, int c, int d) {
151 return (a == b) ? c : d;
152 }
153
154 private int cmoveINEforI(int a, int b, int c, int d) {
155 return (a != b) ? c : d;
156 }
157
158 private int cmoveIGTforI(int a, int b, int c, int d) {
159 return (a > b) ? c : d;
160 }
161
162 private int cmoveIGEforI(int a, int b, int c, int d) {
163 return (a >= b) ? c : d;
164 }
165
166 private int cmoveILTforI(int a, int b, int c, int d) {
167 return (a < b) ? c : d;
168 }
169
170 private int cmoveILEforI(int a, int b, int c, int d) {
171 return (a <= b) ? c : d;
172 }
173
174 // I for L
175 private long cmoveIEQforL(int a, int b, long c, long d) {
176 return (a == b) ? c : d;
177 }
178
179 private long cmoveINEforL(int a, int b, long c, long d) {
180 return (a != b) ? c : d;
181 }
182
183 private long cmoveIGTforL(int a, int b, long c, long d) {
184 return (a > b) ? c : d;
185 }
186
187 private long cmoveIGEforL(int a, int b, long c, long d) {
188 return (a >= b) ? c : d;
189 }
190
191 private long cmoveILTforL(int a, int b, long c, long d) {
192 return (a < b) ? c : d;
193 }
194
195 private long cmoveILEforL(int a, int b, long c, long d) {
196 return (a <= b) ? c : d;
197 }
198
199 // I for F
200 private float cmoveIEQforF(int a, int b, float c, float d) {
201 return (a == b) ? c : d;
202 }
203
204 private float cmoveINEforF(int a, int b, float c, float d) {
205 return (a != b) ? c : d;
206 }
207
208 private float cmoveIGTforF(int a, int b, float c, float d) {
209 return (a > b) ? c : d;
210 }
211
212 private float cmoveIGEforF(int a, int b, float c, float d) {
213 return (a >= b) ? c : d;
214 }
215
216 private float cmoveILTforF(int a, int b, float c, float d) {
217 return (a < b) ? c : d;
218 }
219
220 private float cmoveILEforF(int a, int b, float c, float d) {
221 return (a <= b) ? c : d;
222 }
223
224 // I for D
225 private double cmoveIEQforD(int a, int b, double c, double d) {
226 return (a == b) ? c : d;
227 }
228
229 private double cmoveINEforD(int a, int b, double c, double d) {
230 return (a != b) ? c : d;
231 }
232
233 private double cmoveIGTforD(int a, int b, double c, double d) {
234 return (a > b) ? c : d;
235 }
236
237 private double cmoveIGEforD(int a, int b, double c, double d) {
238 return (a >= b) ? c : d;
239 }
240
241 private double cmoveILTforD(int a, int b, double c, double d) {
242 return (a < b) ? c : d;
243 }
244
245 private double cmoveILEforD(int a, int b, double c, double d) {
246 return (a <= b) ? c : d;
247 }
248
249 // L for I
250 private int cmoveLEQforI(long a, long b, int c, int d) {
251 return (a == b) ? c : d;
252 }
253
254 private int cmoveLNEforI(long a, long b, int c, int d) {
255 return (a != b) ? c : d;
256 }
257
258 private int cmoveLGTforI(long a, long b, int c, int d) {
259 return (a > b) ? c : d;
260 }
261
262 private int cmoveLGEforI(long a, long b, int c, int d) {
263 return (a >= b) ? c : d;
264 }
265
266 private int cmoveLLTforI(long a, long b, int c, int d) {
267 return (a < b) ? c : d;
268 }
269
270 private int cmoveLLEforI(long a, long b, int c, int d) {
271 return (a <= b) ? c : d;
272 }
273
274 // L for L
275 private long cmoveLEQforL(long a, long b, long c, long d) {
276 return (a == b) ? c : d;
277 }
278
279 private long cmoveLNEforL(long a, long b, long c, long d) {
280 return (a != b) ? c : d;
281 }
282
283 private long cmoveLGTforL(long a, long b, long c, long d) {
284 return (a > b) ? c : d;
285 }
286
287 private long cmoveLGEforL(long a, long b, long c, long d) {
288 return (a >= b) ? c : d;
289 }
290
291 private long cmoveLLTforL(long a, long b, long c, long d) {
292 return (a < b) ? c : d;
293 }
294
295 private long cmoveLLEforL(long a, long b, long c, long d) {
296 return (a <= b) ? c : d;
297 }
298
299 // L for F
300 private float cmoveLEQforF(long a, long b, float c, float d) {
301 return (a == b) ? c : d;
302 }
303
304 private float cmoveLNEforF(long a, long b, float c, float d) {
305 return (a != b) ? c : d;
306 }
307
308 private float cmoveLGTforF(long a, long b, float c, float d) {
309 return (a > b) ? c : d;
310 }
311
312 private float cmoveLGEforF(long a, long b, float c, float d) {
313 return (a >= b) ? c : d;
314 }
315
316 private float cmoveLLTforF(long a, long b, float c, float d) {
317 return (a < b) ? c : d;
318 }
319
320 private float cmoveLLEforF(long a, long b, float c, float d) {
321 return (a <= b) ? c : d;
322 }
323
324 // L for D
325 private double cmoveLEQforD(long a, long b, double c, double d) {
326 return (a == b) ? c : d;
327 }
328
329 private double cmoveLNEforD(long a, long b, double c, double d) {
330 return (a != b) ? c : d;
331 }
332
333 private double cmoveLGTforD(long a, long b, double c, double d) {
334 return (a > b) ? c : d;
335 }
336
337 private double cmoveLGEforD(long a, long b, double c, double d) {
338 return (a >= b) ? c : d;
339 }
340
341 private double cmoveLLTforD(long a, long b, double c, double d) {
342 return (a < b) ? c : d;
343 }
344
345 private double cmoveLLEforD(long a, long b, double c, double d) {
346 return (a <= b) ? c : d;
347 }
348
349 // Unsigned comparison: I/L
350 // I for I
351 private int cmoveUIEQforI(int a, int b, int c, int d) {
352 return Integer.compareUnsigned(a, b) == 0 ? c : d;
353 }
354
355 private int cmoveUINEforI(int a, int b, int c, int d) {
356 return Integer.compareUnsigned(a, b) != 0 ? c : d;
357 }
358
359 private int cmoveUIGTforI(int a, int b, int c, int d) {
360 return Integer.compareUnsigned(a, b) > 0 ? c : d;
361 }
362
363 private int cmoveUIGEforI(int a, int b, int c, int d) {
364 return Integer.compareUnsigned(a, b) >= 0 ? c : d;
365 }
366
367 private int cmoveUILTforI(int a, int b, int c, int d) {
368 return Integer.compareUnsigned(a, b) < 0 ? c : d;
369 }
370
371 private int cmoveUILEforI(int a, int b, int c, int d) {
372 return Integer.compareUnsigned(a, b) <= 0 ? c : d;
373 }
374
375 // I for L
376 private long cmoveUIEQforL(int a, int b, long c, long d) {
377 return Integer.compareUnsigned(a, b) == 0 ? c : d;
378 }
379
380 private long cmoveUINEforL(int a, int b, long c, long d) {
381 return Integer.compareUnsigned(a, b) != 0 ? c : d;
382 }
383
384 private long cmoveUIGTforL(int a, int b, long c, long d) {
385 return Integer.compareUnsigned(a, b) > 0 ? c : d;
386 }
387
388 private long cmoveUIGEforL(int a, int b, long c, long d) {
389 return Integer.compareUnsigned(a, b) >= 0 ? c : d;
390 }
391
392 private long cmoveUILTforL(int a, int b, long c, long d) {
393 return Integer.compareUnsigned(a, b) < 0 ? c : d;
394 }
395
396 private long cmoveUILEforL(int a, int b, long c, long d) {
397 return Integer.compareUnsigned(a, b) <= 0 ? c : d;
398 }
399
400 // I for F
401 private float cmoveUIEQforF(int a, int b, float c, float d) {
402 return Integer.compareUnsigned(a, b) == 0 ? c : d;
403 }
404
405 private float cmoveUINEforF(int a, int b, float c, float d) {
406 return Integer.compareUnsigned(a, b) != 0 ? c : d;
407 }
408
409 private float cmoveUIGTforF(int a, int b, float c, float d) {
410 return Integer.compareUnsigned(a, b) > 0 ? c : d;
411 }
412
413 private float cmoveUIGEforF(int a, int b, float c, float d) {
414 return Integer.compareUnsigned(a, b) >= 0 ? c : d;
415 }
416
417 private float cmoveUILTforF(int a, int b, float c, float d) {
418 return Integer.compareUnsigned(a, b) < 0 ? c : d;
419 }
420
421 private float cmoveUILEforF(int a, int b, float c, float d) {
422 return Integer.compareUnsigned(a, b) <= 0 ? c : d;
423 }
424
425 // I for D
426 private double cmoveUIEQforD(int a, int b, double c, double d) {
427 return Integer.compareUnsigned(a, b) == 0 ? c : d;
428 }
429
430 private double cmoveUINEforD(int a, int b, double c, double d) {
431 return Integer.compareUnsigned(a, b) != 0 ? c : d;
432 }
433
434 private double cmoveUIGTforD(int a, int b, double c, double d) {
435 return Integer.compareUnsigned(a, b) > 0 ? c : d;
436 }
437
438 private double cmoveUIGEforD(int a, int b, double c, double d) {
439 return Integer.compareUnsigned(a, b) >= 0 ? c : d;
440 }
441
442 private double cmoveUILTforD(int a, int b, double c, double d) {
443 return Integer.compareUnsigned(a, b) < 0 ? c : d;
444 }
445
446 private double cmoveUILEforD(int a, int b, double c, double d) {
447 return Integer.compareUnsigned(a, b) <= 0 ? c : d;
448 }
449
450 // L for I
451 private int cmoveULEQforI(long a, long b, int c, int d) {
452 return Long.compareUnsigned(a, b) == 0 ? c : d;
453 }
454
455 private int cmoveULNEforI(long a, long b, int c, int d) {
456 return Long.compareUnsigned(a, b) != 0 ? c : d;
457 }
458
459 private int cmoveULGTforI(long a, long b, int c, int d) {
460 return Long.compareUnsigned(a, b) > 0 ? c : d;
461 }
462
463 private int cmoveULGEforI(long a, long b, int c, int d) {
464 return Long.compareUnsigned(a, b) >= 0 ? c : d;
465 }
466
467 private int cmoveULLTforI(long a, long b, int c, int d) {
468 return Long.compareUnsigned(a, b) < 0 ? c : d;
469 }
470
471 private int cmoveULLEforI(long a, long b, int c, int d) {
472 return Long.compareUnsigned(a, b) <= 0 ? c : d;
473 }
474
475 // L for L
476 private long cmoveULEQforL(long a, long b, long c, long d) {
477 return Long.compareUnsigned(a, b) == 0 ? c : d;
478 }
479
480 private long cmoveULNEforL(long a, long b, long c, long d) {
481 return Long.compareUnsigned(a, b) != 0 ? c : d;
482 }
483
484 private long cmoveULGTforL(long a, long b, long c, long d) {
485 return Long.compareUnsigned(a, b) > 0 ? c : d;
486 }
487
488 private long cmoveULGEforL(long a, long b, long c, long d) {
489 return Long.compareUnsigned(a, b) >= 0 ? c : d;
490 }
491
492 private long cmoveULLTforL(long a, long b, long c, long d) {
493 return Long.compareUnsigned(a, b) < 0 ? c : d;
494 }
495
496 private long cmoveULLEforL(long a, long b, long c, long d) {
497 return Long.compareUnsigned(a, b) <= 0 ? c : d;
498 }
499
500 // L for F
501 private float cmoveULEQforF(long a, long b, float c, float d) {
502 return Long.compareUnsigned(a, b) == 0 ? c : d;
503 }
504
505 private float cmoveULNEforF(long a, long b, float c, float d) {
506 return Long.compareUnsigned(a, b) != 0 ? c : d;
507 }
508
509 private float cmoveULGTforF(long a, long b, float c, float d) {
510 return Long.compareUnsigned(a, b) > 0 ? c : d;
511 }
512
513 private float cmoveULGEforF(long a, long b, float c, float d) {
514 return Long.compareUnsigned(a, b) >= 0 ? c : d;
515 }
516
517 private float cmoveULLTforF(long a, long b, float c, float d) {
518 return Long.compareUnsigned(a, b) < 0 ? c : d;
519 }
520
521 private float cmoveULLEforF(long a, long b, float c, float d) {
522 return Long.compareUnsigned(a, b) <= 0 ? c : d;
523 }
524
525 // L for D
526 private double cmoveULEQforD(long a, long b, double c, double d) {
527 return Long.compareUnsigned(a, b) == 0 ? c : d;
528 }
529
530 private double cmoveULNEforD(long a, long b, double c, double d) {
531 return Long.compareUnsigned(a, b) != 0 ? c : d;
532 }
533
534 private double cmoveULGTforD(long a, long b, double c, double d) {
535 return Long.compareUnsigned(a, b) > 0 ? c : d;
536 }
537
538 private double cmoveULGEforD(long a, long b, double c, double d) {
539 return Long.compareUnsigned(a, b) >= 0 ? c : d;
540 }
541
542 private double cmoveULLTforD(long a, long b, double c, double d) {
543 return Long.compareUnsigned(a, b) < 0 ? c : d;
544 }
545
546 private double cmoveULLEforD(long a, long b, double c, double d) {
547 return Long.compareUnsigned(a, b) <= 0 ? c : d;
548 }
549
550 // Float comparison
551 private int cmoveFGTforI(float a, float b, int c, int d) {
552 return (a > b) ? c : d;
553 }
554
555 private long cmoveFGTforL(float a, float b, long c, long d) {
556 return (a > b) ? c : d;
557 }
558
559 private float cmoveFGTforF(float a, float b, float c, float d) {
560 return (a > b) ? c : d;
561 }
562
563 private double cmoveFGTforD(float a, float b, double c, double d) {
564 return (a > b) ? c : d;
565 }
566
567 private int cmoveDGTforI(double a, double b, int c, int d) {
568 return (a > b) ? c : d;
569 }
570
571 private long cmoveDGTforL(double a, double b, long c, long d) {
572 return (a > b) ? c : d;
573 }
574
575 private float cmoveDGTforF(double a, double b, float c, float d) {
576 return (a > b) ? c : d;
577 }
578
579 private double cmoveDGTforD(double a, double b, double c, double d) {
580 return (a > b) ? c : d;
581 }
582
583 // Compare 2 values, and pick one of them
584 @Test
585 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
586 IRNode.VECTOR_MASK_CMP_F, ">0",
587 IRNode.VECTOR_BLEND_F, ">0",
588 IRNode.STORE_VECTOR, ">0"},
589 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
590 private static void testCMoveVFGT(float[] a, float[] b, float[] c) {
591 for (int i = 0; i < a.length; i++) {
592 c[i] = (a[i] > b[i]) ? a[i] : b[i];
593 }
594 }
595
596 @Test
597 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
598 IRNode.VECTOR_MASK_CMP_F, ">0",
599 IRNode.VECTOR_BLEND_F, ">0",
600 IRNode.STORE_VECTOR, ">0"},
601 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
602 private static void testCMoveVFGTSwap(float[] a, float[] b, float[] c) {
603 for (int i = 0; i < a.length; i++) {
604 c[i] = (b[i] > a[i]) ? a[i] : b[i];
605 }
606 }
607
608 @Test
609 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
610 IRNode.VECTOR_MASK_CMP_F, ">0",
611 IRNode.VECTOR_BLEND_F, ">0",
612 IRNode.STORE_VECTOR, ">0"},
613 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
614 private static void testCMoveVFLT(float[] a, float[] b, float[] c) {
615 for (int i = 0; i < a.length; i++) {
616 c[i] = (a[i] < b[i]) ? a[i] : b[i];
617 }
618 }
619
620 @Test
621 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
622 IRNode.VECTOR_MASK_CMP_F, ">0",
623 IRNode.VECTOR_BLEND_F, ">0",
624 IRNode.STORE_VECTOR, ">0"},
625 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
626 private static void testCMoveVFLTSwap(float[] a, float[] b, float[] c) {
627 for (int i = 0; i < a.length; i++) {
628 c[i] = (b[i] < a[i]) ? a[i] : b[i];
629 }
630 }
631
632 @Test
633 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
634 IRNode.VECTOR_MASK_CMP_F, ">0",
635 IRNode.VECTOR_BLEND_F, ">0",
636 IRNode.STORE_VECTOR, ">0"},
637 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
638 private static void testCMoveVFEQ(float[] a, float[] b, float[] c) {
639 for (int i = 0; i < a.length; i++) {
640 c[i] = (a[i] == b[i]) ? a[i] : b[i];
641 }
642 }
643
644 @Test
645 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
646 IRNode.VECTOR_MASK_CMP_D, ">0",
647 IRNode.VECTOR_BLEND_D, ">0",
648 IRNode.STORE_VECTOR, ">0"},
649 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
650 private static void testCMoveVDLE(double[] a, double[] b, double[] c) {
651 for (int i = 0; i < a.length; i++) {
652 c[i] = (a[i] <= b[i]) ? a[i] : b[i];
653 }
654 }
655
656 @Test
657 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
658 IRNode.VECTOR_MASK_CMP_D, ">0",
659 IRNode.VECTOR_BLEND_D, ">0",
660 IRNode.STORE_VECTOR, ">0"},
661 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
662 private static void testCMoveVDLESwap(double[] a, double[] b, double[] c) {
663 for (int i = 0; i < a.length; i++) {
664 c[i] = (b[i] <= a[i]) ? a[i] : b[i];
665 }
666 }
667
668 @Test
669 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
670 IRNode.VECTOR_MASK_CMP_D, ">0",
671 IRNode.VECTOR_BLEND_D, ">0",
672 IRNode.STORE_VECTOR, ">0"},
673 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
674 private static void testCMoveVDGE(double[] a, double[] b, double[] c) {
675 for (int i = 0; i < a.length; i++) {
676 c[i] = (a[i] >= b[i]) ? a[i] : b[i];
677 }
678 }
679
680 @Test
681 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
682 IRNode.VECTOR_MASK_CMP_D, ">0",
683 IRNode.VECTOR_BLEND_D, ">0",
684 IRNode.STORE_VECTOR, ">0"},
685 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
686 private static void testCMoveVDGESwap(double[] a, double[] b, double[] c) {
687 for (int i = 0; i < a.length; i++) {
688 c[i] = (b[i] >= a[i]) ? a[i] : b[i];
689 }
690 }
691
692 @Test
693 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
694 IRNode.VECTOR_MASK_CMP_D, ">0",
695 IRNode.VECTOR_BLEND_D, ">0",
696 IRNode.STORE_VECTOR, ">0"},
697 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
698 private static void testCMoveVDNE(double[] a, double[] b, double[] c) {
699 for (int i = 0; i < a.length; i++) {
700 c[i] = (a[i] != b[i]) ? a[i] : b[i];
701 }
702 }
703
704 // Extensions: compare 2 values, and pick from 2 consts
705 @Test
706 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
707 IRNode.VECTOR_MASK_CMP_F, ">0",
708 IRNode.VECTOR_BLEND_F, ">0",
709 IRNode.STORE_VECTOR, ">0"},
710 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
711 private static void testCMoveFGTforFConst(float[] a, float[] b, float[] c) {
712 for (int i = 0; i < a.length; i++) {
713 c[i] = (a[i] > b[i]) ? 0.1f : -0.1f;
714 }
715 }
716
717 @Test
718 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
719 IRNode.VECTOR_MASK_CMP_F, ">0",
720 IRNode.VECTOR_BLEND_F, ">0",
721 IRNode.STORE_VECTOR, ">0"},
722 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
723 private static void testCMoveFGEforFConst(float[] a, float[] b, float[] c) {
724 for (int i = 0; i < a.length; i++) {
725 c[i] = (a[i] >= b[i]) ? 0.1f : -0.1f;
726 }
727 }
728
729 @Test
730 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
731 IRNode.VECTOR_MASK_CMP_F, ">0",
732 IRNode.VECTOR_BLEND_F, ">0",
733 IRNode.STORE_VECTOR, ">0"},
734 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
735 private static void testCMoveFLTforFConst(float[] a, float[] b, float[] c) {
736 for (int i = 0; i < a.length; i++) {
737 c[i] = (a[i] < b[i]) ? 0.1f : -0.1f;
738 }
739 }
740
741 @Test
742 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
743 IRNode.VECTOR_MASK_CMP_F, ">0",
744 IRNode.VECTOR_BLEND_F, ">0",
745 IRNode.STORE_VECTOR, ">0"},
746 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
747 private static void testCMoveFLEforFConst(float[] a, float[] b, float[] c) {
748 for (int i = 0; i < a.length; i++) {
749 c[i] = (a[i] <= b[i]) ? 0.1f : -0.1f;
750 }
751 }
752
753 @Test
754 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
755 IRNode.VECTOR_MASK_CMP_F, ">0",
756 IRNode.VECTOR_BLEND_F, ">0",
757 IRNode.STORE_VECTOR, ">0"},
758 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
759 private static void testCMoveFEQforFConst(float[] a, float[] b, float[] c) {
760 for (int i = 0; i < a.length; i++) {
761 c[i] = (a[i] == b[i]) ? 0.1f : -0.1f;
762 }
763 }
764
765 @Test
766 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
767 IRNode.VECTOR_MASK_CMP_F, ">0",
768 IRNode.VECTOR_BLEND_F, ">0",
769 IRNode.STORE_VECTOR, ">0"},
770 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
771 private static void testCMoveFNEQforFConst(float[] a, float[] b, float[] c) {
772 for (int i = 0; i < a.length; i++) {
773 c[i] = (a[i] != b[i]) ? 0.1f : -0.1f;
774 }
775 }
776
777 @Test
778 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
779 IRNode.VECTOR_MASK_CMP_F, ">0",
780 IRNode.VECTOR_BLEND_F, ">0",
781 IRNode.STORE_VECTOR, ">0"},
782 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
783 private static void testCMoveFLTforFConstH2(float[] a, float[] b, float[] c) {
784 for (int i = 0; i < a.length; i+=2) {
785 c[i+0] = (a[i+0] < b[i+0]) ? 0.1f : -0.1f;
786 c[i+1] = (a[i+1] < b[i+1]) ? 0.1f : -0.1f;
787 }
788 }
789
790 @Test
791 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
792 IRNode.VECTOR_MASK_CMP_F, ">0",
793 IRNode.VECTOR_BLEND_F, ">0",
794 IRNode.STORE_VECTOR, ">0"},
795 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
796 private static void testCMoveFLEforFConstH2(float[] a, float[] b, float[] c) {
797 for (int i = 0; i < a.length; i+=2) {
798 c[i+0] = (a[i+0] <= b[i+0]) ? 0.1f : -0.1f;
799 c[i+1] = (a[i+1] <= b[i+1]) ? 0.1f : -0.1f;
800 }
801 }
802
803 @Test
804 @IR(counts = {IRNode.LOAD_VECTOR_F, "=0",
805 IRNode.VECTOR_MASK_CMP_F, "=0",
806 IRNode.VECTOR_BLEND_F, "=0",
807 IRNode.STORE_VECTOR, "=0"},
808 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
809 private static void testCMoveFYYforFConstH2(float[] a, float[] b, float[] c) {
810 for (int i = 0; i < a.length; i+=2) {
811 c[i+0] = (a[i+0] <= b[i+0]) ? 0.1f : -0.1f;
812 c[i+1] = (a[i+1] < b[i+1]) ? 0.1f : -0.1f;
813 }
814 }
815
816 @Test
817 @IR(counts = {IRNode.LOAD_VECTOR_F, "=0",
818 IRNode.VECTOR_MASK_CMP_F, "=0",
819 IRNode.VECTOR_BLEND_F, "=0",
820 IRNode.STORE_VECTOR, "=0"},
821 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
822 private static void testCMoveFXXforFConstH2(float[] a, float[] b, float[] c) {
823 for (int i = 0; i < a.length; i+=2) {
824 c[i+0] = (a[i+0] < b[i+0]) ? 0.1f : -0.1f;
825 c[i+1] = (a[i+1] <= b[i+1]) ? 0.1f : -0.1f;
826 }
827 }
828
829 @Test
830 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
831 IRNode.VECTOR_MASK_CMP_D, ">0",
832 IRNode.VECTOR_BLEND_D, ">0",
833 IRNode.STORE_VECTOR, ">0"},
834 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
835 private static void testCMoveDGTforDConst(double[] a, double[] b, double[] c) {
836 for (int i = 0; i < a.length; i++) {
837 c[i] = (a[i] > b[i]) ? 0.1 : -0.1;
838 }
839 }
840
841 @Test
842 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
843 IRNode.VECTOR_MASK_CMP_D, ">0",
844 IRNode.VECTOR_BLEND_D, ">0",
845 IRNode.STORE_VECTOR, ">0"},
846 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
847 private static void testCMoveDGEforDConst(double[] a, double[] b, double[] c) {
848 for (int i = 0; i < a.length; i++) {
849 c[i] = (a[i] >= b[i]) ? 0.1 : -0.1;
850 }
851 }
852
853 @Test
854 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
855 IRNode.VECTOR_MASK_CMP_D, ">0",
856 IRNode.VECTOR_BLEND_D, ">0",
857 IRNode.STORE_VECTOR, ">0"},
858 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
859 private static void testCMoveDLTforDConst(double[] a, double[] b, double[] c) {
860 for (int i = 0; i < a.length; i++) {
861 c[i] = (a[i] < b[i]) ? 0.1 : -0.1;
862 }
863 }
864
865 @Test
866 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
867 IRNode.VECTOR_MASK_CMP_D, ">0",
868 IRNode.VECTOR_BLEND_D, ">0",
869 IRNode.STORE_VECTOR, ">0"},
870 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
871 private static void testCMoveDLEforDConst(double[] a, double[] b, double[] c) {
872 for (int i = 0; i < a.length; i++) {
873 c[i] = (a[i] <= b[i]) ? 0.1 : -0.1;
874 }
875 }
876
877 @Test
878 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
879 IRNode.VECTOR_MASK_CMP_D, ">0",
880 IRNode.VECTOR_BLEND_D, ">0",
881 IRNode.STORE_VECTOR, ">0"},
882 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
883 private static void testCMoveDEQforDConst(double[] a, double[] b, double[] c) {
884 for (int i = 0; i < a.length; i++) {
885 c[i] = (a[i] == b[i]) ? 0.1 : -0.1;
886 }
887 }
888
889 @Test
890 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
891 IRNode.VECTOR_MASK_CMP_D, ">0",
892 IRNode.VECTOR_BLEND_D, ">0",
893 IRNode.STORE_VECTOR, ">0"},
894 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
895 private static void testCMoveDNEQforDConst(double[] a, double[] b, double[] c) {
896 for (int i = 0; i < a.length; i++) {
897 c[i] = (a[i] != b[i]) ? 0.1 : -0.1;
898 }
899 }
900
901 @Test
902 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
903 IRNode.VECTOR_MASK_CMP_D, ">0",
904 IRNode.VECTOR_BLEND_D, ">0",
905 IRNode.STORE_VECTOR, ">0"},
906 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
907 private static void testCMoveDLTforDConstH2(double[] a, double[] b, double[] c) {
908 for (int i = 0; i < a.length; i+=2) {
909 c[i+0] = (a[i+0] < b[i+0]) ? 0.1 : -0.1;
910 c[i+1] = (a[i+1] < b[i+1]) ? 0.1 : -0.1;
911 }
912 }
913
914 @Test
915 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
916 IRNode.VECTOR_MASK_CMP_D, ">0",
917 IRNode.VECTOR_BLEND_D, ">0",
918 IRNode.STORE_VECTOR, ">0"},
919 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
920 private static void testCMoveDLEforDConstH2(double[] a, double[] b, double[] c) {
921 for (int i = 0; i < a.length; i+=2) {
922 c[i+0] = (a[i+0] <= b[i+0]) ? 0.1 : -0.1;
923 c[i+1] = (a[i+1] <= b[i+1]) ? 0.1 : -0.1;
924 }
925 }
926
927 @Test
928 @IR(counts = {IRNode.LOAD_VECTOR_D, "=0",
929 IRNode.VECTOR_MASK_CMP_D, "=0",
930 IRNode.VECTOR_BLEND_D, "=0",
931 IRNode.STORE_VECTOR, "=0"},
932 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
933 private static void testCMoveDYYforDConstH2(double[] a, double[] b, double[] c) {
934 for (int i = 0; i < a.length; i+=2) {
935 c[i+0] = (a[i+0] <= b[i+0]) ? 0.1 : -0.1;
936 c[i+1] = (a[i+1] < b[i+1]) ? 0.1 : -0.1;
937 }
938 }
939
940 @Test
941 @IR(counts = {IRNode.LOAD_VECTOR_D, "=0",
942 IRNode.VECTOR_MASK_CMP_D, "=0",
943 IRNode.VECTOR_BLEND_D, "=0",
944 IRNode.STORE_VECTOR, "=0"},
945 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
946 private static void testCMoveDXXforDConstH2(double[] a, double[] b, double[] c) {
947 for (int i = 0; i < a.length; i+=2) {
948 c[i+0] = (a[i+0] < b[i+0]) ? 0.1 : -0.1;
949 c[i+1] = (a[i+1] <= b[i+1]) ? 0.1 : -0.1;
950 }
951 }
952
953 // Extension: Compare 2 ILFD values, and pick from 2 ILFD values
954 // Note:
955 // To guarantee that CMove is introduced, I need to perform the loads before the branch. To ensure they
956 // do not float down into the branches, I compute a value, and store it to r2 (same as r, except that the
957 // compilation does not know that).
958 // So far, vectorization only works for CMoveF/D, with same data-width comparison (F/I for F, D/L for D).
959 // Signed comparison: I/L
960 // I fo I
961 @Test
962 @IR(failOn = {IRNode.STORE_VECTOR})
963 private static void testCMoveIEQforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
964 for (int i = 0; i < a.length; i++) {
965 int cc = c[i];
966 int dd = d[i];
967 r2[i] = cc + dd;
968 r[i] = (a[i] == b[i]) ? cc : dd;
969 }
970 }
971
972 @Test
973 @IR(failOn = {IRNode.STORE_VECTOR})
974 private static void testCMoveINEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
975 for (int i = 0; i < a.length; i++) {
976 int cc = c[i];
977 int dd = d[i];
978 r2[i] = cc + dd;
979 r[i] = (a[i] != b[i]) ? cc : dd;
980 }
981 }
982
983 @Test
984 @IR(failOn = {IRNode.STORE_VECTOR})
985 private static void testCMoveIGTforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
986 for (int i = 0; i < a.length; i++) {
987 int cc = c[i];
988 int dd = d[i];
989 r2[i] = cc + dd;
990 r[i] = (a[i] > b[i]) ? cc : dd;
991 }
992 }
993
994 @Test
995 @IR(failOn = {IRNode.STORE_VECTOR})
996 private static void testCMoveIGEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
997 for (int i = 0; i < a.length; i++) {
998 int cc = c[i];
999 int dd = d[i];
1000 r2[i] = cc + dd;
1001 r[i] = (a[i] >= b[i]) ? cc : dd;
1002 }
1003 }
1004
1005 @Test
1006 @IR(failOn = {IRNode.STORE_VECTOR})
1007 private static void testCMoveILTforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1008 for (int i = 0; i < a.length; i++) {
1009 int cc = c[i];
1010 int dd = d[i];
1011 r2[i] = cc + dd;
1012 r[i] = (a[i] < b[i]) ? cc : dd;
1013 }
1014 }
1015
1016 @Test
1017 @IR(failOn = {IRNode.STORE_VECTOR})
1018 private static void testCMoveILEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1019 for (int i = 0; i < a.length; i++) {
1020 int cc = c[i];
1021 int dd = d[i];
1022 r2[i] = cc + dd;
1023 r[i] = (a[i] <= b[i]) ? cc : dd;
1024 }
1025 }
1026
1027 // I fo L
1028 @Test
1029 @IR(failOn = {IRNode.STORE_VECTOR})
1030 private static void testCMoveIEQforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1031 for (int i = 0; i < a.length; i++) {
1032 long cc = c[i];
1033 long dd = d[i];
1034 r2[i] = cc + dd;
1035 r[i] = (a[i] == b[i]) ? cc : dd;
1036 }
1037 }
1038
1039 @Test
1040 @IR(failOn = {IRNode.STORE_VECTOR})
1041 private static void testCMoveINEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1042 for (int i = 0; i < a.length; i++) {
1043 long cc = c[i];
1044 long dd = d[i];
1045 r2[i] = cc + dd;
1046 r[i] = (a[i] != b[i]) ? cc : dd;
1047 }
1048 }
1049
1050 @Test
1051 @IR(failOn = {IRNode.STORE_VECTOR})
1052 private static void testCMoveIGTforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1053 for (int i = 0; i < a.length; i++) {
1054 long cc = c[i];
1055 long dd = d[i];
1056 r2[i] = cc + dd;
1057 r[i] = (a[i] > b[i]) ? cc : dd;
1058 }
1059 }
1060
1061 @Test
1062 @IR(failOn = {IRNode.STORE_VECTOR})
1063 private static void testCMoveIGEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1064 for (int i = 0; i < a.length; i++) {
1065 long cc = c[i];
1066 long dd = d[i];
1067 r2[i] = cc + dd;
1068 r[i] = (a[i] >= b[i]) ? cc : dd;
1069 }
1070 }
1071
1072 @Test
1073 @IR(failOn = {IRNode.STORE_VECTOR})
1074 private static void testCMoveILTforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1075 for (int i = 0; i < a.length; i++) {
1076 long cc = c[i];
1077 long dd = d[i];
1078 r2[i] = cc + dd;
1079 r[i] = (a[i] < b[i]) ? cc : dd;
1080 }
1081 }
1082
1083 @Test
1084 @IR(failOn = {IRNode.STORE_VECTOR})
1085 private static void testCMoveILEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1086 for (int i = 0; i < a.length; i++) {
1087 long cc = c[i];
1088 long dd = d[i];
1089 r2[i] = cc + dd;
1090 r[i] = (a[i] <= b[i]) ? cc : dd;
1091 }
1092 }
1093
1094 // I fo F
1095 @Test
1096 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1097 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1098 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1099 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1100 IRNode.STORE_VECTOR, ">0"},
1101 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1102 private static void testCMoveIEQforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1103 for (int i = 0; i < a.length; i++) {
1104 float cc = c[i];
1105 float dd = d[i];
1106 r2[i] = cc + dd;
1107 r[i] = (a[i] == b[i]) ? cc : dd;
1108 }
1109 }
1110
1111 @Test
1112 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1113 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1114 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1115 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1116 IRNode.STORE_VECTOR, ">0"},
1117 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1118 private static void testCMoveINEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1119 for (int i = 0; i < a.length; i++) {
1120 float cc = c[i];
1121 float dd = d[i];
1122 r2[i] = cc + dd;
1123 r[i] = (a[i] != b[i]) ? cc : dd;
1124 }
1125 }
1126
1127 @Test
1128 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1129 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1130 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1131 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1132 IRNode.STORE_VECTOR, ">0"},
1133 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1134 private static void testCMoveIGTforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1135 for (int i = 0; i < a.length; i++) {
1136 float cc = c[i];
1137 float dd = d[i];
1138 r2[i] = cc + dd;
1139 r[i] = (a[i] > b[i]) ? cc : dd;
1140 }
1141 }
1142
1143 @Test
1144 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1145 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1146 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1147 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1148 IRNode.STORE_VECTOR, ">0"},
1149 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1150 private static void testCMoveIGEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1151 for (int i = 0; i < a.length; i++) {
1152 float cc = c[i];
1153 float dd = d[i];
1154 r2[i] = cc + dd;
1155 r[i] = (a[i] >= b[i]) ? cc : dd;
1156 }
1157 }
1158
1159 @Test
1160 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1161 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1162 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1163 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1164 IRNode.STORE_VECTOR, ">0"},
1165 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1166 private static void testCMoveILTforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1167 for (int i = 0; i < a.length; i++) {
1168 float cc = c[i];
1169 float dd = d[i];
1170 r2[i] = cc + dd;
1171 r[i] = (a[i] < b[i]) ? cc : dd;
1172 }
1173 }
1174
1175 @Test
1176 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1177 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1178 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1179 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1180 IRNode.STORE_VECTOR, ">0"},
1181 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1182 private static void testCMoveILEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1183 for (int i = 0; i < a.length; i++) {
1184 float cc = c[i];
1185 float dd = d[i];
1186 r2[i] = cc + dd;
1187 r[i] = (a[i] <= b[i]) ? cc : dd;
1188 }
1189 }
1190
1191 // I fo D
1192 @Test
1193 @IR(failOn = {IRNode.STORE_VECTOR})
1194 private static void testCMoveIEQforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1195 for (int i = 0; i < a.length; i++) {
1196 double cc = c[i];
1197 double dd = d[i];
1198 r2[i] = cc + dd;
1199 r[i] = (a[i] == b[i]) ? cc : dd;
1200 }
1201 }
1202
1203 @Test
1204 @IR(failOn = {IRNode.STORE_VECTOR})
1205 private static void testCMoveINEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1206 for (int i = 0; i < a.length; i++) {
1207 double cc = c[i];
1208 double dd = d[i];
1209 r2[i] = cc + dd;
1210 r[i] = (a[i] != b[i]) ? cc : dd;
1211 }
1212 }
1213
1214 @Test
1215 @IR(failOn = {IRNode.STORE_VECTOR})
1216 private static void testCMoveIGTforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1217 for (int i = 0; i < a.length; i++) {
1218 double cc = c[i];
1219 double dd = d[i];
1220 r2[i] = cc + dd;
1221 r[i] = (a[i] > b[i]) ? cc : dd;
1222 }
1223 }
1224
1225 @Test
1226 @IR(failOn = {IRNode.STORE_VECTOR})
1227 private static void testCMoveIGEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1228 for (int i = 0; i < a.length; i++) {
1229 double cc = c[i];
1230 double dd = d[i];
1231 r2[i] = cc + dd;
1232 r[i] = (a[i] >= b[i]) ? cc : dd;
1233 }
1234 }
1235
1236 @Test
1237 @IR(failOn = {IRNode.STORE_VECTOR})
1238 private static void testCMoveILTforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1239 for (int i = 0; i < a.length; i++) {
1240 double cc = c[i];
1241 double dd = d[i];
1242 r2[i] = cc + dd;
1243 r[i] = (a[i] < b[i]) ? cc : dd;
1244 }
1245 }
1246
1247 @Test
1248 @IR(failOn = {IRNode.STORE_VECTOR})
1249 private static void testCMoveILEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1250 for (int i = 0; i < a.length; i++) {
1251 double cc = c[i];
1252 double dd = d[i];
1253 r2[i] = cc + dd;
1254 r[i] = (a[i] <= b[i]) ? cc : dd;
1255 }
1256 }
1257
1258 // L fo I
1259 @Test
1260 @IR(failOn = {IRNode.STORE_VECTOR})
1261 private static void testCMoveLEQforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1262 for (int i = 0; i < a.length; i++) {
1263 int cc = c[i];
1264 int dd = d[i];
1265 r2[i] = cc + dd;
1266 r[i] = (a[i] == b[i]) ? cc : dd;
1267 }
1268 }
1269
1270 @Test
1271 @IR(failOn = {IRNode.STORE_VECTOR})
1272 private static void testCMoveLNEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1273 for (int i = 0; i < a.length; i++) {
1274 int cc = c[i];
1275 int dd = d[i];
1276 r2[i] = cc + dd;
1277 r[i] = (a[i] != b[i]) ? cc : dd;
1278 }
1279 }
1280
1281 @Test
1282 @IR(failOn = {IRNode.STORE_VECTOR})
1283 private static void testCMoveLGTforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1284 for (int i = 0; i < a.length; i++) {
1285 int cc = c[i];
1286 int dd = d[i];
1287 r2[i] = cc + dd;
1288 r[i] = (a[i] > b[i]) ? cc : dd;
1289 }
1290 }
1291
1292 @Test
1293 @IR(failOn = {IRNode.STORE_VECTOR})
1294 private static void testCMoveLGEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1295 for (int i = 0; i < a.length; i++) {
1296 int cc = c[i];
1297 int dd = d[i];
1298 r2[i] = cc + dd;
1299 r[i] = (a[i] >= b[i]) ? cc : dd;
1300 }
1301 }
1302
1303 @Test
1304 @IR(failOn = {IRNode.STORE_VECTOR})
1305 private static void testCMoveLLTforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1306 for (int i = 0; i < a.length; i++) {
1307 int cc = c[i];
1308 int dd = d[i];
1309 r2[i] = cc + dd;
1310 r[i] = (a[i] < b[i]) ? cc : dd;
1311 }
1312 }
1313
1314 @Test
1315 @IR(failOn = {IRNode.STORE_VECTOR})
1316 private static void testCMoveLLEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1317 for (int i = 0; i < a.length; i++) {
1318 int cc = c[i];
1319 int dd = d[i];
1320 r2[i] = cc + dd;
1321 r[i] = (a[i] <= b[i]) ? cc : dd;
1322 }
1323 }
1324
1325 // L fo L
1326 @Test
1327 @IR(failOn = {IRNode.STORE_VECTOR})
1328 private static void testCMoveLEQforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1329 for (int i = 0; i < a.length; i++) {
1330 long cc = c[i];
1331 long dd = d[i];
1332 r2[i] = cc + dd;
1333 r[i] = (a[i] == b[i]) ? cc : dd;
1334 }
1335 }
1336
1337 @Test
1338 @IR(failOn = {IRNode.STORE_VECTOR})
1339 private static void testCMoveLNEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1340 for (int i = 0; i < a.length; i++) {
1341 long cc = c[i];
1342 long dd = d[i];
1343 r2[i] = cc + dd;
1344 r[i] = (a[i] != b[i]) ? cc : dd;
1345 }
1346 }
1347
1348 @Test
1349 @IR(failOn = {IRNode.STORE_VECTOR})
1350 private static void testCMoveLGTforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1351 for (int i = 0; i < a.length; i++) {
1352 long cc = c[i];
1353 long dd = d[i];
1354 r2[i] = cc + dd;
1355 r[i] = (a[i] > b[i]) ? cc : dd;
1356 }
1357 }
1358
1359 @Test
1360 @IR(failOn = {IRNode.STORE_VECTOR})
1361 private static void testCMoveLGEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1362 for (int i = 0; i < a.length; i++) {
1363 long cc = c[i];
1364 long dd = d[i];
1365 r2[i] = cc + dd;
1366 r[i] = (a[i] >= b[i]) ? cc : dd;
1367 }
1368 }
1369
1370 @Test
1371 @IR(failOn = {IRNode.STORE_VECTOR})
1372 private static void testCMoveLLTforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1373 for (int i = 0; i < a.length; i++) {
1374 long cc = c[i];
1375 long dd = d[i];
1376 r2[i] = cc + dd;
1377 r[i] = (a[i] < b[i]) ? cc : dd;
1378 }
1379 }
1380
1381 @Test
1382 @IR(failOn = {IRNode.STORE_VECTOR})
1383 private static void testCMoveLLEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1384 for (int i = 0; i < a.length; i++) {
1385 long cc = c[i];
1386 long dd = d[i];
1387 r2[i] = cc + dd;
1388 r[i] = (a[i] <= b[i]) ? cc : dd;
1389 }
1390 }
1391
1392 // L fo F
1393 @Test
1394 @IR(failOn = {IRNode.STORE_VECTOR})
1395 private static void testCMoveLEQforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1396 for (int i = 0; i < a.length; i++) {
1397 float cc = c[i];
1398 float dd = d[i];
1399 r2[i] = cc + dd;
1400 r[i] = (a[i] == b[i]) ? cc : dd;
1401 }
1402 }
1403
1404 @Test
1405 @IR(failOn = {IRNode.STORE_VECTOR})
1406 private static void testCMoveLNEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1407 for (int i = 0; i < a.length; i++) {
1408 float cc = c[i];
1409 float dd = d[i];
1410 r2[i] = cc + dd;
1411 r[i] = (a[i] != b[i]) ? cc : dd;
1412 }
1413 }
1414
1415 @Test
1416 @IR(failOn = {IRNode.STORE_VECTOR})
1417 private static void testCMoveLGTforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1418 for (int i = 0; i < a.length; i++) {
1419 float cc = c[i];
1420 float dd = d[i];
1421 r2[i] = cc + dd;
1422 r[i] = (a[i] > b[i]) ? cc : dd;
1423 }
1424 }
1425
1426 @Test
1427 @IR(failOn = {IRNode.STORE_VECTOR})
1428 private static void testCMoveLGEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1429 for (int i = 0; i < a.length; i++) {
1430 float cc = c[i];
1431 float dd = d[i];
1432 r2[i] = cc + dd;
1433 r[i] = (a[i] >= b[i]) ? cc : dd;
1434 }
1435 }
1436
1437 @Test
1438 @IR(failOn = {IRNode.STORE_VECTOR})
1439 private static void testCMoveLLTforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1440 for (int i = 0; i < a.length; i++) {
1441 float cc = c[i];
1442 float dd = d[i];
1443 r2[i] = cc + dd;
1444 r[i] = (a[i] < b[i]) ? cc : dd;
1445 }
1446 }
1447
1448 @Test
1449 @IR(failOn = {IRNode.STORE_VECTOR})
1450 private static void testCMoveLLEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1451 for (int i = 0; i < a.length; i++) {
1452 float cc = c[i];
1453 float dd = d[i];
1454 r2[i] = cc + dd;
1455 r[i] = (a[i] <= b[i]) ? cc : dd;
1456 }
1457 }
1458
1459 // L fo D
1460 @Test
1461 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1462 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1463 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1464 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1465 IRNode.STORE_VECTOR, ">0"},
1466 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1467 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1468 private static void testCMoveLEQforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1469 for (int i = 0; i < a.length; i++) {
1470 double cc = c[i];
1471 double dd = d[i];
1472 r2[i] = cc + dd;
1473 r[i] = (a[i] == b[i]) ? cc : dd;
1474 }
1475 }
1476
1477 @Test
1478 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1479 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1480 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1481 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1482 IRNode.STORE_VECTOR, ">0"},
1483 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1484 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1485 private static void testCMoveLNEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1486 for (int i = 0; i < a.length; i++) {
1487 double cc = c[i];
1488 double dd = d[i];
1489 r2[i] = cc + dd;
1490 r[i] = (a[i] != b[i]) ? cc : dd;
1491 }
1492 }
1493
1494 @Test
1495 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1496 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1497 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1498 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1499 IRNode.STORE_VECTOR, ">0"},
1500 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1501 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1502 private static void testCMoveLGTforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1503 for (int i = 0; i < a.length; i++) {
1504 double cc = c[i];
1505 double dd = d[i];
1506 r2[i] = cc + dd;
1507 r[i] = (a[i] > b[i]) ? cc : dd;
1508 }
1509 }
1510
1511 @Test
1512 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1513 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1514 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1515 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1516 IRNode.STORE_VECTOR, ">0"},
1517 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1518 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1519 private static void testCMoveLGEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1520 for (int i = 0; i < a.length; i++) {
1521 double cc = c[i];
1522 double dd = d[i];
1523 r2[i] = cc + dd;
1524 r[i] = (a[i] >= b[i]) ? cc : dd;
1525 }
1526 }
1527
1528 @Test
1529 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1530 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1531 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1532 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1533 IRNode.STORE_VECTOR, ">0"},
1534 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1535 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1536 private static void testCMoveLLTforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1537 for (int i = 0; i < a.length; i++) {
1538 double cc = c[i];
1539 double dd = d[i];
1540 r2[i] = cc + dd;
1541 r[i] = (a[i] < b[i]) ? cc : dd;
1542 }
1543 }
1544
1545 @Test
1546 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1547 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1548 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1549 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
1550 IRNode.STORE_VECTOR, ">0"},
1551 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
1552 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
1553 private static void testCMoveLLEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
1554 for (int i = 0; i < a.length; i++) {
1555 double cc = c[i];
1556 double dd = d[i];
1557 r2[i] = cc + dd;
1558 r[i] = (a[i] <= b[i]) ? cc : dd;
1559 }
1560 }
1561
1562 // Unsigned comparison: I/L
1563 // I fo I
1564 @Test
1565 @IR(failOn = {IRNode.STORE_VECTOR})
1566 private static void testCMoveUIEQforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1567 for (int i = 0; i < a.length; i++) {
1568 int cc = c[i];
1569 int dd = d[i];
1570 r2[i] = cc + dd;
1571 r[i] = Integer.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1572 }
1573 }
1574
1575 @Test
1576 @IR(failOn = {IRNode.STORE_VECTOR})
1577 private static void testCMoveUINEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1578 for (int i = 0; i < a.length; i++) {
1579 int cc = c[i];
1580 int dd = d[i];
1581 r2[i] = cc + dd;
1582 r[i] = Integer.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1583 }
1584 }
1585
1586 @Test
1587 @IR(failOn = {IRNode.STORE_VECTOR})
1588 private static void testCMoveUIGTforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1589 for (int i = 0; i < a.length; i++) {
1590 int cc = c[i];
1591 int dd = d[i];
1592 r2[i] = cc + dd;
1593 r[i] = Integer.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1594 }
1595 }
1596
1597 @Test
1598 @IR(failOn = {IRNode.STORE_VECTOR})
1599 private static void testCMoveUIGEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1600 for (int i = 0; i < a.length; i++) {
1601 int cc = c[i];
1602 int dd = d[i];
1603 r2[i] = cc + dd;
1604 r[i] = Integer.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1605 }
1606 }
1607
1608 @Test
1609 @IR(failOn = {IRNode.STORE_VECTOR})
1610 private static void testCMoveUILTforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1611 for (int i = 0; i < a.length; i++) {
1612 int cc = c[i];
1613 int dd = d[i];
1614 r2[i] = cc + dd;
1615 r[i] = Integer.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1616 }
1617 }
1618
1619 @Test
1620 @IR(failOn = {IRNode.STORE_VECTOR})
1621 private static void testCMoveUILEforI(int[] a, int[] b, int[] c, int[] d, int[] r, int[] r2) {
1622 for (int i = 0; i < a.length; i++) {
1623 int cc = c[i];
1624 int dd = d[i];
1625 r2[i] = cc + dd;
1626 r[i] = Integer.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1627 }
1628 }
1629
1630 // I fo L
1631 @Test
1632 @IR(failOn = {IRNode.STORE_VECTOR})
1633 private static void testCMoveUIEQforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1634 for (int i = 0; i < a.length; i++) {
1635 long cc = c[i];
1636 long dd = d[i];
1637 r2[i] = cc + dd;
1638 r[i] = Integer.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1639 }
1640 }
1641
1642 @Test
1643 @IR(failOn = {IRNode.STORE_VECTOR})
1644 private static void testCMoveUINEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1645 for (int i = 0; i < a.length; i++) {
1646 long cc = c[i];
1647 long dd = d[i];
1648 r2[i] = cc + dd;
1649 r[i] = Integer.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1650 }
1651 }
1652
1653 @Test
1654 @IR(failOn = {IRNode.STORE_VECTOR})
1655 private static void testCMoveUIGTforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1656 for (int i = 0; i < a.length; i++) {
1657 long cc = c[i];
1658 long dd = d[i];
1659 r2[i] = cc + dd;
1660 r[i] = Integer.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1661 }
1662 }
1663
1664 @Test
1665 @IR(failOn = {IRNode.STORE_VECTOR})
1666 private static void testCMoveUIGEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1667 for (int i = 0; i < a.length; i++) {
1668 long cc = c[i];
1669 long dd = d[i];
1670 r2[i] = cc + dd;
1671 r[i] = Integer.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1672 }
1673 }
1674
1675 @Test
1676 @IR(failOn = {IRNode.STORE_VECTOR})
1677 private static void testCMoveUILTforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1678 for (int i = 0; i < a.length; i++) {
1679 long cc = c[i];
1680 long dd = d[i];
1681 r2[i] = cc + dd;
1682 r[i] = Integer.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1683 }
1684 }
1685
1686 @Test
1687 @IR(failOn = {IRNode.STORE_VECTOR})
1688 private static void testCMoveUILEforL(int[] a, int[] b, long[] c, long[] d, long[] r, long[] r2) {
1689 for (int i = 0; i < a.length; i++) {
1690 long cc = c[i];
1691 long dd = d[i];
1692 r2[i] = cc + dd;
1693 r[i] = Integer.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1694 }
1695 }
1696
1697 // I fo F
1698 @Test
1699 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1700 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1701 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1702 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1703 IRNode.STORE_VECTOR, ">0"},
1704 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1705 private static void testCMoveUIEQforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1706 for (int i = 0; i < a.length; i++) {
1707 float cc = c[i];
1708 float dd = d[i];
1709 r2[i] = cc + dd;
1710 r[i] = Integer.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1711 }
1712 }
1713
1714 @Test
1715 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1716 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1717 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1718 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1719 IRNode.STORE_VECTOR, ">0"},
1720 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1721 private static void testCMoveUINEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1722 for (int i = 0; i < a.length; i++) {
1723 float cc = c[i];
1724 float dd = d[i];
1725 r2[i] = cc + dd;
1726 r[i] = Integer.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1727 }
1728 }
1729
1730 @Test
1731 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1732 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1733 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1734 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1735 IRNode.STORE_VECTOR, ">0"},
1736 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1737 private static void testCMoveUIGTforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1738 for (int i = 0; i < a.length; i++) {
1739 float cc = c[i];
1740 float dd = d[i];
1741 r2[i] = cc + dd;
1742 r[i] = Integer.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1743 }
1744 }
1745
1746 @Test
1747 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1748 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1749 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1750 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1751 IRNode.STORE_VECTOR, ">0"},
1752 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1753 private static void testCMoveUIGEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1754 for (int i = 0; i < a.length; i++) {
1755 float cc = c[i];
1756 float dd = d[i];
1757 r2[i] = cc + dd;
1758 r[i] = Integer.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1759 }
1760 }
1761
1762 @Test
1763 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1764 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1765 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1766 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1767 IRNode.STORE_VECTOR, ">0"},
1768 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1769 private static void testCMoveUILTforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1770 for (int i = 0; i < a.length; i++) {
1771 float cc = c[i];
1772 float dd = d[i];
1773 r2[i] = cc + dd;
1774 r[i] = Integer.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1775 }
1776 }
1777
1778 @Test
1779 @IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1780 IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1781 IRNode.VECTOR_MASK_CMP_I, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1782 IRNode.VECTOR_BLEND_F, IRNode.VECTOR_SIZE + "min(max_int, max_float)", ">0",
1783 IRNode.STORE_VECTOR, ">0"},
1784 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
1785 private static void testCMoveUILEforF(int[] a, int[] b, float[] c, float[] d, float[] r, float[] r2) {
1786 for (int i = 0; i < a.length; i++) {
1787 float cc = c[i];
1788 float dd = d[i];
1789 r2[i] = cc + dd;
1790 r[i] = Integer.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1791 }
1792 }
1793
1794 // I fo D
1795 @Test
1796 @IR(failOn = {IRNode.STORE_VECTOR})
1797 private static void testCMoveUIEQforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1798 for (int i = 0; i < a.length; i++) {
1799 double cc = c[i];
1800 double dd = d[i];
1801 r2[i] = cc + dd;
1802 r[i] = Integer.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1803 }
1804 }
1805
1806 @Test
1807 @IR(failOn = {IRNode.STORE_VECTOR})
1808 private static void testCMoveUINEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1809 for (int i = 0; i < a.length; i++) {
1810 double cc = c[i];
1811 double dd = d[i];
1812 r2[i] = cc + dd;
1813 r[i] = Integer.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1814 }
1815 }
1816
1817 @Test
1818 @IR(failOn = {IRNode.STORE_VECTOR})
1819 private static void testCMoveUIGTforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1820 for (int i = 0; i < a.length; i++) {
1821 double cc = c[i];
1822 double dd = d[i];
1823 r2[i] = cc + dd;
1824 r[i] = Integer.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1825 }
1826 }
1827
1828 @Test
1829 @IR(failOn = {IRNode.STORE_VECTOR})
1830 private static void testCMoveUIGEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1831 for (int i = 0; i < a.length; i++) {
1832 double cc = c[i];
1833 double dd = d[i];
1834 r2[i] = cc + dd;
1835 r[i] = Integer.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1836 }
1837 }
1838
1839 @Test
1840 @IR(failOn = {IRNode.STORE_VECTOR})
1841 private static void testCMoveUILTforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1842 for (int i = 0; i < a.length; i++) {
1843 double cc = c[i];
1844 double dd = d[i];
1845 r2[i] = cc + dd;
1846 r[i] = Integer.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1847 }
1848 }
1849
1850 @Test
1851 @IR(failOn = {IRNode.STORE_VECTOR})
1852 private static void testCMoveUILEforD(int[] a, int[] b, double[] c, double[] d, double[] r, double[] r2) {
1853 for (int i = 0; i < a.length; i++) {
1854 double cc = c[i];
1855 double dd = d[i];
1856 r2[i] = cc + dd;
1857 r[i] = Integer.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1858 }
1859 }
1860
1861 // L fo I
1862 @Test
1863 @IR(failOn = {IRNode.STORE_VECTOR})
1864 private static void testCMoveULEQforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1865 for (int i = 0; i < a.length; i++) {
1866 int cc = c[i];
1867 int dd = d[i];
1868 r2[i] = cc + dd;
1869 r[i] = Long.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1870 }
1871 }
1872
1873 @Test
1874 @IR(failOn = {IRNode.STORE_VECTOR})
1875 private static void testCMoveULNEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1876 for (int i = 0; i < a.length; i++) {
1877 int cc = c[i];
1878 int dd = d[i];
1879 r2[i] = cc + dd;
1880 r[i] = Long.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1881 }
1882 }
1883
1884 @Test
1885 @IR(failOn = {IRNode.STORE_VECTOR})
1886 private static void testCMoveULGTforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1887 for (int i = 0; i < a.length; i++) {
1888 int cc = c[i];
1889 int dd = d[i];
1890 r2[i] = cc + dd;
1891 r[i] = Long.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1892 }
1893 }
1894
1895 @Test
1896 @IR(failOn = {IRNode.STORE_VECTOR})
1897 private static void testCMoveULGEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1898 for (int i = 0; i < a.length; i++) {
1899 int cc = c[i];
1900 int dd = d[i];
1901 r2[i] = cc + dd;
1902 r[i] = Long.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1903 }
1904 }
1905
1906 @Test
1907 @IR(failOn = {IRNode.STORE_VECTOR})
1908 private static void testCMoveULLTforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1909 for (int i = 0; i < a.length; i++) {
1910 int cc = c[i];
1911 int dd = d[i];
1912 r2[i] = cc + dd;
1913 r[i] = Long.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1914 }
1915 }
1916
1917 @Test
1918 @IR(failOn = {IRNode.STORE_VECTOR})
1919 private static void testCMoveULLEforI(long[] a, long[] b, int[] c, int[] d, int[] r, int[] r2) {
1920 for (int i = 0; i < a.length; i++) {
1921 int cc = c[i];
1922 int dd = d[i];
1923 r2[i] = cc + dd;
1924 r[i] = Long.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1925 }
1926 }
1927
1928 // L fo L
1929 @Test
1930 @IR(failOn = {IRNode.STORE_VECTOR})
1931 private static void testCMoveULEQforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1932 for (int i = 0; i < a.length; i++) {
1933 long cc = c[i];
1934 long dd = d[i];
1935 r2[i] = cc + dd;
1936 r[i] = Long.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
1937 }
1938 }
1939
1940 @Test
1941 @IR(failOn = {IRNode.STORE_VECTOR})
1942 private static void testCMoveULNEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1943 for (int i = 0; i < a.length; i++) {
1944 long cc = c[i];
1945 long dd = d[i];
1946 r2[i] = cc + dd;
1947 r[i] = Long.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
1948 }
1949 }
1950
1951 @Test
1952 @IR(failOn = {IRNode.STORE_VECTOR})
1953 private static void testCMoveULGTforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1954 for (int i = 0; i < a.length; i++) {
1955 long cc = c[i];
1956 long dd = d[i];
1957 r2[i] = cc + dd;
1958 r[i] = Long.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
1959 }
1960 }
1961
1962 @Test
1963 @IR(failOn = {IRNode.STORE_VECTOR})
1964 private static void testCMoveULGEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1965 for (int i = 0; i < a.length; i++) {
1966 long cc = c[i];
1967 long dd = d[i];
1968 r2[i] = cc + dd;
1969 r[i] = Long.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
1970 }
1971 }
1972
1973 @Test
1974 @IR(failOn = {IRNode.STORE_VECTOR})
1975 private static void testCMoveULLTforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1976 for (int i = 0; i < a.length; i++) {
1977 long cc = c[i];
1978 long dd = d[i];
1979 r2[i] = cc + dd;
1980 r[i] = Long.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
1981 }
1982 }
1983
1984 @Test
1985 @IR(failOn = {IRNode.STORE_VECTOR})
1986 private static void testCMoveULLEforL(long[] a, long[] b, long[] c, long[] d, long[] r, long[] r2) {
1987 for (int i = 0; i < a.length; i++) {
1988 long cc = c[i];
1989 long dd = d[i];
1990 r2[i] = cc + dd;
1991 r[i] = Long.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
1992 }
1993 }
1994
1995 // L fo F
1996 @Test
1997 @IR(failOn = {IRNode.STORE_VECTOR})
1998 private static void testCMoveULEQforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
1999 for (int i = 0; i < a.length; i++) {
2000 float cc = c[i];
2001 float dd = d[i];
2002 r2[i] = cc + dd;
2003 r[i] = Long.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
2004 }
2005 }
2006
2007 @Test
2008 @IR(failOn = {IRNode.STORE_VECTOR})
2009 private static void testCMoveULNEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
2010 for (int i = 0; i < a.length; i++) {
2011 float cc = c[i];
2012 float dd = d[i];
2013 r2[i] = cc + dd;
2014 r[i] = Long.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
2015 }
2016 }
2017
2018 @Test
2019 @IR(failOn = {IRNode.STORE_VECTOR})
2020 private static void testCMoveULGTforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
2021 for (int i = 0; i < a.length; i++) {
2022 float cc = c[i];
2023 float dd = d[i];
2024 r2[i] = cc + dd;
2025 r[i] = Long.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
2026 }
2027 }
2028
2029 @Test
2030 @IR(failOn = {IRNode.STORE_VECTOR})
2031 private static void testCMoveULGEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
2032 for (int i = 0; i < a.length; i++) {
2033 float cc = c[i];
2034 float dd = d[i];
2035 r2[i] = cc + dd;
2036 r[i] = Long.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
2037 }
2038 }
2039
2040 @Test
2041 @IR(failOn = {IRNode.STORE_VECTOR})
2042 private static void testCMoveULLTforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
2043 for (int i = 0; i < a.length; i++) {
2044 float cc = c[i];
2045 float dd = d[i];
2046 r2[i] = cc + dd;
2047 r[i] = Long.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
2048 }
2049 }
2050
2051 @Test
2052 @IR(failOn = {IRNode.STORE_VECTOR})
2053 private static void testCMoveULLEforF(long[] a, long[] b, float[] c, float[] d, float[] r, float[] r2) {
2054 for (int i = 0; i < a.length; i++) {
2055 float cc = c[i];
2056 float dd = d[i];
2057 r2[i] = cc + dd;
2058 r[i] = Long.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
2059 }
2060 }
2061
2062 // L fo D
2063 @Test
2064 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2065 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2066 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2067 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2068 IRNode.STORE_VECTOR, ">0"},
2069 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2070 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2071 private static void testCMoveULEQforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2072 for (int i = 0; i < a.length; i++) {
2073 double cc = c[i];
2074 double dd = d[i];
2075 r2[i] = cc + dd;
2076 r[i] = Long.compareUnsigned(a[i], b[i]) == 0 ? cc : dd;
2077 }
2078 }
2079
2080 @Test
2081 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2082 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2083 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2084 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2085 IRNode.STORE_VECTOR, ">0"},
2086 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2087 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2088 private static void testCMoveULNEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2089 for (int i = 0; i < a.length; i++) {
2090 double cc = c[i];
2091 double dd = d[i];
2092 r2[i] = cc + dd;
2093 r[i] = Long.compareUnsigned(a[i], b[i]) != 0 ? cc : dd;
2094 }
2095 }
2096
2097 @Test
2098 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2099 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2100 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2101 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2102 IRNode.STORE_VECTOR, ">0"},
2103 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2104 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2105 private static void testCMoveULGTforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2106 for (int i = 0; i < a.length; i++) {
2107 double cc = c[i];
2108 double dd = d[i];
2109 r2[i] = cc + dd;
2110 r[i] = Long.compareUnsigned(a[i], b[i]) > 0 ? cc : dd;
2111 }
2112 }
2113
2114 @Test
2115 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2116 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2117 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2118 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2119 IRNode.STORE_VECTOR, ">0"},
2120 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2121 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2122 private static void testCMoveULGEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2123 for (int i = 0; i < a.length; i++) {
2124 double cc = c[i];
2125 double dd = d[i];
2126 r2[i] = cc + dd;
2127 r[i] = Long.compareUnsigned(a[i], b[i]) >= 0 ? cc : dd;
2128 }
2129 }
2130
2131 @Test
2132 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2133 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2134 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2135 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2136 IRNode.STORE_VECTOR, ">0"},
2137 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2138 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2139 private static void testCMoveULLTforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2140 for (int i = 0; i < a.length; i++) {
2141 double cc = c[i];
2142 double dd = d[i];
2143 r2[i] = cc + dd;
2144 r[i] = Long.compareUnsigned(a[i], b[i]) < 0 ? cc : dd;
2145 }
2146 }
2147
2148 @Test
2149 @IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2150 IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2151 IRNode.VECTOR_MASK_CMP_L, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2152 IRNode.VECTOR_BLEND_D, IRNode.VECTOR_SIZE + "min(max_long, max_double)", ">0",
2153 IRNode.STORE_VECTOR, ">0"},
2154 applyIfCPUFeatureOr = {"avx2", "true", "asimd", "true"})
2155 // Requires avx2, else L is restricted to 16 byte, and D has 32. That leads to a vector elements mismatch of 2 to 4.
2156 private static void testCMoveULLEforD(long[] a, long[] b, double[] c, double[] d, double[] r, double[] r2) {
2157 for (int i = 0; i < a.length; i++) {
2158 double cc = c[i];
2159 double dd = d[i];
2160 r2[i] = cc + dd;
2161 r[i] = Long.compareUnsigned(a[i], b[i]) <= 0 ? cc : dd;
2162 }
2163 }
2164
2165 @Test
2166 @IR(failOn = {IRNode.STORE_VECTOR})
2167 private static void testCMoveFGTforI(float[] a, float[] b, int[] c, int[] d, int[] r, int[] r2) {
2168 for (int i = 0; i < a.length; i++) {
2169 int cc = c[i];
2170 int dd = d[i];
2171 r2[i] = cc + dd;
2172 r[i] = (a[i] > b[i]) ? cc : dd;
2173 }
2174 }
2175
2176 @Test
2177 @IR(failOn = {IRNode.STORE_VECTOR})
2178 private static void testCMoveFGTforL(float[] a, float[] b, long[] c, long[] d, long[] r, long[] r2) {
2179 for (int i = 0; i < a.length; i++) {
2180 long cc = c[i];
2181 long dd = d[i];
2182 r2[i] = cc + dd;
2183 r[i] = (a[i] > b[i]) ? cc : dd;
2184 }
2185 }
2186
2187 @Test
2188 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
2189 IRNode.VECTOR_MASK_CMP_F, ">0",
2190 IRNode.VECTOR_BLEND_F, ">0",
2191 IRNode.STORE_VECTOR, ">0"},
2192 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
2193 private static void testCMoveFGTforF(float[] a, float[] b, float[] c, float[] d, float[] r, float[] r2) {
2194 for (int i = 0; i < a.length; i++) {
2195 float cc = c[i];
2196 float dd = d[i];
2197 r2[i] = cc + dd;
2198 r[i] = (a[i] > b[i]) ? cc : dd;
2199 }
2200 }
2201
2202 @Test
2203 @IR(failOn = {IRNode.STORE_VECTOR})
2204 private static void testCMoveFGTforD(float[] a, float[] b, double[] c, double[] d, double[] r, double[] r2) {
2205 for (int i = 0; i < a.length; i++) {
2206 double cc = c[i];
2207 double dd = d[i];
2208 r2[i] = cc + dd;
2209 r[i] = (a[i] > b[i]) ? cc : dd;
2210 }
2211 }
2212
2213 @Test
2214 @IR(failOn = {IRNode.STORE_VECTOR})
2215 private static void testCMoveDGTforI(double[] a, double[] b, int[] c, int[] d, int[] r, int[] r2) {
2216 for (int i = 0; i < a.length; i++) {
2217 int cc = c[i];
2218 int dd = d[i];
2219 r2[i] = cc + dd;
2220 r[i] = (a[i] > b[i]) ? cc : dd;
2221 }
2222 }
2223
2224 @Test
2225 @IR(failOn = {IRNode.STORE_VECTOR})
2226 private static void testCMoveDGTforL(double[] a, double[] b, long[] c, long[] d, long[] r, long[] r2) {
2227 for (int i = 0; i < a.length; i++) {
2228 long cc = c[i];
2229 long dd = d[i];
2230 r2[i] = cc + dd;
2231 r[i] = (a[i] > b[i]) ? cc : dd;
2232 }
2233 }
2234
2235 @Test
2236 @IR(failOn = {IRNode.STORE_VECTOR})
2237 private static void testCMoveDGTforF(double[] a, double[] b, float[] c, float[] d, float[] r, float[] r2) {
2238 for (int i = 0; i < a.length; i++) {
2239 float cc = c[i];
2240 float dd = d[i];
2241 r2[i] = cc + dd;
2242 r[i] = (a[i] > b[i]) ? cc : dd;
2243 }
2244 }
2245
2246 @Test
2247 @IR(counts = {IRNode.LOAD_VECTOR_D, ">0",
2248 IRNode.VECTOR_MASK_CMP_D, ">0",
2249 IRNode.VECTOR_BLEND_D, ">0",
2250 IRNode.STORE_VECTOR, ">0"},
2251 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
2252 private static void testCMoveDGTforD(double[] a, double[] b, double[] c, double[] d, double[] r, double[] r2) {
2253 for (int i = 0; i < a.length; i++) {
2254 double cc = c[i];
2255 double dd = d[i];
2256 r2[i] = cc + dd;
2257 r[i] = (a[i] > b[i]) ? cc : dd;
2258 }
2259 }
2260
2261 // Use some constants in the comparison
2262 @Test
2263 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
2264 IRNode.VECTOR_MASK_CMP_F, ">0",
2265 IRNode.VECTOR_BLEND_F, ">0",
2266 IRNode.STORE_VECTOR, ">0"},
2267 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
2268 private static void testCMoveFGTforFCmpCon1(float a, float[] b, float[] c, float[] d, float[] r, float[] r2) {
2269 for (int i = 0; i < b.length; i++) {
2270 float cc = c[i];
2271 float dd = d[i];
2272 r2[i] = cc + dd;
2273 r[i] = (a > b[i]) ? cc : dd;
2274 }
2275 }
2276
2277 @Test
2278 @IR(counts = {IRNode.LOAD_VECTOR_F, ">0",
2279 IRNode.VECTOR_MASK_CMP_F, ">0",
2280 IRNode.VECTOR_BLEND_F, ">0",
2281 IRNode.STORE_VECTOR, ">0"},
2282 applyIfCPUFeatureOr = {"avx", "true", "asimd", "true"})
2283 private static void testCMoveFGTforFCmpCon2(float[] a, float b, float[] c, float[] d, float[] r, float[] r2) {
2284 for (int i = 0; i < a.length; i++) {
2285 float cc = c[i];
2286 float dd = d[i];
2287 r2[i] = cc + dd;
2288 r[i] = (a[i] > b) ? cc : dd;
2289 }
2290 }
2291
2292 // A case that is currently not supported and is not expected to vectorize
2293 @Test
2294 @IR(failOn = {IRNode.STORE_VECTOR})
2295 private static void testCMoveVDUnsupported() {
2296 double[] doublec = new double[SIZE];
2297 int seed = 1001;
2298 for (int i = 0; i < doublec.length; i++) {
2299 doublec[i] = (i % 2 == 0) ? seed + i : seed - i;
2300 }
2301 }
2302
2303 @Warmup(0)
2304 @Run(test = {"testCMoveVFGT", "testCMoveVFLT","testCMoveVDLE", "testCMoveVDGE", "testCMoveVFEQ", "testCMoveVDNE",
2305 "testCMoveVFGTSwap", "testCMoveVFLTSwap","testCMoveVDLESwap", "testCMoveVDGESwap",
2306 "testCMoveFGTforFConst", "testCMoveFGEforFConst", "testCMoveFLTforFConst",
2307 "testCMoveFLEforFConst", "testCMoveFEQforFConst", "testCMoveFNEQforFConst",
2308 "testCMoveDGTforDConst", "testCMoveDGEforDConst", "testCMoveDLTforDConst",
2309 "testCMoveDLEforDConst", "testCMoveDEQforDConst", "testCMoveDNEQforDConst",
2310 "testCMoveFLTforFConstH2", "testCMoveFLEforFConstH2",
2311 "testCMoveFYYforFConstH2", "testCMoveFXXforFConstH2",
2312 "testCMoveDLTforDConstH2", "testCMoveDLEforDConstH2",
2313 "testCMoveDYYforDConstH2", "testCMoveDXXforDConstH2"})
2314 private void testCMove_runner() {
2315 float[] floata = new float[SIZE];
2316 float[] floatb = new float[SIZE];
2317 float[] floatc = new float[SIZE];
2318 double[] doublea = new double[SIZE];
2319 double[] doubleb = new double[SIZE];
2320 double[] doublec = new double[SIZE];
2321
2322 init(floata);
2323 init(floatb);
2324 init(doublea);
2325 init(doubleb);
2326
2327 testCMoveVFGT(floata, floatb, floatc);
2328 testCMoveVDLE(doublea, doubleb, doublec);
2329 for (int i = 0; i < SIZE; i++) {
2330 Asserts.assertEquals(floatc[i], cmoveFloatGT(floata[i], floatb[i]));
2331 Asserts.assertEquals(doublec[i], cmoveDoubleLE(doublea[i], doubleb[i]));
2332 }
2333
2334 testCMoveVFLT(floata, floatb, floatc);
2335 testCMoveVDGE(doublea, doubleb, doublec);
2336 for (int i = 0; i < SIZE; i++) {
2337 Asserts.assertEquals(floatc[i], cmoveFloatLT(floata[i], floatb[i]));
2338 Asserts.assertEquals(doublec[i], cmoveDoubleGE(doublea[i], doubleb[i]));
2339 }
2340
2341 // Ensure we frequently have equals
2342 for (int i = 0; i < SIZE; i++) {
2343 if (i % 3 == 0) {
2344 floatb[i] = floata[i];
2345 doubleb[i] = doublea[i];
2346 }
2347 }
2348
2349 testCMoveVFEQ(floata, floatb, floatc);
2350 testCMoveVDNE(doublea, doubleb, doublec);
2351 for (int i = 0; i < SIZE; i++) {
2352 Asserts.assertEquals(floatc[i], cmoveFloatEQ(floata[i], floatb[i]));
2353 Asserts.assertEquals(doublec[i], cmoveDoubleNE(doublea[i], doubleb[i]));
2354 }
2355
2356 testCMoveVFGTSwap(floata, floatb, floatc);
2357 testCMoveVDLESwap(doublea, doubleb, doublec);
2358 for (int i = 0; i < SIZE; i++) {
2359 Asserts.assertEquals(floatc[i], cmoveFloatGTSwap(floata[i], floatb[i]));
2360 Asserts.assertEquals(doublec[i], cmoveDoubleLESwap(doublea[i], doubleb[i]));
2361 }
2362
2363 testCMoveVFLTSwap(floata, floatb, floatc);
2364 testCMoveVDGESwap(doublea, doubleb, doublec);
2365 for (int i = 0; i < SIZE; i++) {
2366 Asserts.assertEquals(floatc[i], cmoveFloatLTSwap(floata[i], floatb[i]));
2367 Asserts.assertEquals(doublec[i], cmoveDoubleGESwap(doublea[i], doubleb[i]));
2368 }
2369
2370 // Extensions: compare 2 values, and pick from 2 consts
2371 testCMoveFGTforFConst(floata, floatb, floatc);
2372 testCMoveDGTforDConst(doublea, doubleb, doublec);
2373 for (int i = 0; i < SIZE; i++) {
2374 Asserts.assertEquals(floatc[i], cmoveFGTforFConst(floata[i], floatb[i]));
2375 Asserts.assertEquals(doublec[i], cmoveDGTforDConst(doublea[i], doubleb[i]));
2376 }
2377
2378 testCMoveFGEforFConst(floata, floatb, floatc);
2379 testCMoveDGEforDConst(doublea, doubleb, doublec);
2380 for (int i = 0; i < SIZE; i++) {
2381 Asserts.assertEquals(floatc[i], cmoveFGEforFConst(floata[i], floatb[i]));
2382 Asserts.assertEquals(doublec[i], cmoveDGEforDConst(doublea[i], doubleb[i]));
2383 }
2384
2385 testCMoveFLTforFConst(floata, floatb, floatc);
2386 testCMoveDLTforDConst(doublea, doubleb, doublec);
2387 for (int i = 0; i < SIZE; i++) {
2388 Asserts.assertEquals(floatc[i], cmoveFLTforFConst(floata[i], floatb[i]));
2389 Asserts.assertEquals(doublec[i], cmoveDLTforDConst(doublea[i], doubleb[i]));
2390 }
2391
2392 testCMoveFLEforFConst(floata, floatb, floatc);
2393 testCMoveDLEforDConst(doublea, doubleb, doublec);
2394 for (int i = 0; i < SIZE; i++) {
2395 Asserts.assertEquals(floatc[i], cmoveFLEforFConst(floata[i], floatb[i]));
2396 Asserts.assertEquals(doublec[i], cmoveDLEforDConst(doublea[i], doubleb[i]));
2397 }
2398
2399 testCMoveFEQforFConst(floata, floatb, floatc);
2400 testCMoveDEQforDConst(doublea, doubleb, doublec);
2401 for (int i = 0; i < SIZE; i++) {
2402 Asserts.assertEquals(floatc[i], cmoveFEQforFConst(floata[i], floatb[i]));
2403 Asserts.assertEquals(doublec[i], cmoveDEQforDConst(doublea[i], doubleb[i]));
2404 }
2405
2406 testCMoveFNEQforFConst(floata, floatb, floatc);
2407 testCMoveDNEQforDConst(doublea, doubleb, doublec);
2408 for (int i = 0; i < SIZE; i++) {
2409 Asserts.assertEquals(floatc[i], cmoveFNEQforFConst(floata[i], floatb[i]));
2410 Asserts.assertEquals(doublec[i], cmoveDNEQforDConst(doublea[i], doubleb[i]));
2411 }
2412
2413 // Hand-unrolled (H2) examples:
2414 testCMoveFLTforFConstH2(floata, floatb, floatc);
2415 testCMoveDLTforDConstH2(doublea, doubleb, doublec);
2416 for (int i = 0; i < SIZE; i++) {
2417 Asserts.assertEquals(floatc[i], cmoveFLTforFConst(floata[i], floatb[i]));
2418 Asserts.assertEquals(doublec[i], cmoveDLTforDConst(doublea[i], doubleb[i]));
2419 }
2420
2421 testCMoveFLEforFConstH2(floata, floatb, floatc);
2422 testCMoveDLEforDConstH2(doublea, doubleb, doublec);
2423 for (int i = 0; i < SIZE; i++) {
2424 Asserts.assertEquals(floatc[i], cmoveFLEforFConst(floata[i], floatb[i]));
2425 Asserts.assertEquals(doublec[i], cmoveDLEforDConst(doublea[i], doubleb[i]));
2426 }
2427
2428 testCMoveFYYforFConstH2(floata, floatb, floatc);
2429 testCMoveDYYforDConstH2(doublea, doubleb, doublec);
2430 for (int i = 0; i < SIZE; i+=2) {
2431 Asserts.assertEquals(floatc[i+0], cmoveFLEforFConst(floata[i+0], floatb[i+0]));
2432 Asserts.assertEquals(doublec[i+0], cmoveDLEforDConst(doublea[i+0], doubleb[i+0]));
2433 Asserts.assertEquals(floatc[i+1], cmoveFLTforFConst(floata[i+1], floatb[i+1]));
2434 Asserts.assertEquals(doublec[i+1], cmoveDLTforDConst(doublea[i+1], doubleb[i+1]));
2435 }
2436
2437 testCMoveFXXforFConstH2(floata, floatb, floatc);
2438 testCMoveDXXforDConstH2(doublea, doubleb, doublec);
2439 for (int i = 0; i < SIZE; i+=2) {
2440 Asserts.assertEquals(floatc[i+0], cmoveFLTforFConst(floata[i+0], floatb[i+0]));
2441 Asserts.assertEquals(doublec[i+0], cmoveDLTforDConst(doublea[i+0], doubleb[i+0]));
2442 Asserts.assertEquals(floatc[i+1], cmoveFLEforFConst(floata[i+1], floatb[i+1]));
2443 Asserts.assertEquals(doublec[i+1], cmoveDLEforDConst(doublea[i+1], doubleb[i+1]));
2444 }
2445 }
2446
2447 @Warmup(0)
2448 @Run(test = {// Signed
2449 // I for I
2450 "testCMoveIEQforI",
2451 "testCMoveINEforI",
2452 "testCMoveIGTforI",
2453 "testCMoveIGEforI",
2454 "testCMoveILTforI",
2455 "testCMoveILEforI",
2456 // I for L
2457 "testCMoveIEQforL",
2458 "testCMoveINEforL",
2459 "testCMoveIGTforL",
2460 "testCMoveIGEforL",
2461 "testCMoveILTforL",
2462 "testCMoveILEforL",
2463 // I for F
2464 "testCMoveIEQforF",
2465 "testCMoveINEforF",
2466 "testCMoveIGTforF",
2467 "testCMoveIGEforF",
2468 "testCMoveILTforF",
2469 "testCMoveILEforF",
2470 // I for D
2471 "testCMoveIEQforD",
2472 "testCMoveINEforD",
2473 "testCMoveIGTforD",
2474 "testCMoveIGEforD",
2475 "testCMoveILTforD",
2476 "testCMoveILEforD",
2477 // L for I
2478 "testCMoveLEQforI",
2479 "testCMoveLNEforI",
2480 "testCMoveLGTforI",
2481 "testCMoveLGEforI",
2482 "testCMoveLLTforI",
2483 "testCMoveLLEforI",
2484 // L for L
2485 "testCMoveLEQforL",
2486 "testCMoveLNEforL",
2487 "testCMoveLGTforL",
2488 "testCMoveLGEforL",
2489 "testCMoveLLTforL",
2490 "testCMoveLLEforL",
2491 // L for F
2492 "testCMoveLEQforF",
2493 "testCMoveLNEforF",
2494 "testCMoveLGTforF",
2495 "testCMoveLGEforF",
2496 "testCMoveLLTforF",
2497 "testCMoveLLEforF",
2498 // L for D
2499 "testCMoveLEQforD",
2500 "testCMoveLNEforD",
2501 "testCMoveLGTforD",
2502 "testCMoveLGEforD",
2503 "testCMoveLLTforD",
2504 "testCMoveLLEforD",
2505 // Unsigned
2506 // I for I
2507 "testCMoveUIEQforI",
2508 "testCMoveUINEforI",
2509 "testCMoveUIGTforI",
2510 "testCMoveUIGEforI",
2511 "testCMoveUILTforI",
2512 "testCMoveUILEforI",
2513 // I for L
2514 "testCMoveUIEQforL",
2515 "testCMoveUINEforL",
2516 "testCMoveUIGTforL",
2517 "testCMoveUIGEforL",
2518 "testCMoveUILTforL",
2519 "testCMoveUILEforL",
2520 // I for F
2521 "testCMoveUIEQforF",
2522 "testCMoveUINEforF",
2523 "testCMoveUIGTforF",
2524 "testCMoveUIGEforF",
2525 "testCMoveUILTforF",
2526 "testCMoveUILEforF",
2527 // I for D
2528 "testCMoveUIEQforD",
2529 "testCMoveUINEforD",
2530 "testCMoveUIGTforD",
2531 "testCMoveUIGEforD",
2532 "testCMoveUILTforD",
2533 "testCMoveUILEforD",
2534 // L for I
2535 "testCMoveULEQforI",
2536 "testCMoveULNEforI",
2537 "testCMoveULGTforI",
2538 "testCMoveULGEforI",
2539 "testCMoveULLTforI",
2540 "testCMoveULLEforI",
2541 // L for L
2542 "testCMoveULEQforL",
2543 "testCMoveULNEforL",
2544 "testCMoveULGTforL",
2545 "testCMoveULGEforL",
2546 "testCMoveULLTforL",
2547 "testCMoveULLEforL",
2548 // L for F
2549 "testCMoveULEQforF",
2550 "testCMoveULNEforF",
2551 "testCMoveULGTforF",
2552 "testCMoveULGEforF",
2553 "testCMoveULLTforF",
2554 "testCMoveULLEforF",
2555 // L for D
2556 "testCMoveULEQforD",
2557 "testCMoveULNEforD",
2558 "testCMoveULGTforD",
2559 "testCMoveULGEforD",
2560 "testCMoveULLTforD",
2561 "testCMoveULLEforD",
2562 // Float
2563 "testCMoveFGTforI",
2564 "testCMoveFGTforL",
2565 "testCMoveFGTforF",
2566 "testCMoveFGTforD",
2567 "testCMoveDGTforI",
2568 "testCMoveDGTforL",
2569 "testCMoveDGTforF",
2570 "testCMoveDGTforD",
2571 "testCMoveFGTforFCmpCon1",
2572 "testCMoveFGTforFCmpCon2"})
2573 private void testCMove_runner_two() {
2574 int[] aI = new int[SIZE];
2575 int[] bI = new int[SIZE];
2576 int[] cI = new int[SIZE];
2577 int[] dI = new int[SIZE];
2578 int[] rI = new int[SIZE];
2579 long[] aL = new long[SIZE];
2580 long[] bL = new long[SIZE];
2581 long[] cL = new long[SIZE];
2582 long[] dL = new long[SIZE];
2583 long[] rL = new long[SIZE];
2584 float[] aF = new float[SIZE];
2585 float[] bF = new float[SIZE];
2586 float[] cF = new float[SIZE];
2587 float[] dF = new float[SIZE];
2588 float[] rF = new float[SIZE];
2589 double[] aD = new double[SIZE];
2590 double[] bD = new double[SIZE];
2591 double[] cD = new double[SIZE];
2592 double[] dD = new double[SIZE];
2593 double[] rD = new double[SIZE];
2594
2595 init(aI);
2596 init(bI);
2597 init(cI);
2598 init(dI);
2599 init(aL);
2600 init(bL);
2601 init(cL);
2602 init(dL);
2603 init(aF);
2604 init(bF);
2605 init(cF);
2606 init(dF);
2607 init(aD);
2608 init(bD);
2609 init(cD);
2610 init(dD);
2611
2612 // Signed
2613 // I for I
2614 testCMoveIEQforI(aI, bI, cI, dI, rI, rI);
2615 for (int i = 0; i < SIZE; i++) {
2616 Asserts.assertEquals(rI[i], cmoveIEQforI(aI[i], bI[i], cI[i], dI[i]));
2617 }
2618
2619 testCMoveINEforI(aI, bI, cI, dI, rI, rI);
2620 for (int i = 0; i < SIZE; i++) {
2621 Asserts.assertEquals(rI[i], cmoveINEforI(aI[i], bI[i], cI[i], dI[i]));
2622 }
2623
2624 testCMoveIGTforI(aI, bI, cI, dI, rI, rI);
2625 for (int i = 0; i < SIZE; i++) {
2626 Asserts.assertEquals(rI[i], cmoveIGTforI(aI[i], bI[i], cI[i], dI[i]));
2627 }
2628
2629 testCMoveIGEforI(aI, bI, cI, dI, rI, rI);
2630 for (int i = 0; i < SIZE; i++) {
2631 Asserts.assertEquals(rI[i], cmoveIGEforI(aI[i], bI[i], cI[i], dI[i]));
2632 }
2633
2634 testCMoveILTforI(aI, bI, cI, dI, rI, rI);
2635 for (int i = 0; i < SIZE; i++) {
2636 Asserts.assertEquals(rI[i], cmoveILTforI(aI[i], bI[i], cI[i], dI[i]));
2637 }
2638
2639 testCMoveILEforI(aI, bI, cI, dI, rI, rI);
2640 for (int i = 0; i < SIZE; i++) {
2641 Asserts.assertEquals(rI[i], cmoveILEforI(aI[i], bI[i], cI[i], dI[i]));
2642 }
2643
2644 // I for L
2645 testCMoveIEQforL(aI, bI, cL, dL, rL, rL);
2646 for (int i = 0; i < SIZE; i++) {
2647 Asserts.assertEquals(rL[i], cmoveIEQforL(aI[i], bI[i], cL[i], dL[i]));
2648 }
2649
2650 testCMoveINEforL(aI, bI, cL, dL, rL, rL);
2651 for (int i = 0; i < SIZE; i++) {
2652 Asserts.assertEquals(rL[i], cmoveINEforL(aI[i], bI[i], cL[i], dL[i]));
2653 }
2654
2655 testCMoveIGTforL(aI, bI, cL, dL, rL, rL);
2656 for (int i = 0; i < SIZE; i++) {
2657 Asserts.assertEquals(rL[i], cmoveIGTforL(aI[i], bI[i], cL[i], dL[i]));
2658 }
2659
2660 testCMoveIGEforL(aI, bI, cL, dL, rL, rL);
2661 for (int i = 0; i < SIZE; i++) {
2662 Asserts.assertEquals(rL[i], cmoveIGEforL(aI[i], bI[i], cL[i], dL[i]));
2663 }
2664
2665 testCMoveILTforL(aI, bI, cL, dL, rL, rL);
2666 for (int i = 0; i < SIZE; i++) {
2667 Asserts.assertEquals(rL[i], cmoveILTforL(aI[i], bI[i], cL[i], dL[i]));
2668 }
2669
2670 testCMoveILEforL(aI, bI, cL, dL, rL, rL);
2671 for (int i = 0; i < SIZE; i++) {
2672 Asserts.assertEquals(rL[i], cmoveILEforL(aI[i], bI[i], cL[i], dL[i]));
2673 }
2674
2675 // I for F
2676 testCMoveIEQforF(aI, bI, cF, dF, rF, rF);
2677 for (int i = 0; i < SIZE; i++) {
2678 Asserts.assertEquals(rF[i], cmoveIEQforF(aI[i], bI[i], cF[i], dF[i]));
2679 }
2680
2681 testCMoveINEforF(aI, bI, cF, dF, rF, rF);
2682 for (int i = 0; i < SIZE; i++) {
2683 Asserts.assertEquals(rF[i], cmoveINEforF(aI[i], bI[i], cF[i], dF[i]));
2684 }
2685
2686 testCMoveIGTforF(aI, bI, cF, dF, rF, rF);
2687 for (int i = 0; i < SIZE; i++) {
2688 Asserts.assertEquals(rF[i], cmoveIGTforF(aI[i], bI[i], cF[i], dF[i]));
2689 }
2690
2691 testCMoveIGEforF(aI, bI, cF, dF, rF, rF);
2692 for (int i = 0; i < SIZE; i++) {
2693 Asserts.assertEquals(rF[i], cmoveIGEforF(aI[i], bI[i], cF[i], dF[i]));
2694 }
2695
2696 testCMoveILTforF(aI, bI, cF, dF, rF, rF);
2697 for (int i = 0; i < SIZE; i++) {
2698 Asserts.assertEquals(rF[i], cmoveILTforF(aI[i], bI[i], cF[i], dF[i]));
2699 }
2700
2701 testCMoveILEforF(aI, bI, cF, dF, rF, rF);
2702 for (int i = 0; i < SIZE; i++) {
2703 Asserts.assertEquals(rF[i], cmoveILEforF(aI[i], bI[i], cF[i], dF[i]));
2704 }
2705
2706 // I for D
2707 testCMoveIEQforD(aI, bI, cD, dD, rD, rD);
2708 for (int i = 0; i < SIZE; i++) {
2709 Asserts.assertEquals(rD[i], cmoveIEQforD(aI[i], bI[i], cD[i], dD[i]));
2710 }
2711
2712 testCMoveINEforD(aI, bI, cD, dD, rD, rD);
2713 for (int i = 0; i < SIZE; i++) {
2714 Asserts.assertEquals(rD[i], cmoveINEforD(aI[i], bI[i], cD[i], dD[i]));
2715 }
2716
2717 testCMoveIGTforD(aI, bI, cD, dD, rD, rD);
2718 for (int i = 0; i < SIZE; i++) {
2719 Asserts.assertEquals(rD[i], cmoveIGTforD(aI[i], bI[i], cD[i], dD[i]));
2720 }
2721
2722 testCMoveIGEforD(aI, bI, cD, dD, rD, rD);
2723 for (int i = 0; i < SIZE; i++) {
2724 Asserts.assertEquals(rD[i], cmoveIGEforD(aI[i], bI[i], cD[i], dD[i]));
2725 }
2726
2727 testCMoveILTforD(aI, bI, cD, dD, rD, rD);
2728 for (int i = 0; i < SIZE; i++) {
2729 Asserts.assertEquals(rD[i], cmoveILTforD(aI[i], bI[i], cD[i], dD[i]));
2730 }
2731
2732 testCMoveILEforD(aI, bI, cD, dD, rD, rD);
2733 for (int i = 0; i < SIZE; i++) {
2734 Asserts.assertEquals(rD[i], cmoveILEforD(aI[i], bI[i], cD[i], dD[i]));
2735 }
2736
2737 // L for I
2738 testCMoveLEQforI(aL, bL, cI, dI, rI, rI);
2739 for (int i = 0; i < SIZE; i++) {
2740 Asserts.assertEquals(rI[i], cmoveLEQforI(aL[i], bL[i], cI[i], dI[i]));
2741 }
2742
2743 testCMoveLNEforI(aL, bL, cI, dI, rI, rI);
2744 for (int i = 0; i < SIZE; i++) {
2745 Asserts.assertEquals(rI[i], cmoveLNEforI(aL[i], bL[i], cI[i], dI[i]));
2746 }
2747
2748 testCMoveLGTforI(aL, bL, cI, dI, rI, rI);
2749 for (int i = 0; i < SIZE; i++) {
2750 Asserts.assertEquals(rI[i], cmoveLGTforI(aL[i], bL[i], cI[i], dI[i]));
2751 }
2752
2753 testCMoveLGEforI(aL, bL, cI, dI, rI, rI);
2754 for (int i = 0; i < SIZE; i++) {
2755 Asserts.assertEquals(rI[i], cmoveLGEforI(aL[i], bL[i], cI[i], dI[i]));
2756 }
2757
2758 testCMoveLLTforI(aL, bL, cI, dI, rI, rI);
2759 for (int i = 0; i < SIZE; i++) {
2760 Asserts.assertEquals(rI[i], cmoveLLTforI(aL[i], bL[i], cI[i], dI[i]));
2761 }
2762
2763 testCMoveLLEforI(aL, bL, cI, dI, rI, rI);
2764 for (int i = 0; i < SIZE; i++) {
2765 Asserts.assertEquals(rI[i], cmoveLLEforI(aL[i], bL[i], cI[i], dI[i]));
2766 }
2767
2768 // L for L
2769 testCMoveLEQforL(aL, bL, cL, dL, rL, rL);
2770 for (int i = 0; i < SIZE; i++) {
2771 Asserts.assertEquals(rL[i], cmoveLEQforL(aL[i], bL[i], cL[i], dL[i]));
2772 }
2773
2774 testCMoveLNEforL(aL, bL, cL, dL, rL, rL);
2775 for (int i = 0; i < SIZE; i++) {
2776 Asserts.assertEquals(rL[i], cmoveLNEforL(aL[i], bL[i], cL[i], dL[i]));
2777 }
2778
2779 testCMoveLGTforL(aL, bL, cL, dL, rL, rL);
2780 for (int i = 0; i < SIZE; i++) {
2781 Asserts.assertEquals(rL[i], cmoveLGTforL(aL[i], bL[i], cL[i], dL[i]));
2782 }
2783
2784 testCMoveLGEforL(aL, bL, cL, dL, rL, rL);
2785 for (int i = 0; i < SIZE; i++) {
2786 Asserts.assertEquals(rL[i], cmoveLGEforL(aL[i], bL[i], cL[i], dL[i]));
2787 }
2788
2789 testCMoveLLTforL(aL, bL, cL, dL, rL, rL);
2790 for (int i = 0; i < SIZE; i++) {
2791 Asserts.assertEquals(rL[i], cmoveLLTforL(aL[i], bL[i], cL[i], dL[i]));
2792 }
2793
2794 testCMoveLLEforL(aL, bL, cL, dL, rL, rL);
2795 for (int i = 0; i < SIZE; i++) {
2796 Asserts.assertEquals(rL[i], cmoveLLEforL(aL[i], bL[i], cL[i], dL[i]));
2797 }
2798
2799 // L for F
2800 testCMoveLEQforF(aL, bL, cF, dF, rF, rF);
2801 for (int i = 0; i < SIZE; i++) {
2802 Asserts.assertEquals(rF[i], cmoveLEQforF(aL[i], bL[i], cF[i], dF[i]));
2803 }
2804
2805 testCMoveLNEforF(aL, bL, cF, dF, rF, rF);
2806 for (int i = 0; i < SIZE; i++) {
2807 Asserts.assertEquals(rF[i], cmoveLNEforF(aL[i], bL[i], cF[i], dF[i]));
2808 }
2809
2810 testCMoveLGTforF(aL, bL, cF, dF, rF, rF);
2811 for (int i = 0; i < SIZE; i++) {
2812 Asserts.assertEquals(rF[i], cmoveLGTforF(aL[i], bL[i], cF[i], dF[i]));
2813 }
2814
2815 testCMoveLGEforF(aL, bL, cF, dF, rF, rF);
2816 for (int i = 0; i < SIZE; i++) {
2817 Asserts.assertEquals(rF[i], cmoveLGEforF(aL[i], bL[i], cF[i], dF[i]));
2818 }
2819
2820 testCMoveLLTforF(aL, bL, cF, dF, rF, rF);
2821 for (int i = 0; i < SIZE; i++) {
2822 Asserts.assertEquals(rF[i], cmoveLLTforF(aL[i], bL[i], cF[i], dF[i]));
2823 }
2824
2825 testCMoveLLEforF(aL, bL, cF, dF, rF, rF);
2826 for (int i = 0; i < SIZE; i++) {
2827 Asserts.assertEquals(rF[i], cmoveLLEforF(aL[i], bL[i], cF[i], dF[i]));
2828 }
2829
2830 // L for D
2831 testCMoveLEQforD(aL, bL, cD, dD, rD, rD);
2832 for (int i = 0; i < SIZE; i++) {
2833 Asserts.assertEquals(rD[i], cmoveLEQforD(aL[i], bL[i], cD[i], dD[i]));
2834 }
2835
2836 testCMoveLNEforD(aL, bL, cD, dD, rD, rD);
2837 for (int i = 0; i < SIZE; i++) {
2838 Asserts.assertEquals(rD[i], cmoveLNEforD(aL[i], bL[i], cD[i], dD[i]));
2839 }
2840
2841 testCMoveLGTforD(aL, bL, cD, dD, rD, rD);
2842 for (int i = 0; i < SIZE; i++) {
2843 Asserts.assertEquals(rD[i], cmoveLGTforD(aL[i], bL[i], cD[i], dD[i]));
2844 }
2845
2846 testCMoveLGEforD(aL, bL, cD, dD, rD, rD);
2847 for (int i = 0; i < SIZE; i++) {
2848 Asserts.assertEquals(rD[i], cmoveLGEforD(aL[i], bL[i], cD[i], dD[i]));
2849 }
2850
2851 testCMoveLLTforD(aL, bL, cD, dD, rD, rD);
2852 for (int i = 0; i < SIZE; i++) {
2853 Asserts.assertEquals(rD[i], cmoveLLTforD(aL[i], bL[i], cD[i], dD[i]));
2854 }
2855
2856 testCMoveLLEforD(aL, bL, cD, dD, rD, rD);
2857 for (int i = 0; i < SIZE; i++) {
2858 Asserts.assertEquals(rD[i], cmoveLLEforD(aL[i], bL[i], cD[i], dD[i]));
2859 }
2860
2861 // Unsigned
2862 // I for I
2863 testCMoveUIEQforI(aI, bI, cI, dI, rI, rI);
2864 for (int i = 0; i < SIZE; i++) {
2865 Asserts.assertEquals(rI[i], cmoveUIEQforI(aI[i], bI[i], cI[i], dI[i]));
2866 }
2867
2868 testCMoveUINEforI(aI, bI, cI, dI, rI, rI);
2869 for (int i = 0; i < SIZE; i++) {
2870 Asserts.assertEquals(rI[i], cmoveUINEforI(aI[i], bI[i], cI[i], dI[i]));
2871 }
2872
2873 testCMoveUIGTforI(aI, bI, cI, dI, rI, rI);
2874 for (int i = 0; i < SIZE; i++) {
2875 Asserts.assertEquals(rI[i], cmoveUIGTforI(aI[i], bI[i], cI[i], dI[i]));
2876 }
2877
2878 testCMoveUIGEforI(aI, bI, cI, dI, rI, rI);
2879 for (int i = 0; i < SIZE; i++) {
2880 Asserts.assertEquals(rI[i], cmoveUIGEforI(aI[i], bI[i], cI[i], dI[i]));
2881 }
2882
2883 testCMoveUILTforI(aI, bI, cI, dI, rI, rI);
2884 for (int i = 0; i < SIZE; i++) {
2885 Asserts.assertEquals(rI[i], cmoveUILTforI(aI[i], bI[i], cI[i], dI[i]));
2886 }
2887
2888 testCMoveUILEforI(aI, bI, cI, dI, rI, rI);
2889 for (int i = 0; i < SIZE; i++) {
2890 Asserts.assertEquals(rI[i], cmoveUILEforI(aI[i], bI[i], cI[i], dI[i]));
2891 }
2892
2893 // I for L
2894 testCMoveUIEQforL(aI, bI, cL, dL, rL, rL);
2895 for (int i = 0; i < SIZE; i++) {
2896 Asserts.assertEquals(rL[i], cmoveUIEQforL(aI[i], bI[i], cL[i], dL[i]));
2897 }
2898
2899 testCMoveUINEforL(aI, bI, cL, dL, rL, rL);
2900 for (int i = 0; i < SIZE; i++) {
2901 Asserts.assertEquals(rL[i], cmoveUINEforL(aI[i], bI[i], cL[i], dL[i]));
2902 }
2903
2904 testCMoveUIGTforL(aI, bI, cL, dL, rL, rL);
2905 for (int i = 0; i < SIZE; i++) {
2906 Asserts.assertEquals(rL[i], cmoveUIGTforL(aI[i], bI[i], cL[i], dL[i]));
2907 }
2908
2909 testCMoveUIGEforL(aI, bI, cL, dL, rL, rL);
2910 for (int i = 0; i < SIZE; i++) {
2911 Asserts.assertEquals(rL[i], cmoveUIGEforL(aI[i], bI[i], cL[i], dL[i]));
2912 }
2913
2914 testCMoveUILTforL(aI, bI, cL, dL, rL, rL);
2915 for (int i = 0; i < SIZE; i++) {
2916 Asserts.assertEquals(rL[i], cmoveUILTforL(aI[i], bI[i], cL[i], dL[i]));
2917 }
2918
2919 testCMoveUILEforL(aI, bI, cL, dL, rL, rL);
2920 for (int i = 0; i < SIZE; i++) {
2921 Asserts.assertEquals(rL[i], cmoveUILEforL(aI[i], bI[i], cL[i], dL[i]));
2922 }
2923
2924 // I for F
2925 testCMoveUIEQforF(aI, bI, cF, dF, rF, rF);
2926 for (int i = 0; i < SIZE; i++) {
2927 Asserts.assertEquals(rF[i], cmoveUIEQforF(aI[i], bI[i], cF[i], dF[i]));
2928 }
2929
2930 testCMoveUINEforF(aI, bI, cF, dF, rF, rF);
2931 for (int i = 0; i < SIZE; i++) {
2932 Asserts.assertEquals(rF[i], cmoveUINEforF(aI[i], bI[i], cF[i], dF[i]));
2933 }
2934
2935 testCMoveUIGTforF(aI, bI, cF, dF, rF, rF);
2936 for (int i = 0; i < SIZE; i++) {
2937 Asserts.assertEquals(rF[i], cmoveUIGTforF(aI[i], bI[i], cF[i], dF[i]));
2938 }
2939
2940 testCMoveUIGEforF(aI, bI, cF, dF, rF, rF);
2941 for (int i = 0; i < SIZE; i++) {
2942 Asserts.assertEquals(rF[i], cmoveUIGEforF(aI[i], bI[i], cF[i], dF[i]));
2943 }
2944
2945 testCMoveUILTforF(aI, bI, cF, dF, rF, rF);
2946 for (int i = 0; i < SIZE; i++) {
2947 Asserts.assertEquals(rF[i], cmoveUILTforF(aI[i], bI[i], cF[i], dF[i]));
2948 }
2949
2950 testCMoveUILEforF(aI, bI, cF, dF, rF, rF);
2951 for (int i = 0; i < SIZE; i++) {
2952 Asserts.assertEquals(rF[i], cmoveUILEforF(aI[i], bI[i], cF[i], dF[i]));
2953 }
2954
2955 // I for D
2956 testCMoveUIEQforD(aI, bI, cD, dD, rD, rD);
2957 for (int i = 0; i < SIZE; i++) {
2958 Asserts.assertEquals(rD[i], cmoveUIEQforD(aI[i], bI[i], cD[i], dD[i]));
2959 }
2960
2961 testCMoveUINEforD(aI, bI, cD, dD, rD, rD);
2962 for (int i = 0; i < SIZE; i++) {
2963 Asserts.assertEquals(rD[i], cmoveUINEforD(aI[i], bI[i], cD[i], dD[i]));
2964 }
2965
2966 testCMoveUIGTforD(aI, bI, cD, dD, rD, rD);
2967 for (int i = 0; i < SIZE; i++) {
2968 Asserts.assertEquals(rD[i], cmoveUIGTforD(aI[i], bI[i], cD[i], dD[i]));
2969 }
2970
2971 testCMoveUIGEforD(aI, bI, cD, dD, rD, rD);
2972 for (int i = 0; i < SIZE; i++) {
2973 Asserts.assertEquals(rD[i], cmoveUIGEforD(aI[i], bI[i], cD[i], dD[i]));
2974 }
2975
2976 testCMoveUILTforD(aI, bI, cD, dD, rD, rD);
2977 for (int i = 0; i < SIZE; i++) {
2978 Asserts.assertEquals(rD[i], cmoveUILTforD(aI[i], bI[i], cD[i], dD[i]));
2979 }
2980
2981 testCMoveUILEforD(aI, bI, cD, dD, rD, rD);
2982 for (int i = 0; i < SIZE; i++) {
2983 Asserts.assertEquals(rD[i], cmoveUILEforD(aI[i], bI[i], cD[i], dD[i]));
2984 }
2985
2986 // L for I
2987 testCMoveULEQforI(aL, bL, cI, dI, rI, rI);
2988 for (int i = 0; i < SIZE; i++) {
2989 Asserts.assertEquals(rI[i], cmoveULEQforI(aL[i], bL[i], cI[i], dI[i]));
2990 }
2991
2992 testCMoveULNEforI(aL, bL, cI, dI, rI, rI);
2993 for (int i = 0; i < SIZE; i++) {
2994 Asserts.assertEquals(rI[i], cmoveULNEforI(aL[i], bL[i], cI[i], dI[i]));
2995 }
2996
2997 testCMoveULGTforI(aL, bL, cI, dI, rI, rI);
2998 for (int i = 0; i < SIZE; i++) {
2999 Asserts.assertEquals(rI[i], cmoveULGTforI(aL[i], bL[i], cI[i], dI[i]));
3000 }
3001
3002 testCMoveULGEforI(aL, bL, cI, dI, rI, rI);
3003 for (int i = 0; i < SIZE; i++) {
3004 Asserts.assertEquals(rI[i], cmoveULGEforI(aL[i], bL[i], cI[i], dI[i]));
3005 }
3006
3007 testCMoveULLTforI(aL, bL, cI, dI, rI, rI);
3008 for (int i = 0; i < SIZE; i++) {
3009 Asserts.assertEquals(rI[i], cmoveULLTforI(aL[i], bL[i], cI[i], dI[i]));
3010 }
3011
3012 testCMoveULLEforI(aL, bL, cI, dI, rI, rI);
3013 for (int i = 0; i < SIZE; i++) {
3014 Asserts.assertEquals(rI[i], cmoveULLEforI(aL[i], bL[i], cI[i], dI[i]));
3015 }
3016
3017 // L for L
3018 testCMoveULEQforL(aL, bL, cL, dL, rL, rL);
3019 for (int i = 0; i < SIZE; i++) {
3020 Asserts.assertEquals(rL[i], cmoveULEQforL(aL[i], bL[i], cL[i], dL[i]));
3021 }
3022
3023 testCMoveULNEforL(aL, bL, cL, dL, rL, rL);
3024 for (int i = 0; i < SIZE; i++) {
3025 Asserts.assertEquals(rL[i], cmoveULNEforL(aL[i], bL[i], cL[i], dL[i]));
3026 }
3027
3028 testCMoveULGTforL(aL, bL, cL, dL, rL, rL);
3029 for (int i = 0; i < SIZE; i++) {
3030 Asserts.assertEquals(rL[i], cmoveULGTforL(aL[i], bL[i], cL[i], dL[i]));
3031 }
3032
3033 testCMoveULGEforL(aL, bL, cL, dL, rL, rL);
3034 for (int i = 0; i < SIZE; i++) {
3035 Asserts.assertEquals(rL[i], cmoveULGEforL(aL[i], bL[i], cL[i], dL[i]));
3036 }
3037
3038 testCMoveULLTforL(aL, bL, cL, dL, rL, rL);
3039 for (int i = 0; i < SIZE; i++) {
3040 Asserts.assertEquals(rL[i], cmoveULLTforL(aL[i], bL[i], cL[i], dL[i]));
3041 }
3042
3043 testCMoveULLEforL(aL, bL, cL, dL, rL, rL);
3044 for (int i = 0; i < SIZE; i++) {
3045 Asserts.assertEquals(rL[i], cmoveULLEforL(aL[i], bL[i], cL[i], dL[i]));
3046 }
3047
3048 // L for F
3049 testCMoveULEQforF(aL, bL, cF, dF, rF, rF);
3050 for (int i = 0; i < SIZE; i++) {
3051 Asserts.assertEquals(rF[i], cmoveULEQforF(aL[i], bL[i], cF[i], dF[i]));
3052 }
3053
3054 testCMoveULNEforF(aL, bL, cF, dF, rF, rF);
3055 for (int i = 0; i < SIZE; i++) {
3056 Asserts.assertEquals(rF[i], cmoveULNEforF(aL[i], bL[i], cF[i], dF[i]));
3057 }
3058
3059 testCMoveULGTforF(aL, bL, cF, dF, rF, rF);
3060 for (int i = 0; i < SIZE; i++) {
3061 Asserts.assertEquals(rF[i], cmoveULGTforF(aL[i], bL[i], cF[i], dF[i]));
3062 }
3063
3064 testCMoveULGEforF(aL, bL, cF, dF, rF, rF);
3065 for (int i = 0; i < SIZE; i++) {
3066 Asserts.assertEquals(rF[i], cmoveULGEforF(aL[i], bL[i], cF[i], dF[i]));
3067 }
3068
3069 testCMoveULLTforF(aL, bL, cF, dF, rF, rF);
3070 for (int i = 0; i < SIZE; i++) {
3071 Asserts.assertEquals(rF[i], cmoveULLTforF(aL[i], bL[i], cF[i], dF[i]));
3072 }
3073
3074 testCMoveULLEforF(aL, bL, cF, dF, rF, rF);
3075 for (int i = 0; i < SIZE; i++) {
3076 Asserts.assertEquals(rF[i], cmoveULLEforF(aL[i], bL[i], cF[i], dF[i]));
3077 }
3078
3079 // L for D
3080 testCMoveULEQforD(aL, bL, cD, dD, rD, rD);
3081 for (int i = 0; i < SIZE; i++) {
3082 Asserts.assertEquals(rD[i], cmoveULEQforD(aL[i], bL[i], cD[i], dD[i]));
3083 }
3084
3085 testCMoveULNEforD(aL, bL, cD, dD, rD, rD);
3086 for (int i = 0; i < SIZE; i++) {
3087 Asserts.assertEquals(rD[i], cmoveULNEforD(aL[i], bL[i], cD[i], dD[i]));
3088 }
3089
3090 testCMoveULGTforD(aL, bL, cD, dD, rD, rD);
3091 for (int i = 0; i < SIZE; i++) {
3092 Asserts.assertEquals(rD[i], cmoveULGTforD(aL[i], bL[i], cD[i], dD[i]));
3093 }
3094
3095 testCMoveULGEforD(aL, bL, cD, dD, rD, rD);
3096 for (int i = 0; i < SIZE; i++) {
3097 Asserts.assertEquals(rD[i], cmoveULGEforD(aL[i], bL[i], cD[i], dD[i]));
3098 }
3099
3100 testCMoveULLTforD(aL, bL, cD, dD, rD, rD);
3101 for (int i = 0; i < SIZE; i++) {
3102 Asserts.assertEquals(rD[i], cmoveULLTforD(aL[i], bL[i], cD[i], dD[i]));
3103 }
3104
3105 testCMoveULLEforD(aL, bL, cD, dD, rD, rD);
3106 for (int i = 0; i < SIZE; i++) {
3107 Asserts.assertEquals(rD[i], cmoveULLEforD(aL[i], bL[i], cD[i], dD[i]));
3108 }
3109
3110 // Float
3111 testCMoveFGTforI(aF, bF, cI, dI, rI, rI);
3112 for (int i = 0; i < SIZE; i++) {
3113 Asserts.assertEquals(rI[i], cmoveFGTforI(aF[i], bF[i], cI[i], dI[i]));
3114 }
3115
3116 testCMoveFGTforL(aF, bF, cL, dL, rL, rL);
3117 for (int i = 0; i < SIZE; i++) {
3118 Asserts.assertEquals(rL[i], cmoveFGTforL(aF[i], bF[i], cL[i], dL[i]));
3119 }
3120
3121 testCMoveFGTforF(aF, bF, cF, dF, rF, rF);
3122 for (int i = 0; i < SIZE; i++) {
3123 Asserts.assertEquals(rF[i], cmoveFGTforF(aF[i], bF[i], cF[i], dF[i]));
3124 }
3125
3126 testCMoveFGTforD(aF, bF, cD, dD, rD, rD);
3127 for (int i = 0; i < SIZE; i++) {
3128 Asserts.assertEquals(rD[i], cmoveFGTforD(aF[i], bF[i], cD[i], dD[i]));
3129 }
3130
3131 testCMoveDGTforI(aD, bD, cI, dI, rI, rI);
3132 for (int i = 0; i < SIZE; i++) {
3133 Asserts.assertEquals(rI[i], cmoveDGTforI(aD[i], bD[i], cI[i], dI[i]));
3134 }
3135
3136 testCMoveDGTforL(aD, bD, cL, dL, rL, rL);
3137 for (int i = 0; i < SIZE; i++) {
3138 Asserts.assertEquals(rL[i], cmoveDGTforL(aD[i], bD[i], cL[i], dL[i]));
3139 }
3140
3141 testCMoveDGTforF(aD, bD, cF, dF, rF, rF);
3142 for (int i = 0; i < SIZE; i++) {
3143 Asserts.assertEquals(rF[i], cmoveDGTforF(aD[i], bD[i], cF[i], dF[i]));
3144 }
3145
3146 testCMoveDGTforD(aD, bD, cD, dD, rD, rD);
3147 for (int i = 0; i < SIZE; i++) {
3148 Asserts.assertEquals(rD[i], cmoveDGTforD(aD[i], bD[i], cD[i], dD[i]));
3149 }
3150
3151 // Use some constants/invariants in the comparison
3152 testCMoveFGTforFCmpCon1(aF[0], bF, cF, dF, rF, rF);
3153 for (int i = 0; i < SIZE; i++) {
3154 Asserts.assertEquals(rF[i], cmoveFGTforF(aF[0], bF[i], cF[i], dF[i]));
3155 }
3156
3157 testCMoveFGTforFCmpCon2(aF, bF[0], cF, dF, rF, rF);
3158 for (int i = 0; i < SIZE; i++) {
3159 Asserts.assertEquals(rF[i], cmoveFGTforF(aF[i], bF[0], cF[i], dF[i]));
3160 }
3161 }
3162
3163 private static void init(int[] a) {
3164 for (int i = 0; i < SIZE; i++) {
3165 a[i] = RANDOM.nextInt();
3166 }
3167 }
3168
3169 private static void init(long[] a) {
3170 for (int i = 0; i < SIZE; i++) {
3171 a[i] = RANDOM.nextLong();
3172 }
3173 }
3174
3175 private static void init(float[] a) {
3176 for (int i = 0; i < SIZE; i++) {
3177 a[i] = switch(RANDOM.nextInt() % 20) {
3178 case 0 -> Float.NaN;
3179 case 1 -> 0;
3180 case 2 -> 1;
3181 case 3 -> Float.POSITIVE_INFINITY;
3182 case 4 -> Float.NEGATIVE_INFINITY;
3183 case 5 -> Float.MAX_VALUE;
3184 case 6 -> Float.MIN_VALUE;
3185 case 7, 8, 9 -> RANDOM.nextFloat();
3186 default -> Float.intBitsToFloat(RANDOM.nextInt());
3187 };
3188 }
3189 }
3190
3191 private static void init(double[] a) {
3192 for (int i = 0; i < SIZE; i++) {
3193 a[i] = switch(RANDOM.nextInt() % 20) {
3194 case 0 -> Double.NaN;
3195 case 1 -> 0;
3196 case 2 -> 1;
3197 case 3 -> Double.POSITIVE_INFINITY;
3198 case 4 -> Double.NEGATIVE_INFINITY;
3199 case 5 -> Double.MAX_VALUE;
3200 case 6 -> Double.MIN_VALUE;
3201 case 7, 8, 9 -> RANDOM.nextDouble();
3202 default -> Double.longBitsToDouble(RANDOM.nextLong());
3203 };
3204 }
3205 }
3206 }