Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed Apr 25, 2024
1 parent fc74c9e commit 30f626b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/hotspot/share/opto/loopTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,11 +1201,12 @@ bool IdealLoopTree::policy_range_check(PhaseIdealLoop* phase, bool provisional,

// Comparing trip+off vs limit
Node *bol = iff->in(1);
if (bol->req() != 2) {
if (bol->req() < 2) {
continue; // dead constant test
}
if (!bol->is_Bool()) {
assert(bol->is_OpaqueInitializedAssertionPredicate(), "Initialized Assertion Predicate check only");
assert(bol->is_Opaque4() || bol->is_OpaqueInitializedAssertionPredicate(),
"Opaque node of non-null-check or of Initialized Assertion Predicate");
continue;
}
if (bol->as_Bool()->_test._test == BoolTest::ne) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static void main(String[] args) {
testCloneDown();
testOnlyCloneDownCmp();
testCloneDownInsideLoop();
testPolicyRangeCheck();
maybeNull(null); // Make sure return value is sometimes null.
testPolicyRangeCheck(a);
testUnsafeAccess(a);
testOpaqueOutsideLoop();
testOpaqueInsideIfOutsideLoop();
Expand Down Expand Up @@ -260,7 +260,7 @@ static void testCloneDownInsideLoop() {
}
}

static void testPolicyRangeCheck() {
static void testPolicyRangeCheck(Object o) {
int two = 100;
int limit = 2;
for (; limit < 4; limit *= 2);
Expand All @@ -269,11 +269,16 @@ static void testPolicyRangeCheck() {
}

// 4) We call IdealLoopTree::policy_range_check() for this loop:
// Initialized Assertion Predicate is now part of loop body and we also check
// if it could be eliminated with Range Check Elimination. We thus need to
// exclude Ifs with OpaqueInitializedAssertionPredicate in policy_range_check().
// - Initialized Assertion Predicate is now part of loop body.
// - Opaque4 node for null-check is also part of loop body.
// We also check the If nodes for these Opaque nodes could be eliminated with
// Range Check Elimination. We thus need to exclude Ifs with
// Opaque4 and OpaqueInitializedAssertionPredicate nodes in policy_range_check().
for (int i = 0; i < 100; i++) {
// 1) Apply Loop Predication: Loop Predicate + Temlate Assertion Predicate
A a = maybeNull(o); // Profiling tells us that return value *might* be null.
iFld = UNSAFE.getInt(a, OFFSET); // Emits If with Opaque4Node for null check.

// 1) Apply Loop Predication: Loop Predicate + Template Assertion Predicate
// 2) Apply Loop Peeling: Create Initialized Assertion Predicate with
// OpaqueInitializedAssertionPredicate
// 3) After CCP: C2 knows that two == 2. CountedLoopEnd found to be true
Expand Down

0 comments on commit 30f626b

Please sign in to comment.