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:36 UTC 2025
On Wed, 2 Apr 2025 10:00:14 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Kangcheng Xu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> fix ((x<<y) << z) + (x<<y) patterns
>
> src/hotspot/share/opto/addnode.cpp line 415:
>
>> 413: if (find_power_of_two_addition_pattern(this, bt).valid) {
>> 414: return nullptr;
>> 415: }
>
> Hmm. So somewhere we would have generated that pattern, probably in MulNode. Can you add a verification there, to check that we are only generating patterns that `find_power_of_two_addition_pattern` recognizes? That would make sure that we keep the code here and there in sync.
Added `assert()` to `Mul[IL]Node::Ideal()`
> src/hotspot/share/opto/addnode.cpp line 428:
>
>> 426: ((mul = find_simple_multiplication_pattern(in1, bt)).valid && mul.variable == in2) ||
>> 427: ((mul = find_power_of_two_addition_pattern(in1, bt)).valid && mul.variable == in2)
>> 428: ) {
>
> I find this quite difficult to read. And it looks repetitive too. Maybe you can refactor it?
> Also, it would be nice to have comments with the patterns here, to see which one covers what case, so that we have a nice overview.
Refactored. Added comments with example. It's still some-what repetitive and definitely much clearer.
https://github.com/openjdk/jdk/blob/eefe3a35effc469f3527d4825c9cc4f2a72742dc/src/hotspot/share/opto/addnode.cpp#L421-L444
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23506#discussion_r2038113521
PR Review Comment: https://git.openjdk.org/jdk/pull/23506#discussion_r2038113480
More information about the hotspot-compiler-dev
mailing list