RFR: 8369002: Extract the loop->is_member(get_loop(get_ctrl(node))) pattern in a new function

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Wed Nov 12 14:18:18 UTC 2025


On Wed, 12 Nov 2025 08:49:49 GMT, Anton Seoane Ampudia <aseoane at openjdk.org> wrote:

> This PR adds a "shorthand" for the common `loop->is_member(get_loop(get_ctrl(node)))` pattern in loop optimizations.
> 
> In PhaseIdealLoop, there is already an `is_member` function that checks if a node is a (nested) member of an IdealLoopTree. In a similar fashion, this changeset adds a `ctrl_is_member` that aims to simplify the common pattern of:
> 
> Node* node_ctrl = get_ctrl(node);
> if (loop->is_member(get_loop(node))) { ... }
> 
> 
> This hopes to provide a bit more readability and code conciseness in such a common operation.
> 
> **Testing:** passes tiers 1-3

Changes requested by rcastanedalo (Reviewer).

src/hotspot/share/opto/loopnode.hpp line 1394:

> 1392: 
> 1393:   // is the control for 'n' a (nested) member of 'loop'?
> 1394:   int ctrl_is_member(const IdealLoopTree *loop, Node *n) {

On top of @benoitmaillard's suggestion:

Suggestion:

  bool ctrl_is_member(const IdealLoopTree* loop, const Node* n) {


Adding the `const` qualifier requires propagating constness to `PhaseIdealLoop::is_member` and then transitively to `PhaseIdealLoop::get_loop()`, but I think it is worth doing it in this RFE if we are going to touch `PhaseIdealLoop::is_member` anyway.

src/hotspot/share/opto/loopnode.hpp line 1396:

> 1394:   int ctrl_is_member(const IdealLoopTree *loop, Node *n) {
> 1395:     Node* n_ctrl = get_ctrl(n);
> 1396:     return loop->is_member(get_loop(n_ctrl));

Suggestion:

    return is_member(loop, get_ctrl(n));

-------------

PR Review: https://git.openjdk.org/jdk/pull/28259#pullrequestreview-3453651928
PR Review Comment: https://git.openjdk.org/jdk/pull/28259#discussion_r2518477552
PR Review Comment: https://git.openjdk.org/jdk/pull/28259#discussion_r2518462925


More information about the hotspot-compiler-dev mailing list