30
30
31
31
/*
32
32
* @test
33
- * @bug 8324655 8329797
33
+ * @bug 8324655 8329797 8331090
34
34
* @key randomness
35
35
* @summary Test that if expressions are properly folded into min/max nodes
36
36
* @requires os.arch != "riscv64"
@@ -505,7 +505,27 @@ public void checkTestMinLongVector(Object[] vals) {
505
505
}
506
506
}
507
507
508
- @ Run (test = { "testMinI1" , "testMinI2" , "testMaxI1" , "testMaxI2" , "testMinI1E" , "testMinI2E" , "testMaxI1E" , "testMaxI2E" })
508
+ @ Test
509
+ @ IR (failOn = { IRNode .IF }, counts = { IRNode .MIN_I , "1" })
510
+ public int testMinIConst (int a ) {
511
+ if (a > 65535 ) {
512
+ a = 65535 ;
513
+ }
514
+
515
+ return a ;
516
+ }
517
+
518
+ @ Test
519
+ @ IR (phase = { CompilePhase .BEFORE_MACRO_EXPANSION }, failOn = { IRNode .IF }, counts = { IRNode .MIN_L , "1" })
520
+ public long testMinLConst (long a ) {
521
+ if (a > 65535 ) {
522
+ a = 65535 ;
523
+ }
524
+
525
+ return a ;
526
+ }
527
+
528
+ @ Run (test = { "testMinI1" , "testMinI2" , "testMaxI1" , "testMaxI2" , "testMinI1E" , "testMinI2E" , "testMaxI1E" , "testMaxI2E" , "testMinIConst" })
509
529
public void runTestIntegers () {
510
530
testIntegers (10 , 20 );
511
531
testIntegers (20 , 10 );
@@ -526,9 +546,12 @@ public void testIntegers(int a, int b) {
526
546
Asserts .assertEQ (a >= b ? b : a , testMinI2E (a , b ));
527
547
Asserts .assertEQ (a >= b ? a : b , testMaxI1E (a , b ));
528
548
Asserts .assertEQ (a <= b ? b : a , testMaxI2E (a , b ));
549
+
550
+ Asserts .assertEQ (a > 65535 ? 65535 : a , testMinIConst (a ));
551
+ Asserts .assertEQ (b > 65535 ? 65535 : b , testMinIConst (b ));
529
552
}
530
553
531
- @ Run (test = { "testMinL1" , "testMinL2" , "testMaxL1" , "testMaxL2" , "testMinL1E" , "testMinL2E" , "testMaxL1E" , "testMaxL2E" })
554
+ @ Run (test = { "testMinL1" , "testMinL2" , "testMaxL1" , "testMaxL2" , "testMinL1E" , "testMinL2E" , "testMaxL1E" , "testMaxL2E" , "testMinLConst" })
532
555
public void runTestLongs () {
533
556
testLongs (10 , 20 );
534
557
testLongs (20 , 10 );
@@ -551,5 +574,8 @@ public void testLongs(long a, long b) {
551
574
Asserts .assertEQ (a >= b ? b : a , testMinL2E (a , b ));
552
575
Asserts .assertEQ (a >= b ? a : b , testMaxL1E (a , b ));
553
576
Asserts .assertEQ (a <= b ? b : a , testMaxL2E (a , b ));
577
+
578
+ Asserts .assertEQ (a > 65535L ? 65535L : a , testMinLConst (a ));
579
+ Asserts .assertEQ (b > 65535L ? 65535L : b , testMinLConst (b ));
554
580
}
555
581
}
0 commit comments