Skip to content

Commit

Permalink
Fix using wrong predicate iterator and add test for it. Additionally …
Browse files Browse the repository at this point in the history
…add more test run configurations including all tests
  • Loading branch information
chhagedorn committed Nov 23, 2023
1 parent 97dfebe commit 5a6eaad
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/hotspot/share/opto/predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
88 changes: 78 additions & 10 deletions test/hotspot/jtreg/compiler/predicates/TestAssertionPredicates.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -105,6 +115,12 @@
* compiler.predicates.TestAssertionPredicates ZGCStressGCM
*/

/*
* @test id=NoFlags
* @key randomness
* @bug 8288981
* @run driver compiler.predicates.TestAssertionPredicates NoFlags
*/

package compiler.predicates;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1103,7 +1160,7 @@ static void test8308392No8() {
static void runTest8308392No9() {
try {
test8308392No9();
} catch (ArithmeticException e) {
} catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
// Expected.
}
}
Expand Down Expand Up @@ -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() {
}

Expand Down

0 comments on commit 5a6eaad

Please sign in to comment.