From 5a6eaad87826041554d38aaffaf08d47b3e10a25 Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Thu, 16 Nov 2023 10:36:34 +0100 Subject: [PATCH] Fix using wrong predicate iterator and add test for it. Additionally add more test run configurations including all tests --- src/hotspot/share/opto/predicates.cpp | 5 +- .../predicates/TestAssertionPredicates.java | 88 ++++++++++++++++--- 2 files changed, 81 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index e84cb35e5aa5f..9c54947eb71bf 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -868,8 +868,9 @@ void PredicateBlock::verify_block() { // anymore (i.e. entry to the first Regular Predicate in this block if any or `regular_predicate_proj` otherwise). Node* PredicateBlock::skip_regular_predicates(Node* regular_predicate_proj, Deoptimization::DeoptReason deopt_reason) { PredicateVisitor do_nothing_visitor; - PredicateInBlockIterator predicate_in_block_iterator(regular_predicate_proj, deopt_reason, &do_nothing_visitor); - return predicate_in_block_iterator.for_each(); + RegularPredicateInBlockIterator regular_predicate_in_block_iterator(regular_predicate_proj, deopt_reason, + &do_nothing_visitor); + return regular_predicate_in_block_iterator.for_each(); } // Applies the PredicateVisitor to each Regular Predicate in this block. diff --git a/test/hotspot/jtreg/compiler/predicates/TestAssertionPredicates.java b/test/hotspot/jtreg/compiler/predicates/TestAssertionPredicates.java index bd83a4546a796..a359feeb58fec 100644 --- a/test/hotspot/jtreg/compiler/predicates/TestAssertionPredicates.java +++ b/test/hotspot/jtreg/compiler/predicates/TestAssertionPredicates.java @@ -43,6 +43,16 @@ * compiler.predicates.TestAssertionPredicates Xcomp */ +/* + * @test id=NoLoopPredication + * @bug 8288981 + * @requires vm.compiler2.enabled + * @run main/othervm -Xbatch -XX:-UseLoopPredicate + * -XX:CompileCommand=compileonly,compiler.predicates.TestAssertionPredicates::* + * -XX:CompileCommand=dontinline,compiler.predicates.TestAssertionPredicates::* + * compiler.predicates.TestAssertionPredicates NoLoopPredication + */ + /* * @test id=UseProfiledLoopPredicateFalse * @bug 8288981 @@ -105,6 +115,12 @@ * compiler.predicates.TestAssertionPredicates ZGCStressGCM */ +/* + * @test id=NoFlags + * @key randomness + * @bug 8288981 + * @run driver compiler.predicates.TestAssertionPredicates NoFlags + */ package compiler.predicates; @@ -136,15 +152,7 @@ static class Foo { public static void main(String[] args) { - try { - executeTests(args[0]); - } catch (ArrayIndexOutOfBoundsException e) { - // Expected - } - } - - static void executeTests(String methods) { - switch (methods) { + switch (args[0]) { case "NoProfiledLoopPredicate" -> testWithPartialPeelingFirst(); case "LoopMaxUnroll0" -> { testPeeling(); @@ -208,10 +216,59 @@ static void executeTests(String methods) { testDataUpdatePeelingUnrolling(); } } + case "NoLoopPredication", "NoFlags" -> { + for (int i = 0; i < 10000; i++) { + runAllTests(); + } + } default -> throw new RuntimeException("invalid methods"); } } + static void runAllTests() { + testPeeling(); + testUnswitchingThenPeeling(); + testPeelingThenUnswitchingThenPeeling(); + testPeelingThenUnswitchingThenPeelingThenPreMainPost(); + testDyingRuntimePredicate(); + testDyingNegatedRuntimePredicate(); + testPeelMainLoopAfterUnrollingThenPreMainPost(); + testPeelMainLoopAfterUnrolling2(); + testUnrolling8(); + testUnrolling16(); + testPreMainPost(); + testUnrolling2(); + testUnrolling4(); + testPeelingThenPreMainPost(); + testUnswitchingThenPeelingThenPreMainPost(); + runTestDontCloneParsePredicateUnswitching(); + testDyingInitializedAssertionPredicate(); + test8288981(); + test8288941(); + iFld = -1; + test8292507(); + test8307131(); + test8308392No1(); + iFld = -50000; + test8308392No2(); + test8308392No3(); + test8308392No4(); + test8308392No5(); + test8308392No6(); + test8308392No7(); + iFld = 0; + test8308392No8(); + runTest8308392No9(); + test8308392No10(); + testSplitIfCloneDownWithOpaqueAssertionPredicate(); + testHaltNotRemovingAssertionPredicate8305428(); + test8305428(); + testDataUpdateUnroll(); + testDataUpdateUnswitchUnroll(); + testDataUpdatePeelingUnrolling(); + testBackToBackLoopLimitCheckPredicate(); + } + static void runTestDontCloneParsePredicateUnswitching() { iFld = 0; try { @@ -1103,7 +1160,7 @@ static void test8308392No8() { static void runTest8308392No9() { try { test8308392No9(); - } catch (ArithmeticException e) { + } catch (ArithmeticException | ArrayIndexOutOfBoundsException e) { // Expected. } } @@ -1146,6 +1203,17 @@ static void testSplitIfCloneDownWithOpaqueAssertionPredicate() { long n = p; } + static void testBackToBackLoopLimitCheckPredicate() { + int i = 34; + if (flag) {} + while (i < 50) { + i++; + } + for (int j = 0; j < 4; j++) { + iArr[j] += 34; + } + } + static void dontInline() { }