From 30f626b558c5c09c3917766682d5b17748476bac Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Thu, 25 Apr 2024 16:16:03 +0200 Subject: [PATCH] Add more tests --- src/hotspot/share/opto/loopTransform.cpp | 5 +++-- ...OpaqueInitializedAssertionPredicateNode.java | 17 +++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 4db45d4168a7b..21c5037dced07 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -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) { diff --git a/test/hotspot/jtreg/compiler/predicates/assertion/TestOpaqueInitializedAssertionPredicateNode.java b/test/hotspot/jtreg/compiler/predicates/assertion/TestOpaqueInitializedAssertionPredicateNode.java index cb58803639a3e..8fb9e693eb6fe 100644 --- a/test/hotspot/jtreg/compiler/predicates/assertion/TestOpaqueInitializedAssertionPredicateNode.java +++ b/test/hotspot/jtreg/compiler/predicates/assertion/TestOpaqueInitializedAssertionPredicateNode.java @@ -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(); @@ -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); @@ -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