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