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