3030
3131/*
3232 * @test
33- * @bug 8324655 8329797
33+ * @bug 8324655 8329797 8331090
3434 * @key randomness
3535 * @summary Test that if expressions are properly folded into min/max nodes
3636 * @requires os.arch != "riscv64"
@@ -505,7 +505,27 @@ public void checkTestMinLongVector(Object[] vals) {
505505 }
506506 }
507507
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" })
509529 public void runTestIntegers () {
510530 testIntegers (10 , 20 );
511531 testIntegers (20 , 10 );
@@ -526,9 +546,12 @@ public void testIntegers(int a, int b) {
526546 Asserts .assertEQ (a >= b ? b : a , testMinI2E (a , b ));
527547 Asserts .assertEQ (a >= b ? a : b , testMaxI1E (a , b ));
528548 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 ));
529552 }
530553
531- @ Run (test = { "testMinL1" , "testMinL2" , "testMaxL1" , "testMaxL2" , "testMinL1E" , "testMinL2E" , "testMaxL1E" , "testMaxL2E" })
554+ @ Run (test = { "testMinL1" , "testMinL2" , "testMaxL1" , "testMaxL2" , "testMinL1E" , "testMinL2E" , "testMaxL1E" , "testMaxL2E" , "testMinLConst" })
532555 public void runTestLongs () {
533556 testLongs (10 , 20 );
534557 testLongs (20 , 10 );
@@ -551,5 +574,8 @@ public void testLongs(long a, long b) {
551574 Asserts .assertEQ (a >= b ? b : a , testMinL2E (a , b ));
552575 Asserts .assertEQ (a >= b ? a : b , testMaxL1E (a , b ));
553576 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 ));
554580 }
555581}
0 commit comments