1 /*
2 * Copyright (c) 2025, Rivos Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package compiler.c2.irTests;
25
26 import compiler.lib.ir_framework.*;
27 import java.util.List;
28
29 /*
30 * @test
31 * @bug 8358892 8357551
32 * @summary The test is to trigger code path of BoolTest::ge/gt in C2_MacroAssembler::enc_cmove_cmp_fp
33 * @requires vm.debug
34 * @library /test/lib /
35 * @run driver ${test.main.class}
36 */
37 public class TestFPComparison2 {
38 static final double[] DOUBLES = new double[] {
39 Double.NEGATIVE_INFINITY,
40 -Double.MAX_VALUE,
41 -1.0,
42 -Double.MIN_VALUE,
43 -0.0,
44 0.0,
45 Double.MIN_VALUE,
46 1.0,
47 Double.MAX_VALUE,
48 Double.POSITIVE_INFINITY,
49 Double.NaN,
50 };
51
52 static final float[] FLOATS = new float[] {
53 Float.NEGATIVE_INFINITY,
54 -Float.MAX_VALUE,
55 -1.0F,
56 -Float.MIN_VALUE,
57 -0.0F,
58 0.0F,
59 Float.MIN_VALUE,
60 1.0F,
61 Float.MAX_VALUE,
62 Float.POSITIVE_INFINITY,
63 Float.NaN,
64 };
65
66 static final int[] INTS = new int[] {
67 Integer.MIN_VALUE,
68 -100,
69 -1,
70 0,
71 1,
72 100,
73 Integer.MAX_VALUE,
74 };
75
76 public static void main(String[] args) {
77 List<String> options = List.of("-XX:-TieredCompilation", "-Xlog:jit+compilation=trace");
78 // Booltest::ge
79 TestFramework
80 framework = new TestFramework(Test_ge_1.class);
81 framework.addFlags(options.toArray(new String[0])).start();
82 framework = new TestFramework(Test_ge_cmove_fp_1.class);
83 framework.addFlags(options.toArray(new String[0])).start();
84
85 framework = new TestFramework(Test_ge_2.class);
86 framework.addFlags(options.toArray(new String[0])).start();
87 framework = new TestFramework(Test_ge_cmove_fp_2.class);
88 framework.addFlags(options.toArray(new String[0])).start();
89
90 // Booltest::gt
91 framework = new TestFramework(Test_gt_1.class);
92 framework.addFlags(options.toArray(new String[0])).start();
93 framework = new TestFramework(Test_gt_cmove_fp_1.class);
94 framework.addFlags(options.toArray(new String[0])).start();
95
96 framework = new TestFramework(Test_gt_2.class);
97 framework.addFlags(options.toArray(new String[0])).start();
98 framework = new TestFramework(Test_gt_cmove_fp_2.class);
99 framework.addFlags(options.toArray(new String[0])).start();
100
101 // BoolTest::ge/gt in C2_MacroAssembler::enc_cmove_fp_cmp_fp
102 framework = new TestFramework(Test_cmov_fp_cmp_fp_ge_3.class);
103 framework.addFlags(options.toArray(new String[0])).start();
104 framework = new TestFramework(Test_cmov_fp_cmp_fp_ge_4.class);
105 framework.addFlags(options.toArray(new String[0])).start();
106 }
107 }
108
109 class Test_ge_1 {
110 @Test
111 @IR(counts = {IRNode.CMOVE_I, "1"},
112 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
113 public static int test_float_BoolTest_ge_fixed_1_0(float x, float y) {
114 // return 1
115 // when either x or y is NaN
116 // when neither is NaN, and x > y
117 // return 0
118 // when neither is NaN, and x <= y
119 return !(x <= y) ? 1 : 0;
120 }
121 @DontCompile
122 public static int golden_float_BoolTest_ge_fixed_1_0(float x, float y) {
123 return !(x <= y) ? 1 : 0;
124 }
125
126 @Test
127 @IR(counts = {IRNode.CMOVE_I, "1"},
128 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
129 public static int test_double_BoolTest_ge_fixed_1_0(double x, double y) {
130 // return 1
131 // when either x or y is NaN
132 // when neither is NaN, and x > y
133 // return 0
134 // when neither is NaN, and x <= y
135 return !(x <= y) ? 1 : 0;
136 }
137 @DontCompile
138 public static int golden_double_BoolTest_ge_fixed_1_0(double x, double y) {
139 return !(x <= y) ? 1 : 0;
140 }
141
142 @Test
143 @IR(counts = {IRNode.CMOVE_I, "1"},
144 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
145 public static int test_float_BoolTest_ge_fixed_0_1(float x, float y) {
146 return !(x <= y) ? 0 : 1;
147 }
148 @DontCompile
149 public static int golden_float_BoolTest_ge_fixed_0_1(float x, float y) {
150 return !(x <= y) ? 0 : 1;
151 }
152
153 @Test
154 @IR(counts = {IRNode.CMOVE_I, "1"},
155 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
156 public static int test_double_BoolTest_ge_fixed_0_1(double x, double y) {
157 return !(x <= y) ? 0 : 1;
158 }
159 @DontCompile
160 public static int golden_double_BoolTest_ge_fixed_0_1(double x, double y) {
161 return !(x <= y) ? 0 : 1;
162 }
163
164 @Test
165 @IR(counts = {IRNode.CMOVE_I, "1"},
166 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
167 public static int test_float_BoolTest_ge_fixed_10_20(float x, float y) {
168 return !(x <= y) ? 10 : 20;
169 }
170 @DontCompile
171 public static int golden_float_BoolTest_ge_fixed_10_20(float x, float y) {
172 return !(x <= y) ? 10 : 20;
173 }
174
175 @Test
176 @IR(counts = {IRNode.CMOVE_I, "1"},
177 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
178 public static int test_double_BoolTest_ge_fixed_10_20(double x, double y) {
179 return !(x <= y) ? 10 : 20;
180 }
181 @DontCompile
182 public static int golden_double_BoolTest_ge_fixed_10_20(double x, double y) {
183 return !(x <= y) ? 10 : 20;
184 }
185
186 @Test
187 @IR(counts = {IRNode.CMOVE_I, "1"},
188 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
189 public static int test_float_BoolTest_ge_variable_results(float x, float y, int a, int b) {
190 return !(x <= y) ? a : b;
191 }
192 @DontCompile
193 public static int golden_float_BoolTest_ge_variable_results(float x, float y, int a, int b) {
194 return !(x <= y) ? a : b;
195 }
196
197 @Test
198 @IR(counts = {IRNode.CMOVE_I, "1"},
199 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
200 public static int test_double_BoolTest_ge_variable_results(double x, double y, int a, int b) {
201 return !(x <= y) ? a : b;
202 }
203 @DontCompile
204 public static int golden_double_BoolTest_ge_variable_results(double x, double y, int a, int b) {
205 return !(x <= y) ? a : b;
206 }
207
208 @Run(test = {"test_float_BoolTest_ge_fixed_1_0", "test_double_BoolTest_ge_fixed_1_0",
209 "test_float_BoolTest_ge_fixed_0_1", "test_double_BoolTest_ge_fixed_0_1",
210 "test_float_BoolTest_ge_fixed_10_20", "test_double_BoolTest_ge_fixed_10_20",
211 "test_float_BoolTest_ge_variable_results", "test_double_BoolTest_ge_variable_results"})
212 public void runTests() {
213 int err = 0;
214
215 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
216 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
217 float x = TestFPComparison2.FLOATS[i];
218 float y = TestFPComparison2.FLOATS[j];
219 int actual = test_float_BoolTest_ge_fixed_1_0(x, y);
220 int expected = golden_float_BoolTest_ge_fixed_1_0(x, y);
221 if (actual != expected) {
222 System.out.println("Float failed (ge, 1, 0), x: " + x + ", y: " + y +
223 ", actual: " + actual + ", expected: " + expected);
224 err++;
225 }
226 }
227 }
228
229 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
230 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
231 double x = TestFPComparison2.DOUBLES[i];
232 double y = TestFPComparison2.DOUBLES[j];
233 int actual = test_double_BoolTest_ge_fixed_1_0(x, y);
234 int expected = golden_double_BoolTest_ge_fixed_1_0(x, y);
235 if (actual != expected) {
236 System.out.println("Double failed (ge, 1, 0), x: " + x + ", y: " + y +
237 ", actual: " + actual + ", expected: " + expected);
238 err++;
239 }
240 }
241 }
242
243 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
244 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
245 float x = TestFPComparison2.FLOATS[i];
246 float y = TestFPComparison2.FLOATS[j];
247 int actual = test_float_BoolTest_ge_fixed_0_1(x, y);
248 int expected = golden_float_BoolTest_ge_fixed_0_1(x, y);
249 if (actual != expected) {
250 System.out.println("Float failed (ge, 0, 1), x: " + x + ", y: " + y +
251 ", actual: " + actual + ", expected: " + expected);
252 err++;
253 }
254 }
255 }
256
257 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
258 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
259 double x = TestFPComparison2.DOUBLES[i];
260 double y = TestFPComparison2.DOUBLES[j];
261 int actual = test_double_BoolTest_ge_fixed_0_1(x, y);
262 int expected = golden_double_BoolTest_ge_fixed_0_1(x, y);
263 if (actual != expected) {
264 System.out.println("Double failed (ge, 0, 1), x: " + x + ", y: " + y +
265 ", actual: " + actual + ", expected: " + expected);
266 err++;
267 }
268 }
269 }
270
271 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
272 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
273 float x = TestFPComparison2.FLOATS[i];
274 float y = TestFPComparison2.FLOATS[j];
275 int actual = test_float_BoolTest_ge_fixed_10_20(x, y);
276 int expected = golden_float_BoolTest_ge_fixed_10_20(x, y);
277 if (actual != expected) {
278 System.out.println("Float failed (ge, 10, 20), x: " + x + ", y: " + y +
279 ", actual: " + actual + ", expected: " + expected);
280 err++;
281 }
282 }
283 }
284
285 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
286 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
287 double x = TestFPComparison2.DOUBLES[i];
288 double y = TestFPComparison2.DOUBLES[j];
289 int actual = test_double_BoolTest_ge_fixed_10_20(x, y);
290 int expected = golden_double_BoolTest_ge_fixed_10_20(x, y);
291 if (actual != expected) {
292 System.out.println("Double failed (ge, 10, 20), x: " + x + ", y: " + y +
293 ", actual: " + actual + ", expected: " + expected);
294 err++;
295 }
296 }
297 }
298
299 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
300 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
301 float x = TestFPComparison2.FLOATS[i];
302 float y = TestFPComparison2.FLOATS[j];
303 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
304 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
305 int a = TestFPComparison2.INTS[m];
306 int b = TestFPComparison2.INTS[n];
307 int actual = test_float_BoolTest_ge_variable_results(x, y, a, b);
308 int expected = golden_float_BoolTest_ge_variable_results(x, y, a, b);
309 if (actual != expected) {
310 System.out.println("Float failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
311 ", actual: " + actual + ", expected: " + expected);
312 err++;
313 }
314 }
315 }
316 }
317 }
318
319 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
320 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
321 double x = TestFPComparison2.DOUBLES[i];
322 double y = TestFPComparison2.DOUBLES[j];
323 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
324 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
325 int a = TestFPComparison2.INTS[m];
326 int b = TestFPComparison2.INTS[n];
327 int actual = test_double_BoolTest_ge_variable_results(x, y, a, b);
328 int expected = golden_double_BoolTest_ge_variable_results(x, y, a, b);
329 if (actual != expected) {
330 System.out.println("Double failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
331 ", actual: " + actual + ", expected: " + expected);
332 err++;
333 }
334 }
335 }
336 }
337 }
338
339 if (err != 0) {
340 throw new RuntimeException("Some tests failed");
341 }
342 }
343 }
344
345
346 class Test_ge_cmove_fp_1 {
347 @Test
348 @IR(counts = {IRNode.CMOVE_F, "1"},
349 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
350 public static float test_float_BoolTest_ge_fixed_1_0(float x, float y) {
351 // return 1
352 // when either x or y is NaN
353 // when neither is NaN, and x > y
354 // return 0
355 // when neither is NaN, and x <= y
356 return !(x <= y) ? 1.0f : 0.0f;
357 }
358 @DontCompile
359 public static float golden_float_BoolTest_ge_fixed_1_0(float x, float y) {
360 return !(x <= y) ? 1.0f : 0.0f;
361 }
362
363 @Test
364 @IR(counts = {IRNode.CMOVE_F, "1"},
365 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
366 public static float test_double_BoolTest_ge_fixed_1_0(double x, double y) {
367 // return 1
368 // when either x or y is NaN
369 // when neither is NaN, and x > y
370 // return 0
371 // when neither is NaN, and x <= y
372 return !(x <= y) ? 1.0f : 0.0f;
373 }
374 @DontCompile
375 public static float golden_double_BoolTest_ge_fixed_1_0(double x, double y) {
376 return !(x <= y) ? 1.0f : 0.0f;
377 }
378
379 @Test
380 @IR(counts = {IRNode.CMOVE_F, "1"},
381 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
382 public static float test_float_BoolTest_ge_fixed_0_1(float x, float y) {
383 return !(x <= y) ? 0.0f : 1.0f;
384 }
385 @DontCompile
386 public static float golden_float_BoolTest_ge_fixed_0_1(float x, float y) {
387 return !(x <= y) ? 0.0f : 1.0f;
388 }
389
390 @Test
391 @IR(counts = {IRNode.CMOVE_F, "1"},
392 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
393 public static float test_double_BoolTest_ge_fixed_0_1(double x, double y) {
394 return !(x <= y) ? 0.0f : 1.0f;
395 }
396 @DontCompile
397 public static float golden_double_BoolTest_ge_fixed_0_1(double x, double y) {
398 return !(x <= y) ? 0.0f : 1.0f;
399 }
400
401 @Test
402 @IR(counts = {IRNode.CMOVE_F, "1"},
403 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
404 public static float test_float_BoolTest_ge_fixed_10_20(float x, float y) {
405 return !(x <= y) ? 10.0f : 20.0f;
406 }
407 @DontCompile
408 public static float golden_float_BoolTest_ge_fixed_10_20(float x, float y) {
409 return !(x <= y) ? 10.0f : 20.0f;
410 }
411
412 @Test
413 @IR(counts = {IRNode.CMOVE_F, "1"},
414 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
415 public static float test_double_BoolTest_ge_fixed_10_20(double x, double y) {
416 return !(x <= y) ? 10.0f : 20.0f;
417 }
418 @DontCompile
419 public static float golden_double_BoolTest_ge_fixed_10_20(double x, double y) {
420 return !(x <= y) ? 10.0f : 20.0f;
421 }
422
423 @Test
424 @IR(counts = {IRNode.CMOVE_F, "1"},
425 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
426 public static float test_float_BoolTest_ge_variable_results(float x, float y, float a, float b) {
427 return !(x <= y) ? a : b;
428 }
429 @DontCompile
430 public static float golden_float_BoolTest_ge_variable_results(float x, float y, float a, float b) {
431 return !(x <= y) ? a : b;
432 }
433
434 @Test
435 @IR(counts = {IRNode.CMOVE_F, "1"},
436 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
437 public static float test_double_BoolTest_ge_variable_results(double x, double y, float a, float b) {
438 return !(x <= y) ? a : b;
439 }
440 @DontCompile
441 public static float golden_double_BoolTest_ge_variable_results(double x, double y, float a, float b) {
442 return !(x <= y) ? a : b;
443 }
444
445 @Run(test = {"test_float_BoolTest_ge_fixed_1_0", "test_double_BoolTest_ge_fixed_1_0",
446 "test_float_BoolTest_ge_fixed_0_1", "test_double_BoolTest_ge_fixed_0_1",
447 "test_float_BoolTest_ge_fixed_10_20", "test_double_BoolTest_ge_fixed_10_20",
448 "test_float_BoolTest_ge_variable_results", "test_double_BoolTest_ge_variable_results"})
449 public void runTests() {
450 int err = 0;
451
452 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
453 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
454 float x = TestFPComparison2.FLOATS[i];
455 float y = TestFPComparison2.FLOATS[j];
456 float actual = test_float_BoolTest_ge_fixed_1_0(x, y);
457 float expected = golden_float_BoolTest_ge_fixed_1_0(x, y);
458 if (actual != expected) {
459 System.out.println("Float failed (ge, 1, 0), x: " + x + ", y: " + y +
460 ", actual: " + actual + ", expected: " + expected);
461 err++;
462 }
463 }
464 }
465
466 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
467 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
468 double x = TestFPComparison2.DOUBLES[i];
469 double y = TestFPComparison2.DOUBLES[j];
470 float actual = test_double_BoolTest_ge_fixed_1_0(x, y);
471 float expected = golden_double_BoolTest_ge_fixed_1_0(x, y);
472 if (actual != expected) {
473 System.out.println("Double failed (ge, 1, 0), x: " + x + ", y: " + y +
474 ", actual: " + actual + ", expected: " + expected);
475 err++;
476 }
477 }
478 }
479
480 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
481 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
482 float x = TestFPComparison2.FLOATS[i];
483 float y = TestFPComparison2.FLOATS[j];
484 float actual = test_float_BoolTest_ge_fixed_0_1(x, y);
485 float expected = golden_float_BoolTest_ge_fixed_0_1(x, y);
486 if (actual != expected) {
487 System.out.println("Float failed (ge, 0, 1), x: " + x + ", y: " + y +
488 ", actual: " + actual + ", expected: " + expected);
489 err++;
490 }
491 }
492 }
493
494 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
495 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
496 double x = TestFPComparison2.DOUBLES[i];
497 double y = TestFPComparison2.DOUBLES[j];
498 float actual = test_double_BoolTest_ge_fixed_0_1(x, y);
499 float expected = golden_double_BoolTest_ge_fixed_0_1(x, y);
500 if (actual != expected) {
501 System.out.println("Double failed (ge, 0, 1), x: " + x + ", y: " + y +
502 ", actual: " + actual + ", expected: " + expected);
503 err++;
504 }
505 }
506 }
507
508 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
509 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
510 float x = TestFPComparison2.FLOATS[i];
511 float y = TestFPComparison2.FLOATS[j];
512 float actual = test_float_BoolTest_ge_fixed_10_20(x, y);
513 float expected = golden_float_BoolTest_ge_fixed_10_20(x, y);
514 if (actual != expected) {
515 System.out.println("Float failed (ge, 10, 20), x: " + x + ", y: " + y +
516 ", actual: " + actual + ", expected: " + expected);
517 err++;
518 }
519 }
520 }
521
522 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
523 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
524 double x = TestFPComparison2.DOUBLES[i];
525 double y = TestFPComparison2.DOUBLES[j];
526 float actual = test_double_BoolTest_ge_fixed_10_20(x, y);
527 float expected = golden_double_BoolTest_ge_fixed_10_20(x, y);
528 if (actual != expected) {
529 System.out.println("Double failed (ge, 10, 20), x: " + x + ", y: " + y +
530 ", actual: " + actual + ", expected: " + expected);
531 err++;
532 }
533 }
534 }
535
536 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
537 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
538 float x = TestFPComparison2.FLOATS[i];
539 float y = TestFPComparison2.FLOATS[j];
540 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
541 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
542 float a = TestFPComparison2.FLOATS[m];
543 float b = TestFPComparison2.FLOATS[n];
544 float actual = test_float_BoolTest_ge_variable_results(x, y, a, b);
545 float expected = golden_float_BoolTest_ge_variable_results(x, y, a, b);
546 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
547 System.out.println("Float failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
548 ", actual: " + actual + ", expected: " + expected);
549 err++;
550 }
551 }
552 }
553 }
554 }
555
556 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
557 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
558 double x = TestFPComparison2.DOUBLES[i];
559 double y = TestFPComparison2.DOUBLES[j];
560 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
561 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
562 float a = TestFPComparison2.FLOATS[m];
563 float b = TestFPComparison2.FLOATS[n];
564 float actual = test_double_BoolTest_ge_variable_results(x, y, a, b);
565 float expected = golden_double_BoolTest_ge_variable_results(x, y, a, b);
566 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
567 System.out.println("Double failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
568 ", actual: " + actual + ", expected: " + expected);
569 err++;
570 }
571 }
572 }
573 }
574 }
575
576 if (err != 0) {
577 throw new RuntimeException("Some tests failed");
578 }
579 }
580 }
581
582 class Test_ge_2 {
583 @Test
584 @IR(counts = {IRNode.CMOVE_I, "1"},
585 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
586 public static int test_float_BoolTest_ge_fixed_1_0(float x, float y) {
587 // return 1
588 // when either x or y is NaN
589 // when neither is NaN, and x < y
590 // return 0
591 // when neither is NaN, and x >= y
592 return !(x >= y) ? 1 : 0;
593 }
594 @DontCompile
595 public static int golden_float_BoolTest_ge_fixed_1_0(float x, float y) {
596 return !(x >= y) ? 1 : 0;
597 }
598
599 @Test
600 @IR(counts = {IRNode.CMOVE_I, "1"},
601 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
602 public static int test_double_BoolTest_ge_fixed_1_0(double x, double y) {
603 // return 1
604 // when either x or y is NaN
605 // when neither is NaN, and x < y
606 // return 0
607 // when neither is NaN, and x >= y
608 return !(x >= y) ? 1 : 0;
609 }
610 @DontCompile
611 public static int golden_double_BoolTest_ge_fixed_1_0(double x, double y) {
612 return !(x >= y) ? 1 : 0;
613 }
614
615 @Test
616 @IR(counts = {IRNode.CMOVE_I, "1"},
617 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
618 public static int test_float_BoolTest_ge_fixed_0_1(float x, float y) {
619 return !(x >= y) ? 0 : 1;
620 }
621 @DontCompile
622 public static int golden_float_BoolTest_ge_fixed_0_1(float x, float y) {
623 return !(x >= y) ? 0 : 1;
624 }
625
626 @Test
627 @IR(counts = {IRNode.CMOVE_I, "1"},
628 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
629 public static int test_double_BoolTest_ge_fixed_0_1(double x, double y) {
630 return !(x >= y) ? 0 : 1;
631 }
632 @DontCompile
633 public static int golden_double_BoolTest_ge_fixed_0_1(double x, double y) {
634 return !(x >= y) ? 0 : 1;
635 }
636
637 @Test
638 @IR(counts = {IRNode.CMOVE_I, "1"},
639 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
640 public static int test_float_BoolTest_ge_fixed_10_20(float x, float y) {
641 return !(x >= y) ? 10 : 20;
642 }
643 @DontCompile
644 public static int golden_float_BoolTest_ge_fixed_10_20(float x, float y) {
645 return !(x >= y) ? 10 : 20;
646 }
647
648 @Test
649 @IR(counts = {IRNode.CMOVE_I, "1"},
650 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
651 public static int test_double_BoolTest_ge_fixed_10_20(double x, double y) {
652 return !(x >= y) ? 10 : 20;
653 }
654 @DontCompile
655 public static int golden_double_BoolTest_ge_fixed_10_20(double x, double y) {
656 return !(x >= y) ? 10 : 20;
657 }
658
659 @Test
660 @IR(counts = {IRNode.CMOVE_I, "1"},
661 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
662 public static int test_float_BoolTest_ge_variable_results(float x, float y, int a, int b) {
663 return !(x >= y) ? a : b;
664 }
665 @DontCompile
666 public static int golden_float_BoolTest_ge_variable_results(float x, float y, int a, int b) {
667 return !(x >= y) ? a : b;
668 }
669
670 @Test
671 @IR(counts = {IRNode.CMOVE_I, "1"},
672 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
673 public static int test_double_BoolTest_ge_variable_results(double x, double y, int a, int b) {
674 return !(x >= y) ? a : b;
675 }
676 @DontCompile
677 public static int golden_double_BoolTest_ge_variable_results(double x, double y, int a, int b) {
678 return !(x >= y) ? a : b;
679 }
680
681 @Run(test = {"test_float_BoolTest_ge_fixed_1_0", "test_double_BoolTest_ge_fixed_1_0",
682 "test_float_BoolTest_ge_fixed_0_1", "test_double_BoolTest_ge_fixed_0_1",
683 "test_float_BoolTest_ge_fixed_10_20", "test_double_BoolTest_ge_fixed_10_20",
684 "test_float_BoolTest_ge_variable_results", "test_double_BoolTest_ge_variable_results"})
685 public void runTests() {
686 int err = 0;
687
688 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
689 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
690 float x = TestFPComparison2.FLOATS[i];
691 float y = TestFPComparison2.FLOATS[j];
692 int actual = test_float_BoolTest_ge_fixed_1_0(x, y);
693 int expected = golden_float_BoolTest_ge_fixed_1_0(x, y);
694 if (actual != expected) {
695 System.out.println("Float failed (ge), x: " + x + ", y: " + y +
696 ", actual: " + actual + ", expected: " + expected);
697 err++;
698 }
699 }
700 }
701
702 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
703 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
704 double x = TestFPComparison2.DOUBLES[i];
705 double y = TestFPComparison2.DOUBLES[j];
706 int actual = test_double_BoolTest_ge_fixed_1_0(x, y);
707 int expected = golden_double_BoolTest_ge_fixed_1_0(x, y);
708 if (actual != expected) {
709 System.out.println("Double failed (ge), x: " + x + ", y: " + y +
710 ", actual: " + actual + ", expected: " + expected);
711 err++;
712 }
713 }
714 }
715
716 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
717 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
718 float x = TestFPComparison2.FLOATS[i];
719 float y = TestFPComparison2.FLOATS[j];
720 int actual = test_float_BoolTest_ge_fixed_0_1(x, y);
721 int expected = golden_float_BoolTest_ge_fixed_0_1(x, y);
722 if (actual != expected) {
723 System.out.println("Float failed (ge, 0, 1), x: " + x + ", y: " + y +
724 ", actual: " + actual + ", expected: " + expected);
725 err++;
726 }
727 }
728 }
729
730 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
731 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
732 double x = TestFPComparison2.DOUBLES[i];
733 double y = TestFPComparison2.DOUBLES[j];
734 int actual = test_double_BoolTest_ge_fixed_0_1(x, y);
735 int expected = golden_double_BoolTest_ge_fixed_0_1(x, y);
736 if (actual != expected) {
737 System.out.println("Double failed (ge, 0, 1), x: " + x + ", y: " + y +
738 ", actual: " + actual + ", expected: " + expected);
739 err++;
740 }
741 }
742 }
743
744 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
745 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
746 float x = TestFPComparison2.FLOATS[i];
747 float y = TestFPComparison2.FLOATS[j];
748 int actual = test_float_BoolTest_ge_fixed_10_20(x, y);
749 int expected = golden_float_BoolTest_ge_fixed_10_20(x, y);
750 if (actual != expected) {
751 System.out.println("Float failed (ge, 10, 20), x: " + x + ", y: " + y +
752 ", actual: " + actual + ", expected: " + expected);
753 err++;
754 }
755 }
756 }
757
758 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
759 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
760 double x = TestFPComparison2.DOUBLES[i];
761 double y = TestFPComparison2.DOUBLES[j];
762 int actual = test_double_BoolTest_ge_fixed_10_20(x, y);
763 int expected = golden_double_BoolTest_ge_fixed_10_20(x, y);
764 if (actual != expected) {
765 System.out.println("Double failed (ge, 10, 20), x: " + x + ", y: " + y +
766 ", actual: " + actual + ", expected: " + expected);
767 err++;
768 }
769 }
770 }
771
772 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
773 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
774 float x = TestFPComparison2.FLOATS[i];
775 float y = TestFPComparison2.FLOATS[j];
776 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
777 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
778 int a = TestFPComparison2.INTS[m];
779 int b = TestFPComparison2.INTS[n];
780 int actual = test_float_BoolTest_ge_variable_results(x, y, a, b);
781 int expected = golden_float_BoolTest_ge_variable_results(x, y, a, b);
782 if (actual != expected) {
783 System.out.println("Float failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
784 ", actual: " + actual + ", expected: " + expected);
785 err++;
786 }
787 }
788 }
789 }
790 }
791
792 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
793 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
794 double x = TestFPComparison2.DOUBLES[i];
795 double y = TestFPComparison2.DOUBLES[j];
796 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
797 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
798 int a = TestFPComparison2.INTS[m];
799 int b = TestFPComparison2.INTS[n];
800 int actual = test_double_BoolTest_ge_variable_results(x, y, a, b);
801 int expected = golden_double_BoolTest_ge_variable_results(x, y, a, b);
802 if (actual != expected) {
803 System.out.println("Double failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
804 ", actual: " + actual + ", expected: " + expected);
805 err++;
806 }
807 }
808 }
809 }
810 }
811
812 if (err != 0) {
813 throw new RuntimeException("Some tests failed");
814 }
815 }
816 }
817
818 class Test_ge_cmove_fp_2 {
819 @Test
820 @IR(counts = {IRNode.CMOVE_F, "1"},
821 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
822 public static float test_float_BoolTest_ge_fixed_1_0(float x, float y) {
823 // return 1
824 // when either x or y is NaN
825 // when neither is NaN, and x < y
826 // return 0
827 // when neither is NaN, and x >= y
828 return !(x >= y) ? 1.0f : 0.0f;
829 }
830 @DontCompile
831 public static float golden_float_BoolTest_ge_fixed_1_0(float x, float y) {
832 return !(x >= y) ? 1.0f : 0.0f;
833 }
834
835 @Test
836 @IR(counts = {IRNode.CMOVE_F, "1"},
837 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
838 public static float test_double_BoolTest_ge_fixed_1_0(double x, double y) {
839 // return 1
840 // when either x or y is NaN
841 // when neither is NaN, and x < y
842 // return 0
843 // when neither is NaN, and x >= y
844 return !(x >= y) ? 1.0f : 0.0f;
845 }
846 @DontCompile
847 public static float golden_double_BoolTest_ge_fixed_1_0(double x, double y) {
848 return !(x >= y) ? 1.0f : 0.0f;
849 }
850
851 @Test
852 @IR(counts = {IRNode.CMOVE_F, "1"},
853 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
854 public static float test_float_BoolTest_ge_fixed_0_1(float x, float y) {
855 return !(x >= y) ? 0.0f : 1.0f;
856 }
857 @DontCompile
858 public static float golden_float_BoolTest_ge_fixed_0_1(float x, float y) {
859 return !(x >= y) ? 0.0f : 1.0f;
860 }
861
862 @Test
863 @IR(counts = {IRNode.CMOVE_F, "1"},
864 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
865 public static float test_double_BoolTest_ge_fixed_0_1(double x, double y) {
866 return !(x >= y) ? 0.0f : 1.0f;
867 }
868 @DontCompile
869 public static float golden_double_BoolTest_ge_fixed_0_1(double x, double y) {
870 return !(x >= y) ? 0.0f : 1.0f;
871 }
872
873 @Test
874 @IR(counts = {IRNode.CMOVE_F, "1"},
875 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
876 public static float test_float_BoolTest_ge_fixed_10_20(float x, float y) {
877 return !(x >= y) ? 10.0f : 20.0f;
878 }
879 @DontCompile
880 public static float golden_float_BoolTest_ge_fixed_10_20(float x, float y) {
881 return !(x >= y) ? 10.0f : 20.0f;
882 }
883
884 @Test
885 @IR(counts = {IRNode.CMOVE_F, "1"},
886 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
887 public static float test_double_BoolTest_ge_fixed_10_20(double x, double y) {
888 return !(x >= y) ? 10.0f : 20.0f;
889 }
890 @DontCompile
891 public static float golden_double_BoolTest_ge_fixed_10_20(double x, double y) {
892 return !(x >= y) ? 10.0f : 20.0f;
893 }
894
895 @Test
896 @IR(counts = {IRNode.CMOVE_F, "1"},
897 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
898 public static float test_float_BoolTest_ge_variable_results(float x, float y, float a, float b) {
899 return !(x >= y) ? a : b;
900 }
901 @DontCompile
902 public static float golden_float_BoolTest_ge_variable_results(float x, float y, float a, float b) {
903 return !(x >= y) ? a : b;
904 }
905
906 @Test
907 @IR(counts = {IRNode.CMOVE_F, "1"},
908 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
909 public static float test_double_BoolTest_ge_variable_results(double x, double y, float a, float b) {
910 return !(x >= y) ? a : b;
911 }
912 @DontCompile
913 public static float golden_double_BoolTest_ge_variable_results(double x, double y, float a, float b) {
914 return !(x >= y) ? a : b;
915 }
916
917 @Run(test = {"test_float_BoolTest_ge_fixed_1_0", "test_double_BoolTest_ge_fixed_1_0",
918 "test_float_BoolTest_ge_fixed_0_1", "test_double_BoolTest_ge_fixed_0_1",
919 "test_float_BoolTest_ge_fixed_10_20", "test_double_BoolTest_ge_fixed_10_20",
920 "test_float_BoolTest_ge_variable_results", "test_double_BoolTest_ge_variable_results"})
921 public void runTests() {
922 int err = 0;
923
924 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
925 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
926 float x = TestFPComparison2.FLOATS[i];
927 float y = TestFPComparison2.FLOATS[j];
928 float actual = test_float_BoolTest_ge_fixed_1_0(x, y);
929 float expected = golden_float_BoolTest_ge_fixed_1_0(x, y);
930 if (actual != expected) {
931 System.out.println("Float failed (ge), x: " + x + ", y: " + y +
932 ", actual: " + actual + ", expected: " + expected);
933 err++;
934 }
935 }
936 }
937
938 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
939 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
940 double x = TestFPComparison2.DOUBLES[i];
941 double y = TestFPComparison2.DOUBLES[j];
942 float actual = test_double_BoolTest_ge_fixed_1_0(x, y);
943 float expected = golden_double_BoolTest_ge_fixed_1_0(x, y);
944 if (actual != expected) {
945 System.out.println("Double failed (ge), x: " + x + ", y: " + y +
946 ", actual: " + actual + ", expected: " + expected);
947 err++;
948 }
949 }
950 }
951
952 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
953 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
954 float x = TestFPComparison2.FLOATS[i];
955 float y = TestFPComparison2.FLOATS[j];
956 float actual = test_float_BoolTest_ge_fixed_0_1(x, y);
957 float expected = golden_float_BoolTest_ge_fixed_0_1(x, y);
958 if (actual != expected) {
959 System.out.println("Float failed (ge, 0, 1), x: " + x + ", y: " + y +
960 ", actual: " + actual + ", expected: " + expected);
961 err++;
962 }
963 }
964 }
965
966 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
967 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
968 double x = TestFPComparison2.DOUBLES[i];
969 double y = TestFPComparison2.DOUBLES[j];
970 float actual = test_double_BoolTest_ge_fixed_0_1(x, y);
971 float expected = golden_double_BoolTest_ge_fixed_0_1(x, y);
972 if (actual != expected) {
973 System.out.println("Double failed (ge, 0, 1), x: " + x + ", y: " + y +
974 ", actual: " + actual + ", expected: " + expected);
975 err++;
976 }
977 }
978 }
979
980 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
981 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
982 float x = TestFPComparison2.FLOATS[i];
983 float y = TestFPComparison2.FLOATS[j];
984 float actual = test_float_BoolTest_ge_fixed_10_20(x, y);
985 float expected = golden_float_BoolTest_ge_fixed_10_20(x, y);
986 if (actual != expected) {
987 System.out.println("Float failed (ge, 10, 20), x: " + x + ", y: " + y +
988 ", actual: " + actual + ", expected: " + expected);
989 err++;
990 }
991 }
992 }
993
994 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
995 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
996 double x = TestFPComparison2.DOUBLES[i];
997 double y = TestFPComparison2.DOUBLES[j];
998 float actual = test_double_BoolTest_ge_fixed_10_20(x, y);
999 float expected = golden_double_BoolTest_ge_fixed_10_20(x, y);
1000 if (actual != expected) {
1001 System.out.println("Double failed (ge, 10, 20), x: " + x + ", y: " + y +
1002 ", actual: " + actual + ", expected: " + expected);
1003 err++;
1004 }
1005 }
1006 }
1007
1008 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1009 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1010 float x = TestFPComparison2.FLOATS[i];
1011 float y = TestFPComparison2.FLOATS[j];
1012 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1013 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1014 float a = TestFPComparison2.FLOATS[m];
1015 float b = TestFPComparison2.FLOATS[n];
1016 float actual = test_float_BoolTest_ge_variable_results(x, y, a, b);
1017 float expected = golden_float_BoolTest_ge_variable_results(x, y, a, b);
1018 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1019 System.out.println("Float failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1020 ", actual: " + actual + ", expected: " + expected);
1021 err++;
1022 }
1023 }
1024 }
1025 }
1026 }
1027
1028 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1029 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1030 double x = TestFPComparison2.DOUBLES[i];
1031 double y = TestFPComparison2.DOUBLES[j];
1032 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1033 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1034 float a = TestFPComparison2.FLOATS[m];
1035 float b = TestFPComparison2.FLOATS[n];
1036 float actual = test_double_BoolTest_ge_variable_results(x, y, a, b);
1037 float expected = golden_double_BoolTest_ge_variable_results(x, y, a, b);
1038 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1039 System.out.println("Double failed (ge), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1040 ", actual: " + actual + ", expected: " + expected);
1041 err++;
1042 }
1043 }
1044 }
1045 }
1046 }
1047
1048 if (err != 0) {
1049 throw new RuntimeException("Some tests failed");
1050 }
1051 }
1052 }
1053
1054 class Test_gt_1 {
1055 @Test
1056 @IR(counts = {IRNode.CMOVE_I, "1"},
1057 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1058 public static int test_float_BoolTest_gt_fixed_1_0(float x, float y) {
1059 // return 1
1060 // when either x or y is NaN
1061 // when neither is NaN, and x >= y
1062 // return 0
1063 // when neither is NaN, and x < y
1064 return !(x < y) ? 1 : 0;
1065 }
1066 @DontCompile
1067 public static int golden_float_BoolTest_gt_fixed_1_0(float x, float y) {
1068 return !(x < y) ? 1 : 0;
1069 }
1070
1071 @Test
1072 @IR(counts = {IRNode.CMOVE_I, "1"},
1073 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1074 public static int test_double_BoolTest_gt_fixed_1_0(double x, double y) {
1075 // return 1
1076 // when either x or y is NaN
1077 // when neither is NaN, and x >= y
1078 // return 0
1079 // when neither is NaN, and x < y
1080 return !(x < y) ? 1 : 0;
1081 }
1082 @DontCompile
1083 public static int golden_double_BoolTest_gt_fixed_1_0(double x, double y) {
1084 return !(x < y) ? 1 : 0;
1085 }
1086
1087 @Test
1088 @IR(counts = {IRNode.CMOVE_I, "1"},
1089 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1090 public static int test_float_BoolTest_gt_fixed_0_1(float x, float y) {
1091 return !(x < y) ? 0 : 1;
1092 }
1093 @DontCompile
1094 public static int golden_float_BoolTest_gt_fixed_0_1(float x, float y) {
1095 return !(x < y) ? 0 : 1;
1096 }
1097
1098 @Test
1099 @IR(counts = {IRNode.CMOVE_I, "1"},
1100 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1101 public static int test_double_BoolTest_gt_fixed_0_1(double x, double y) {
1102 return !(x < y) ? 0 : 1;
1103 }
1104 @DontCompile
1105 public static int golden_double_BoolTest_gt_fixed_0_1(double x, double y) {
1106 return !(x < y) ? 0 : 1;
1107 }
1108
1109 @Test
1110 @IR(counts = {IRNode.CMOVE_I, "1"},
1111 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1112 public static int test_float_BoolTest_gt_fixed_10_20(float x, float y) {
1113 return !(x < y) ? 10 : 20;
1114 }
1115 @DontCompile
1116 public static int golden_float_BoolTest_gt_fixed_10_20(float x, float y) {
1117 return !(x < y) ? 10 : 20;
1118 }
1119
1120 @Test
1121 @IR(counts = {IRNode.CMOVE_I, "1"},
1122 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1123 public static int test_double_BoolTest_gt_fixed_10_20(double x, double y) {
1124 return !(x < y) ? 10 : 20;
1125 }
1126 @DontCompile
1127 public static int golden_double_BoolTest_gt_fixed_10_20(double x, double y) {
1128 return !(x < y) ? 10 : 20;
1129 }
1130
1131 @Test
1132 @IR(counts = {IRNode.CMOVE_I, "1"},
1133 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1134 public static int test_float_BoolTest_gt_variable_results(float x, float y, int a, int b) {
1135 return !(x < y) ? a : b;
1136 }
1137 @DontCompile
1138 public static int golden_float_BoolTest_gt_variable_results(float x, float y, int a, int b) {
1139 return !(x < y) ? a : b;
1140 }
1141
1142 @Test
1143 @IR(counts = {IRNode.CMOVE_I, "1"},
1144 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1145 public static int test_double_BoolTest_gt_variable_results(double x, double y, int a, int b) {
1146 return !(x < y) ? a : b;
1147 }
1148 @DontCompile
1149 public static int golden_double_BoolTest_gt_variable_results(double x, double y, int a, int b) {
1150 return !(x < y) ? a : b;
1151 }
1152
1153 @Run(test = {"test_float_BoolTest_gt_fixed_1_0", "test_double_BoolTest_gt_fixed_1_0",
1154 "test_float_BoolTest_gt_fixed_0_1", "test_double_BoolTest_gt_fixed_0_1",
1155 "test_float_BoolTest_gt_fixed_10_20", "test_double_BoolTest_gt_fixed_10_20",
1156 "test_float_BoolTest_gt_variable_results", "test_double_BoolTest_gt_variable_results"})
1157 public void runTests() {
1158 int err = 0;
1159
1160 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1161 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1162 float x = TestFPComparison2.FLOATS[i];
1163 float y = TestFPComparison2.FLOATS[j];
1164 int actual = test_float_BoolTest_gt_fixed_1_0(x, y);
1165 int expected = golden_float_BoolTest_gt_fixed_1_0(x, y);
1166 if (actual != expected) {
1167 System.out.println("Float failed (gt), x: " + x + ", y: " + y +
1168 ", actual: " + actual + ", expected: " + expected);
1169 err++;
1170 }
1171 }
1172 }
1173
1174 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1175 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1176 double x = TestFPComparison2.DOUBLES[i];
1177 double y = TestFPComparison2.DOUBLES[j];
1178 int actual = test_double_BoolTest_gt_fixed_1_0(x, y);
1179 int expected = golden_double_BoolTest_gt_fixed_1_0(x, y);
1180 if (actual != expected) {
1181 System.out.println("Double failed (gt), x: " + x + ", y: " + y +
1182 ", actual: " + actual + ", expected: " + expected);
1183 err++;
1184 }
1185 }
1186 }
1187
1188 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1189 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1190 float x = TestFPComparison2.FLOATS[i];
1191 float y = TestFPComparison2.FLOATS[j];
1192 int actual = test_float_BoolTest_gt_fixed_0_1(x, y);
1193 int expected = golden_float_BoolTest_gt_fixed_0_1(x, y);
1194 if (actual != expected) {
1195 System.out.println("Float failed (gt, 0, 1), x: " + x + ", y: " + y +
1196 ", actual: " + actual + ", expected: " + expected);
1197 err++;
1198 }
1199 }
1200 }
1201
1202 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1203 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1204 double x = TestFPComparison2.DOUBLES[i];
1205 double y = TestFPComparison2.DOUBLES[j];
1206 int actual = test_double_BoolTest_gt_fixed_0_1(x, y);
1207 int expected = golden_double_BoolTest_gt_fixed_0_1(x, y);
1208 if (actual != expected) {
1209 System.out.println("Double failed (gt, 0, 1), x: " + x + ", y: " + y +
1210 ", actual: " + actual + ", expected: " + expected);
1211 err++;
1212 }
1213 }
1214 }
1215
1216 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1217 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1218 float x = TestFPComparison2.FLOATS[i];
1219 float y = TestFPComparison2.FLOATS[j];
1220 int actual = test_float_BoolTest_gt_fixed_10_20(x, y);
1221 int expected = golden_float_BoolTest_gt_fixed_10_20(x, y);
1222 if (actual != expected) {
1223 System.out.println("Float failed (gt, 10, 20), x: " + x + ", y: " + y +
1224 ", actual: " + actual + ", expected: " + expected);
1225 err++;
1226 }
1227 }
1228 }
1229
1230 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1231 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1232 double x = TestFPComparison2.DOUBLES[i];
1233 double y = TestFPComparison2.DOUBLES[j];
1234 int actual = test_double_BoolTest_gt_fixed_10_20(x, y);
1235 int expected = golden_double_BoolTest_gt_fixed_10_20(x, y);
1236 if (actual != expected) {
1237 System.out.println("Double failed (gt, 10, 20), x: " + x + ", y: " + y +
1238 ", actual: " + actual + ", expected: " + expected);
1239 err++;
1240 }
1241 }
1242 }
1243
1244 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1245 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1246 float x = TestFPComparison2.FLOATS[i];
1247 float y = TestFPComparison2.FLOATS[j];
1248 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
1249 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
1250 int a = TestFPComparison2.INTS[m];
1251 int b = TestFPComparison2.INTS[n];
1252 int actual = test_float_BoolTest_gt_variable_results(x, y, a, b);
1253 int expected = golden_float_BoolTest_gt_variable_results(x, y, a, b);
1254 if (actual != expected) {
1255 System.out.println("Float failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1256 ", actual: " + actual + ", expected: " + expected);
1257 err++;
1258 }
1259 }
1260 }
1261 }
1262 }
1263
1264 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1265 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1266 double x = TestFPComparison2.DOUBLES[i];
1267 double y = TestFPComparison2.DOUBLES[j];
1268 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
1269 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
1270 int a = TestFPComparison2.INTS[m];
1271 int b = TestFPComparison2.INTS[n];
1272 int actual = test_double_BoolTest_gt_variable_results(x, y, a, b);
1273 int expected = golden_double_BoolTest_gt_variable_results(x, y, a, b);
1274 if (actual != expected) {
1275 System.out.println("Double failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1276 ", actual: " + actual + ", expected: " + expected);
1277 err++;
1278 }
1279 }
1280 }
1281 }
1282 }
1283
1284 if (err != 0) {
1285 throw new RuntimeException("Some tests failed");
1286 }
1287 }
1288 }
1289
1290 class Test_gt_cmove_fp_1 {
1291 @Test
1292 @IR(counts = {IRNode.CMOVE_F, "1"},
1293 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1294 public static float test_float_BoolTest_gt_fixed_1_0(float x, float y) {
1295 // return 1
1296 // when either x or y is NaN
1297 // when neither is NaN, and x >= y
1298 // return 0
1299 // when neither is NaN, and x < y
1300 return !(x < y) ? 1.0f : 0.0f;
1301 }
1302 @DontCompile
1303 public static float golden_float_BoolTest_gt_fixed_1_0(float x, float y) {
1304 return !(x < y) ? 1.0f : 0.0f;
1305 }
1306
1307 @Test
1308 @IR(counts = {IRNode.CMOVE_F, "1"},
1309 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1310 public static float test_double_BoolTest_gt_fixed_1_0(double x, double y) {
1311 // return 1
1312 // when either x or y is NaN
1313 // when neither is NaN, and x >= y
1314 // return 0
1315 // when neither is NaN, and x < y
1316 return !(x < y) ? 1.0f : 0.0f;
1317 }
1318 @DontCompile
1319 public static float golden_double_BoolTest_gt_fixed_1_0(double x, double y) {
1320 return !(x < y) ? 1.0f : 0.0f;
1321 }
1322
1323 @Test
1324 @IR(counts = {IRNode.CMOVE_F, "1"},
1325 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1326 public static float test_float_BoolTest_gt_fixed_0_1(float x, float y) {
1327 return !(x < y) ? 0.0f : 1.0f;
1328 }
1329 @DontCompile
1330 public static float golden_float_BoolTest_gt_fixed_0_1(float x, float y) {
1331 return !(x < y) ? 0.0f : 1.0f;
1332 }
1333
1334 @Test
1335 @IR(counts = {IRNode.CMOVE_F, "1"},
1336 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1337 public static float test_double_BoolTest_gt_fixed_0_1(double x, double y) {
1338 return !(x < y) ? 0.0f : 1.0f;
1339 }
1340 @DontCompile
1341 public static float golden_double_BoolTest_gt_fixed_0_1(double x, double y) {
1342 return !(x < y) ? 0.0f : 1.0f;
1343 }
1344
1345 @Test
1346 @IR(counts = {IRNode.CMOVE_F, "1"},
1347 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1348 public static float test_float_BoolTest_gt_fixed_10_20(float x, float y) {
1349 return !(x < y) ? 10.0f : 20.0f;
1350 }
1351 @DontCompile
1352 public static float golden_float_BoolTest_gt_fixed_10_20(float x, float y) {
1353 return !(x < y) ? 10.0f : 20.0f;
1354 }
1355
1356 @Test
1357 @IR(counts = {IRNode.CMOVE_F, "1"},
1358 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1359 public static float test_double_BoolTest_gt_fixed_10_20(double x, double y) {
1360 return !(x < y) ? 10.0f : 20.0f;
1361 }
1362 @DontCompile
1363 public static float golden_double_BoolTest_gt_fixed_10_20(double x, double y) {
1364 return !(x < y) ? 10.0f : 20.0f;
1365 }
1366
1367 @Test
1368 @IR(counts = {IRNode.CMOVE_F, "1"},
1369 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1370 public static float test_float_BoolTest_gt_variable_results(float x, float y, float a, float b) {
1371 return !(x < y) ? a : b;
1372 }
1373 @DontCompile
1374 public static float golden_float_BoolTest_gt_variable_results(float x, float y, float a, float b) {
1375 return !(x < y) ? a : b;
1376 }
1377
1378 @Test
1379 @IR(counts = {IRNode.CMOVE_F, "1"},
1380 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1381 public static float test_double_BoolTest_gt_variable_results(double x, double y, float a, float b) {
1382 return !(x < y) ? a : b;
1383 }
1384 @DontCompile
1385 public static float golden_double_BoolTest_gt_variable_results(double x, double y, float a, float b) {
1386 return !(x < y) ? a : b;
1387 }
1388
1389 @Run(test = {"test_float_BoolTest_gt_fixed_1_0", "test_double_BoolTest_gt_fixed_1_0",
1390 "test_float_BoolTest_gt_fixed_0_1", "test_double_BoolTest_gt_fixed_0_1",
1391 "test_float_BoolTest_gt_fixed_10_20", "test_double_BoolTest_gt_fixed_10_20",
1392 "test_float_BoolTest_gt_variable_results", "test_double_BoolTest_gt_variable_results"})
1393 public void runTests() {
1394 int err = 0;
1395
1396 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1397 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1398 float x = TestFPComparison2.FLOATS[i];
1399 float y = TestFPComparison2.FLOATS[j];
1400 float actual = test_float_BoolTest_gt_fixed_1_0(x, y);
1401 float expected = golden_float_BoolTest_gt_fixed_1_0(x, y);
1402 if (actual != expected) {
1403 System.out.println("Float failed (gt), x: " + x + ", y: " + y +
1404 ", actual: " + actual + ", expected: " + expected);
1405 err++;
1406 }
1407 }
1408 }
1409
1410 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1411 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1412 double x = TestFPComparison2.DOUBLES[i];
1413 double y = TestFPComparison2.DOUBLES[j];
1414 float actual = test_double_BoolTest_gt_fixed_1_0(x, y);
1415 float expected = golden_double_BoolTest_gt_fixed_1_0(x, y);
1416 if (actual != expected) {
1417 System.out.println("Double failed (gt), x: " + x + ", y: " + y +
1418 ", actual: " + actual + ", expected: " + expected);
1419 err++;
1420 }
1421 }
1422 }
1423
1424 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1425 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1426 float x = TestFPComparison2.FLOATS[i];
1427 float y = TestFPComparison2.FLOATS[j];
1428 float actual = test_float_BoolTest_gt_fixed_0_1(x, y);
1429 float expected = golden_float_BoolTest_gt_fixed_0_1(x, y);
1430 if (actual != expected) {
1431 System.out.println("Float failed (gt, 0, 1), x: " + x + ", y: " + y +
1432 ", actual: " + actual + ", expected: " + expected);
1433 err++;
1434 }
1435 }
1436 }
1437
1438 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1439 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1440 double x = TestFPComparison2.DOUBLES[i];
1441 double y = TestFPComparison2.DOUBLES[j];
1442 float actual = test_double_BoolTest_gt_fixed_0_1(x, y);
1443 float expected = golden_double_BoolTest_gt_fixed_0_1(x, y);
1444 if (actual != expected) {
1445 System.out.println("Double failed (gt, 0, 1), x: " + x + ", y: " + y +
1446 ", actual: " + actual + ", expected: " + expected);
1447 err++;
1448 }
1449 }
1450 }
1451
1452 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1453 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1454 float x = TestFPComparison2.FLOATS[i];
1455 float y = TestFPComparison2.FLOATS[j];
1456 float actual = test_float_BoolTest_gt_fixed_10_20(x, y);
1457 float expected = golden_float_BoolTest_gt_fixed_10_20(x, y);
1458 if (actual != expected) {
1459 System.out.println("Float failed (gt, 10, 20), x: " + x + ", y: " + y +
1460 ", actual: " + actual + ", expected: " + expected);
1461 err++;
1462 }
1463 }
1464 }
1465
1466 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1467 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1468 double x = TestFPComparison2.DOUBLES[i];
1469 double y = TestFPComparison2.DOUBLES[j];
1470 float actual = test_double_BoolTest_gt_fixed_10_20(x, y);
1471 float expected = golden_double_BoolTest_gt_fixed_10_20(x, y);
1472 if (actual != expected) {
1473 System.out.println("Double failed (gt, 10, 20), x: " + x + ", y: " + y +
1474 ", actual: " + actual + ", expected: " + expected);
1475 err++;
1476 }
1477 }
1478 }
1479
1480 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1481 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1482 float x = TestFPComparison2.FLOATS[i];
1483 float y = TestFPComparison2.FLOATS[j];
1484 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1485 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1486 float a = TestFPComparison2.FLOATS[m];
1487 float b = TestFPComparison2.FLOATS[n];
1488 float actual = test_float_BoolTest_gt_variable_results(x, y, a, b);
1489 float expected = golden_float_BoolTest_gt_variable_results(x, y, a, b);
1490 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1491 System.out.println("Float failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1492 ", actual: " + actual + ", expected: " + expected);
1493 err++;
1494 }
1495 }
1496 }
1497 }
1498 }
1499
1500 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1501 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1502 double x = TestFPComparison2.DOUBLES[i];
1503 double y = TestFPComparison2.DOUBLES[j];
1504 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1505 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1506 float a = TestFPComparison2.FLOATS[m];
1507 float b = TestFPComparison2.FLOATS[n];
1508 float actual = test_double_BoolTest_gt_variable_results(x, y, a, b);
1509 float expected = golden_double_BoolTest_gt_variable_results(x, y, a, b);
1510 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1511 System.out.println("Double failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1512 ", actual: " + actual + ", expected: " + expected);
1513 err++;
1514 }
1515 }
1516 }
1517 }
1518 }
1519
1520 if (err != 0) {
1521 throw new RuntimeException("Some tests failed");
1522 }
1523 }
1524 }
1525
1526 class Test_gt_2 {
1527 @Test
1528 @IR(counts = {IRNode.CMOVE_I, "1"},
1529 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1530 public static int test_float_BoolTest_gt_fixed_1_0(float x, float y) {
1531 // return 1
1532 // when either x or y is NaN
1533 // when neither is NaN, and x <= y
1534 // return 0
1535 // when neither is NaN, and x > y
1536 return !(x > y) ? 1 : 0;
1537 }
1538 @DontCompile
1539 public static int golden_float_BoolTest_gt_fixed_1_0(float x, float y) {
1540 return !(x > y) ? 1 : 0;
1541 }
1542
1543 @Test
1544 @IR(counts = {IRNode.CMOVE_I, "1"},
1545 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1546 public static int test_double_BoolTest_gt_fixed_1_0(double x, double y) {
1547 // return 1
1548 // when either x or y is NaN
1549 // when neither is NaN, and x <= y
1550 // return 0
1551 // when neither is NaN, and x > y
1552 return !(x > y) ? 1 : 0;
1553 }
1554 @DontCompile
1555 public static int golden_double_BoolTest_gt_fixed_1_0(double x, double y) {
1556 return !(x > y) ? 1 : 0;
1557 }
1558
1559 @Test
1560 @IR(counts = {IRNode.CMOVE_I, "1"},
1561 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1562 public static int test_float_BoolTest_gt_fixed_0_1(float x, float y) {
1563 return !(x > y) ? 0 : 1;
1564 }
1565 @DontCompile
1566 public static int golden_float_BoolTest_gt_fixed_0_1(float x, float y) {
1567 return !(x > y) ? 0 : 1;
1568 }
1569
1570 @Test
1571 @IR(counts = {IRNode.CMOVE_I, "1"},
1572 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1573 public static int test_double_BoolTest_gt_fixed_0_1(double x, double y) {
1574 return !(x > y) ? 0 : 1;
1575 }
1576 @DontCompile
1577 public static int golden_double_BoolTest_gt_fixed_0_1(double x, double y) {
1578 return !(x > y) ? 0 : 1;
1579 }
1580
1581 @Test
1582 @IR(counts = {IRNode.CMOVE_I, "1"},
1583 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1584 public static int test_float_BoolTest_gt_fixed_10_20(float x, float y) {
1585 return !(x > y) ? 10 : 20;
1586 }
1587 @DontCompile
1588 public static int golden_float_BoolTest_gt_fixed_10_20(float x, float y) {
1589 return !(x > y) ? 10 : 20;
1590 }
1591
1592 @Test
1593 @IR(counts = {IRNode.CMOVE_I, "1"},
1594 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1595 public static int test_double_BoolTest_gt_fixed_10_20(double x, double y) {
1596 return !(x > y) ? 10 : 20;
1597 }
1598 @DontCompile
1599 public static int golden_double_BoolTest_gt_fixed_10_20(double x, double y) {
1600 return !(x > y) ? 10 : 20;
1601 }
1602
1603 @Test
1604 @IR(counts = {IRNode.CMOVE_I, "1"},
1605 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1606 public static int test_float_BoolTest_gt_variable_results(float x, float y, int a, int b) {
1607 return !(x > y) ? a : b;
1608 }
1609 @DontCompile
1610 public static int golden_float_BoolTest_gt_variable_results(float x, float y, int a, int b) {
1611 return !(x > y) ? a : b;
1612 }
1613
1614 @Test
1615 @IR(counts = {IRNode.CMOVE_I, "1"},
1616 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1617 public static int test_double_BoolTest_gt_variable_results(double x, double y, int a, int b) {
1618 return !(x > y) ? a : b;
1619 }
1620 @DontCompile
1621 public static int golden_double_BoolTest_gt_variable_results(double x, double y, int a, int b) {
1622 return !(x > y) ? a : b;
1623 }
1624
1625 @Run(test = {"test_float_BoolTest_gt_fixed_1_0", "test_double_BoolTest_gt_fixed_1_0",
1626 "test_float_BoolTest_gt_fixed_0_1", "test_double_BoolTest_gt_fixed_0_1",
1627 "test_float_BoolTest_gt_fixed_10_20", "test_double_BoolTest_gt_fixed_10_20",
1628 "test_float_BoolTest_gt_variable_results", "test_double_BoolTest_gt_variable_results"})
1629 public void runTests() {
1630 int err = 0;
1631
1632 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1633 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1634 float x = TestFPComparison2.FLOATS[i];
1635 float y = TestFPComparison2.FLOATS[j];
1636 int actual = test_float_BoolTest_gt_fixed_1_0(x, y);
1637 int expected = golden_float_BoolTest_gt_fixed_1_0(x, y);
1638 if (actual != expected) {
1639 System.out.println("Float failed (gt), x: " + x + ", y: " + y +
1640 ", actual: " + actual + ", expected: " + expected);
1641 err++;
1642 }
1643 }
1644 }
1645
1646 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1647 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1648 double x = TestFPComparison2.DOUBLES[i];
1649 double y = TestFPComparison2.DOUBLES[j];
1650 int actual = test_double_BoolTest_gt_fixed_1_0(x, y);
1651 int expected = golden_double_BoolTest_gt_fixed_1_0(x, y);
1652 if (actual != expected) {
1653 System.out.println("Double failed (gt), x: " + x + ", y: " + y +
1654 ", actual: " + actual + ", expected: " + expected);
1655 err++;
1656 }
1657 }
1658 }
1659
1660 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1661 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1662 float x = TestFPComparison2.FLOATS[i];
1663 float y = TestFPComparison2.FLOATS[j];
1664 int actual = test_float_BoolTest_gt_fixed_0_1(x, y);
1665 int expected = golden_float_BoolTest_gt_fixed_0_1(x, y);
1666 if (actual != expected) {
1667 System.out.println("Float failed (gt, 0, 1), x: " + x + ", y: " + y +
1668 ", actual: " + actual + ", expected: " + expected);
1669 err++;
1670 }
1671 }
1672 }
1673
1674 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1675 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1676 double x = TestFPComparison2.DOUBLES[i];
1677 double y = TestFPComparison2.DOUBLES[j];
1678 int actual = test_double_BoolTest_gt_fixed_0_1(x, y);
1679 int expected = golden_double_BoolTest_gt_fixed_0_1(x, y);
1680 if (actual != expected) {
1681 System.out.println("Double failed (gt, 0, 1), x: " + x + ", y: " + y +
1682 ", actual: " + actual + ", expected: " + expected);
1683 err++;
1684 }
1685 }
1686 }
1687
1688 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1689 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1690 float x = TestFPComparison2.FLOATS[i];
1691 float y = TestFPComparison2.FLOATS[j];
1692 int actual = test_float_BoolTest_gt_fixed_10_20(x, y);
1693 int expected = golden_float_BoolTest_gt_fixed_10_20(x, y);
1694 if (actual != expected) {
1695 System.out.println("Float failed (gt, 10, 20), x: " + x + ", y: " + y +
1696 ", actual: " + actual + ", expected: " + expected);
1697 err++;
1698 }
1699 }
1700 }
1701
1702 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1703 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1704 double x = TestFPComparison2.DOUBLES[i];
1705 double y = TestFPComparison2.DOUBLES[j];
1706 int actual = test_double_BoolTest_gt_fixed_10_20(x, y);
1707 int expected = golden_double_BoolTest_gt_fixed_10_20(x, y);
1708 if (actual != expected) {
1709 System.out.println("Double failed (gt, 10, 20), x: " + x + ", y: " + y +
1710 ", actual: " + actual + ", expected: " + expected);
1711 err++;
1712 }
1713 }
1714 }
1715
1716 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1717 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1718 float x = TestFPComparison2.FLOATS[i];
1719 float y = TestFPComparison2.FLOATS[j];
1720 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
1721 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
1722 int a = TestFPComparison2.INTS[m];
1723 int b = TestFPComparison2.INTS[n];
1724 int actual = test_float_BoolTest_gt_variable_results(x, y, a, b);
1725 int expected = golden_float_BoolTest_gt_variable_results(x, y, a, b);
1726 if (actual != expected) {
1727 System.out.println("Float failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1728 ", actual: " + actual + ", expected: " + expected);
1729 err++;
1730 }
1731 }
1732 }
1733 }
1734 }
1735
1736 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1737 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1738 double x = TestFPComparison2.DOUBLES[i];
1739 double y = TestFPComparison2.DOUBLES[j];
1740 for (int m = 0; m < TestFPComparison2.INTS.length; m++) {
1741 for (int n = 0; n < TestFPComparison2.INTS.length; n++) {
1742 int a = TestFPComparison2.INTS[m];
1743 int b = TestFPComparison2.INTS[n];
1744 int actual = test_double_BoolTest_gt_variable_results(x, y, a, b);
1745 int expected = golden_double_BoolTest_gt_variable_results(x, y, a, b);
1746 if (actual != expected) {
1747 System.out.println("Double failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1748 ", actual: " + actual + ", expected: " + expected);
1749 err++;
1750 }
1751 }
1752 }
1753 }
1754 }
1755
1756 if (err != 0) {
1757 throw new RuntimeException("Some tests failed");
1758 }
1759 }
1760 }
1761
1762 class Test_gt_cmove_fp_2 {
1763 @Test
1764 @IR(counts = {IRNode.CMOVE_F, "1"},
1765 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1766 public static float test_float_BoolTest_gt_fixed_1_0(float x, float y) {
1767 // return 1
1768 // when either x or y is NaN
1769 // when neither is NaN, and x <= y
1770 // return 0
1771 // when neither is NaN, and x > y
1772 return !(x > y) ? 1.0f : 0.0f;
1773 }
1774 @DontCompile
1775 public static float golden_float_BoolTest_gt_fixed_1_0(float x, float y) {
1776 return !(x > y) ? 1.0f : 0.0f;
1777 }
1778
1779 @Test
1780 @IR(counts = {IRNode.CMOVE_F, "1"},
1781 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1782 public static float test_double_BoolTest_gt_fixed_1_0(double x, double y) {
1783 // return 1
1784 // when either x or y is NaN
1785 // when neither is NaN, and x <= y
1786 // return 0
1787 // when neither is NaN, and x > y
1788 return !(x > y) ? 1.0f : 0.0f;
1789 }
1790 @DontCompile
1791 public static float golden_double_BoolTest_gt_fixed_1_0(double x, double y) {
1792 return !(x > y) ? 1.0f : 0.0f;
1793 }
1794
1795 @Test
1796 @IR(counts = {IRNode.CMOVE_F, "1"},
1797 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1798 public static float test_float_BoolTest_gt_fixed_0_1(float x, float y) {
1799 return !(x > y) ? 0.0f : 1.0f;
1800 }
1801 @DontCompile
1802 public static float golden_float_BoolTest_gt_fixed_0_1(float x, float y) {
1803 return !(x > y) ? 0.0f : 1.0f;
1804 }
1805
1806 @Test
1807 @IR(counts = {IRNode.CMOVE_F, "1"},
1808 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1809 public static float test_double_BoolTest_gt_fixed_0_1(double x, double y) {
1810 return !(x > y) ? 0.0f : 1.0f;
1811 }
1812 @DontCompile
1813 public static float golden_double_BoolTest_gt_fixed_0_1(double x, double y) {
1814 return !(x > y) ? 0.0f : 1.0f;
1815 }
1816
1817 @Test
1818 @IR(counts = {IRNode.CMOVE_F, "1"},
1819 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1820 public static float test_float_BoolTest_gt_fixed_10_20(float x, float y) {
1821 return !(x > y) ? 10.0f : 20.0f;
1822 }
1823 @DontCompile
1824 public static float golden_float_BoolTest_gt_fixed_10_20(float x, float y) {
1825 return !(x > y) ? 10.0f : 20.0f;
1826 }
1827
1828 @Test
1829 @IR(counts = {IRNode.CMOVE_F, "1"},
1830 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1831 public static float test_double_BoolTest_gt_fixed_10_20(double x, double y) {
1832 return !(x > y) ? 10.0f : 20.0f;
1833 }
1834 @DontCompile
1835 public static float golden_double_BoolTest_gt_fixed_10_20(double x, double y) {
1836 return !(x > y) ? 10.0f : 20.0f;
1837 }
1838
1839 @Test
1840 @IR(counts = {IRNode.CMOVE_F, "1"},
1841 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1842 public static float test_float_BoolTest_gt_variable_results(float x, float y, float a, float b) {
1843 return !(x > y) ? a : b;
1844 }
1845 @DontCompile
1846 public static float golden_float_BoolTest_gt_variable_results(float x, float y, float a, float b) {
1847 return !(x > y) ? a : b;
1848 }
1849
1850 @Test
1851 @IR(counts = {IRNode.CMOVE_F, "1"},
1852 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
1853 public static float test_double_BoolTest_gt_variable_results(double x, double y, float a, float b) {
1854 return !(x > y) ? a : b;
1855 }
1856 @DontCompile
1857 public static float golden_double_BoolTest_gt_variable_results(double x, double y, float a, float b) {
1858 return !(x > y) ? a : b;
1859 }
1860
1861 @Run(test = {"test_float_BoolTest_gt_fixed_1_0", "test_double_BoolTest_gt_fixed_1_0",
1862 "test_float_BoolTest_gt_fixed_0_1", "test_double_BoolTest_gt_fixed_0_1",
1863 "test_float_BoolTest_gt_fixed_10_20", "test_double_BoolTest_gt_fixed_10_20",
1864 "test_float_BoolTest_gt_variable_results", "test_double_BoolTest_gt_variable_results"})
1865 public void runTests() {
1866 int err = 0;
1867
1868 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1869 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1870 float x = TestFPComparison2.FLOATS[i];
1871 float y = TestFPComparison2.FLOATS[j];
1872 float actual = test_float_BoolTest_gt_fixed_1_0(x, y);
1873 float expected = golden_float_BoolTest_gt_fixed_1_0(x, y);
1874 if (actual != expected) {
1875 System.out.println("Float failed (gt), x: " + x + ", y: " + y +
1876 ", actual: " + actual + ", expected: " + expected);
1877 err++;
1878 }
1879 }
1880 }
1881
1882 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1883 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1884 double x = TestFPComparison2.DOUBLES[i];
1885 double y = TestFPComparison2.DOUBLES[j];
1886 float actual = test_double_BoolTest_gt_fixed_1_0(x, y);
1887 float expected = golden_double_BoolTest_gt_fixed_1_0(x, y);
1888 if (actual != expected) {
1889 System.out.println("Double failed (gt), x: " + x + ", y: " + y +
1890 ", actual: " + actual + ", expected: " + expected);
1891 err++;
1892 }
1893 }
1894 }
1895
1896 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1897 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1898 float x = TestFPComparison2.FLOATS[i];
1899 float y = TestFPComparison2.FLOATS[j];
1900 float actual = test_float_BoolTest_gt_fixed_0_1(x, y);
1901 float expected = golden_float_BoolTest_gt_fixed_0_1(x, y);
1902 if (actual != expected) {
1903 System.out.println("Float failed (gt, 0, 1), x: " + x + ", y: " + y +
1904 ", actual: " + actual + ", expected: " + expected);
1905 err++;
1906 }
1907 }
1908 }
1909
1910 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1911 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1912 double x = TestFPComparison2.DOUBLES[i];
1913 double y = TestFPComparison2.DOUBLES[j];
1914 float actual = test_double_BoolTest_gt_fixed_0_1(x, y);
1915 float expected = golden_double_BoolTest_gt_fixed_0_1(x, y);
1916 if (actual != expected) {
1917 System.out.println("Double failed (gt, 0, 1), x: " + x + ", y: " + y +
1918 ", actual: " + actual + ", expected: " + expected);
1919 err++;
1920 }
1921 }
1922 }
1923
1924 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1925 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1926 float x = TestFPComparison2.FLOATS[i];
1927 float y = TestFPComparison2.FLOATS[j];
1928 float actual = test_float_BoolTest_gt_fixed_10_20(x, y);
1929 float expected = golden_float_BoolTest_gt_fixed_10_20(x, y);
1930 if (actual != expected) {
1931 System.out.println("Float failed (gt, 10, 20), x: " + x + ", y: " + y +
1932 ", actual: " + actual + ", expected: " + expected);
1933 err++;
1934 }
1935 }
1936 }
1937
1938 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1939 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1940 double x = TestFPComparison2.DOUBLES[i];
1941 double y = TestFPComparison2.DOUBLES[j];
1942 float actual = test_double_BoolTest_gt_fixed_10_20(x, y);
1943 float expected = golden_double_BoolTest_gt_fixed_10_20(x, y);
1944 if (actual != expected) {
1945 System.out.println("Double failed (gt, 10, 20), x: " + x + ", y: " + y +
1946 ", actual: " + actual + ", expected: " + expected);
1947 err++;
1948 }
1949 }
1950 }
1951
1952 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
1953 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
1954 float x = TestFPComparison2.FLOATS[i];
1955 float y = TestFPComparison2.FLOATS[j];
1956 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1957 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1958 float a = TestFPComparison2.FLOATS[m];
1959 float b = TestFPComparison2.FLOATS[n];
1960 float actual = test_float_BoolTest_gt_variable_results(x, y, a, b);
1961 float expected = golden_float_BoolTest_gt_variable_results(x, y, a, b);
1962 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1963 System.out.println("Float failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1964 ", actual: " + actual + ", expected: " + expected);
1965 err++;
1966 }
1967 }
1968 }
1969 }
1970 }
1971
1972 for (int i = 0; i < TestFPComparison2.DOUBLES.length; i++) {
1973 for (int j = 0; j < TestFPComparison2.DOUBLES.length; j++) {
1974 double x = TestFPComparison2.DOUBLES[i];
1975 double y = TestFPComparison2.DOUBLES[j];
1976 for (int m = 0; m < TestFPComparison2.FLOATS.length; m++) {
1977 for (int n = 0; n < TestFPComparison2.FLOATS.length; n++) {
1978 float a = TestFPComparison2.FLOATS[m];
1979 float b = TestFPComparison2.FLOATS[n];
1980 float actual = test_double_BoolTest_gt_variable_results(x, y, a, b);
1981 float expected = golden_double_BoolTest_gt_variable_results(x, y, a, b);
1982 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
1983 System.out.println("Double failed (gt), x: " + x + ", y: " + y + ", a: " + a + ", b: " + b +
1984 ", actual: " + actual + ", expected: " + expected);
1985 err++;
1986 }
1987 }
1988 }
1989 }
1990 }
1991
1992 if (err != 0) {
1993 throw new RuntimeException("Some tests failed");
1994 }
1995 }
1996 }
1997
1998 class Test_cmov_fp_cmp_fp_ge_3 {
1999 @Test
2000 @IR(counts = {IRNode.CMOVE_F, "1"},
2001 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2002 public static float test_float_BoolTest_gt_x_lt_0(float x) {
2003 return x < 0 ? 0 : x;
2004 }
2005 @DontCompile
2006 public static float golden_float_BoolTest_gt_x_lt_0(float x) {
2007 return x < 0 ? 0 : x;
2008 }
2009
2010 @Test
2011 @IR(counts = {IRNode.CMOVE_F, "1"},
2012 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2013 public static float test_float_BoolTest_gt_x_gt_0(float x) {
2014 return x > 0 ? 0 : x;
2015 }
2016 @DontCompile
2017 public static float golden_float_BoolTest_gt_x_gt_0(float x) {
2018 return x > 0 ? 0 : x;
2019 }
2020
2021 @Test
2022 @IR(counts = {IRNode.CMOVE_F, "1"},
2023 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2024 public static float test_float_BoolTest_gt_neg_x_lt_0(float x) {
2025 return !(x < 0) ? 0 : x;
2026 }
2027 @DontCompile
2028 public static float golden_float_BoolTest_gt_neg_x_lt_0(float x) {
2029 return !(x < 0) ? 0 : x;
2030 }
2031
2032 @Test
2033 @IR(counts = {IRNode.CMOVE_F, "1"},
2034 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2035 public static float test_float_BoolTest_gt_neg_x_gt_0(float x) {
2036 return !(x > 0) ? 0 : x;
2037 }
2038 @DontCompile
2039 public static float golden_float_BoolTest_gt_neg_x_gt_0(float x) {
2040 return !(x > 0) ? 0 : x;
2041 }
2042
2043 @Run(test = {"test_float_BoolTest_gt_x_lt_0", "test_float_BoolTest_gt_x_gt_0",
2044 "test_float_BoolTest_gt_neg_x_lt_0", "test_float_BoolTest_gt_neg_x_gt_0",})
2045 public void runTests() {
2046 int err = 0;
2047
2048 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2049 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2050 float x = TestFPComparison2.FLOATS[i];
2051 float actual = test_float_BoolTest_gt_x_lt_0(x);
2052 float expected = golden_float_BoolTest_gt_x_lt_0(x);
2053 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2054 System.out.println("Float failed (lt, x, 0), x: " + x +
2055 ", actual: " + actual + ", expected: " + expected);
2056 err++;
2057 }
2058 }
2059 }
2060
2061 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2062 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2063 float x = TestFPComparison2.FLOATS[i];
2064 float actual = test_float_BoolTest_gt_x_gt_0(x);
2065 float expected = golden_float_BoolTest_gt_x_gt_0(x);
2066 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2067 System.out.println("Float failed (gt, x, 0), x: " + x +
2068 ", actual: " + actual + ", expected: " + expected);
2069 err++;
2070 }
2071 }
2072 }
2073
2074 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2075 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2076 float x = TestFPComparison2.FLOATS[i];
2077 float actual = test_float_BoolTest_gt_neg_x_lt_0(x);
2078 float expected = golden_float_BoolTest_gt_neg_x_lt_0(x);
2079 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2080 System.out.println("Float failed (neg lt, x, 0), x: " + x +
2081 ", actual: " + actual + ", expected: " + expected);
2082 err++;
2083 }
2084 }
2085 }
2086
2087 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2088 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2089 float x = TestFPComparison2.FLOATS[i];
2090 float actual = test_float_BoolTest_gt_neg_x_gt_0(x);
2091 float expected = golden_float_BoolTest_gt_neg_x_gt_0(x);
2092 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2093 System.out.println("Float failed (neg gt, x, 0), x: " + x +
2094 ", actual: " + actual + ", expected: " + expected);
2095 err++;
2096 }
2097 }
2098 }
2099
2100 if (err != 0) {
2101 throw new RuntimeException("Some tests failed");
2102 }
2103 }
2104 }
2105
2106 class Test_cmov_fp_cmp_fp_ge_4 {
2107 @Test
2108 @IR(counts = {IRNode.CMOVE_F, "1"},
2109 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2110 public static float test_float_BoolTest_ge_x_le_0(float x) {
2111 return x <= 0 ? 0 : x;
2112 }
2113 @DontCompile
2114 public static float golden_float_BoolTest_ge_x_le_0(float x) {
2115 return x <= 0 ? 0 : x;
2116 }
2117
2118 @Test
2119 @IR(counts = {IRNode.CMOVE_F, "1"},
2120 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2121 public static float test_float_BoolTest_ge_x_ge_0(float x) {
2122 return x >= 0 ? 0 : x;
2123 }
2124 @DontCompile
2125 public static float golden_float_BoolTest_ge_x_ge_0(float x) {
2126 return x >= 0 ? 0 : x;
2127 }
2128
2129 @Test
2130 @IR(counts = {IRNode.CMOVE_F, "1"},
2131 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2132 public static float test_float_BoolTest_ge_neg_x_le_0(float x) {
2133 return !(x <= 0) ? 0 : x;
2134 }
2135 @DontCompile
2136 public static float golden_float_BoolTest_ge_neg_x_le_0(float x) {
2137 return !(x <= 0) ? 0 : x;
2138 }
2139
2140 @Test
2141 @IR(counts = {IRNode.CMOVE_F, "1"},
2142 applyIfPlatformOr = {"riscv64", "true", "aarch64", "true"})
2143 public static float test_float_BoolTest_ge_neg_x_ge_0(float x) {
2144 return !(x >= 0) ? 0 : x;
2145 }
2146 @DontCompile
2147 public static float golden_float_BoolTest_ge_neg_x_ge_0(float x) {
2148 return !(x >= 0) ? 0 : x;
2149 }
2150
2151 @Run(test = {"test_float_BoolTest_ge_x_le_0", "test_float_BoolTest_ge_x_ge_0",
2152 "test_float_BoolTest_ge_neg_x_le_0", "test_float_BoolTest_ge_neg_x_ge_0",})
2153 public void runTests() {
2154 int err = 0;
2155
2156 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2157 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2158 float x = TestFPComparison2.FLOATS[i];
2159 float actual = test_float_BoolTest_ge_x_le_0(x);
2160 float expected = golden_float_BoolTest_ge_x_le_0(x);
2161 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2162 System.out.println("Float failed (le, x, 0), x: " + x +
2163 ", actual: " + actual + ", expected: " + expected);
2164 err++;
2165 }
2166 }
2167 }
2168
2169 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2170 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2171 float x = TestFPComparison2.FLOATS[i];
2172 float actual = test_float_BoolTest_ge_x_ge_0(x);
2173 float expected = golden_float_BoolTest_ge_x_ge_0(x);
2174 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2175 System.out.println("Float failed (ge, x, 0), x: " + x +
2176 ", actual: " + actual + ", expected: " + expected);
2177 err++;
2178 }
2179 }
2180 }
2181
2182 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2183 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2184 float x = TestFPComparison2.FLOATS[i];
2185 float actual = test_float_BoolTest_ge_neg_x_le_0(x);
2186 float expected = golden_float_BoolTest_ge_neg_x_le_0(x);
2187 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2188 System.out.println("Float failed (neg le, x, 0), x: " + x +
2189 ", actual: " + actual + ", expected: " + expected);
2190 err++;
2191 }
2192 }
2193 }
2194
2195 for (int i = 0; i < TestFPComparison2.FLOATS.length; i++) {
2196 for (int j = 0; j < TestFPComparison2.FLOATS.length; j++) {
2197 float x = TestFPComparison2.FLOATS[i];
2198 float actual = test_float_BoolTest_ge_neg_x_ge_0(x);
2199 float expected = golden_float_BoolTest_ge_neg_x_ge_0(x);
2200 if (actual != expected && (!Float.isNaN(actual) || !Float.isNaN(expected))) {
2201 System.out.println("Float failed (neg ge, x, 0), x: " + x +
2202 ", actual: " + actual + ", expected: " + expected);
2203 err++;
2204 }
2205 }
2206 }
2207
2208 if (err != 0) {
2209 throw new RuntimeException("Some tests failed");
2210 }
2211 }
2212 }