RFR: 8369002: Extract the loop->is_member(get_loop(get_ctrl(node))) pattern in a new function
Benoît Maillard
bmaillard at openjdk.org
Wed Nov 12 09:40:05 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
Looks good to me, thanks for making the change @anton-seoane! I would just change the return type, see my comments.
src/hotspot/share/opto/loopnode.hpp line 1389:
> 1387:
> 1388: // Is 'n' a (nested) member of 'loop'?
> 1389: int is_member( const IdealLoopTree *loop, Node *n ) const {
Let's change this one as well while we're at it
Suggestion:
bool is_member( const IdealLoopTree *loop, Node *n ) const {
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) {
We should take advantage of the opportunity to make the return type consistent with the other variation (`bool is_member(const IdealLoopTree *l)`)
Suggestion:
bool ctrl_is_member(const IdealLoopTree *loop, Node *n) {
-------------
PR Review: https://git.openjdk.org/jdk/pull/28259#pullrequestreview-3452473070
PR Review Comment: https://git.openjdk.org/jdk/pull/28259#discussion_r2517579412
PR Review Comment: https://git.openjdk.org/jdk/pull/28259#discussion_r2517578812
More information about the hotspot-compiler-dev
mailing list