RFR: 8349523: Unused runtime calls to drem/frem should be removed [v8]

Tobias Hartmann thartmann at openjdk.org
Mon Mar 3 07:05:00 UTC 2025


On Fri, 28 Feb 2025 16:04:31 GMT, Marc Chevalier <duke at openjdk.org> wrote:

>> Remove frem and drem macros nodes when the result is not used. These nodes have other outputs (like memory), which is not meaningful, but preventing them to be dropped so easily. This patch removes the useless frem/drem nodes, and by rewiring the inputs to the outputs.
>> 
>> Thanks,
>> Marc
>
> Marc Chevalier has updated the pull request incrementally with one additional commit since the last revision:
> 
>   address comments

Great work, Marc. This is a good preparation for [JDK-8347901](https://bugs.openjdk.org/browse/JDK-8347901).

I added a few minor comments.

src/hotspot/share/opto/divnode.cpp line 1520:

> 1518:   PhaseIterGVN* igvn = phase->is_IterGVN();
> 1519: 
> 1520:   bool result_is_ignored = proj_out_or_null(TypeFunc::Parms) == nullptr;

I think `result_is_unused` might be better wording (same below).

src/hotspot/share/opto/node.cpp line 2948:

> 2946: // `maybe_pure_function` is assumed to be the input of `this`. This is a bit redundant,
> 2947: // but we already have and need maybe_pure_function in all the call sites, so
> 2948: // it makes obvious that the `maybe_pure_function` is the same node as in the caller,

Suggestion:

// it makes it obvious that the `maybe_pure_function` is the same node as in the caller,

src/hotspot/share/opto/node.cpp line 2952:

> 2950: // the local in the caller.
> 2951: bool Node::is_data_proj_of_pure_function(const Node* maybe_pure_function) const {
> 2952:   return Opcode() == Op_Proj && static_cast<const ProjNode*>(this)->_con == TypeFunc::Parms && maybe_pure_function->is_pure_function();

You should use `as_Proj()` here instead of the static cast.

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

PR Review: https://git.openjdk.org/jdk/pull/23694#pullrequestreview-2653213655
PR Review Comment: https://git.openjdk.org/jdk/pull/23694#discussion_r1976968908
PR Review Comment: https://git.openjdk.org/jdk/pull/23694#discussion_r1976967349
PR Review Comment: https://git.openjdk.org/jdk/pull/23694#discussion_r1976966281


More information about the hotspot-compiler-dev mailing list