RFR: 8347555: [REDO] C2: implement optimization for series of Add of unique value [v9]

Kangcheng Xu kxu at openjdk.org
Thu Apr 10 19:05:37 UTC 2025


On Thu, 3 Apr 2025 05:06:51 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> src/hotspot/share/opto/addnode.cpp line 509:
>> 
>>> 507:     if (rhs.valid && rhs.variable == n->in(1)) {
>>> 508:       return Multiplication{true, rhs.variable, rhs.multiplier + 1};
>>> 509:     }
>> 
>> Hmm, it seems these are patterns that you did not promise you would cover in the description above.
>> It makes it a little difficult to keep the overview...
>
> Just a drive-by comment what might help: Name the cases you cover in the description with `(1)`, (2)` etc. and add the numbers as comments in the code where you cover the patterns. This would support the mapping from description to implementation.

I updated and expanded the comment. They are clearer now. I also added a subcase for `a + a` so `assert()` in `MulNode::Ideal()` can call directly into `find_power_of_two_addition_pattern()`

> Name the cases you cover in the description [..]

That's a great suggestion! Thank you. I'll start using this technique from now on.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23506#discussion_r2038113317


More information about the hotspot-compiler-dev mailing list