RFR: 8347555: [REDO] C2: implement optimization for series of Add of unique value [v18]
    Kangcheng Xu 
    kxu at openjdk.org
       
    Wed Oct  1 05:08:05 UTC 2025
    
    
  
On Wed, 17 Sep 2025 15:02:38 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Kangcheng Xu has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 67 commits:
>> 
>>  - Merge branch 'openjdk:master' into arithmetic-canonicalization
>>  - Merge remote-tracking branch 'origin/master' into arithmetic-canonicalization
>>  - Allow swapping LHS/RHS in case not matched
>>  - Merge branch 'refs/heads/master' into arithmetic-canonicalization
>>  - improve comment readability and struct helper functions
>>  - remove asserts, add more documentation
>>  - fix typo: lhs->rhs
>>  - update comments
>>  - use java_add to avoid cpp overflow UB
>>  - add assertion for MulLNode too
>>  - ... and 57 more: https://git.openjdk.org/jdk/compare/173dedfb...7bb7e645
>
> src/hotspot/share/opto/addnode.cpp line 424:
> 
>> 422: // Note this also converts, for example, original expression `(a*3) + a` into `4*a` and `(a<<2) + a` into `5*a`. A more
>> 423: // generalized pattern `(a*b) + (a*c)` into `a*(b + c)` is handled by AddNode::IdealIL().
>> 424: Node* AddNode::convert_serial_additions(PhaseGVN* phase, BasicType bt) {
> 
> The name `convert_serial_additions` now seems a bit off. Because we really cover a lot of other cases too.
> Really you cover `a + pattern` and `pattern + a`, where `pattern` is one of the cases from `find_serial_addition_patterns`.
> 
> Maybe it could be called `AddNode::Ideal_collapse_variable_times_con`. Because in the end you want to find cases that are equivalent to `a * some_con`.
> 
> Lead the documentation with that as well, rather than the series of additions. Because the series of additions is not the pattern you actually match here. The series of additions is only one of the use-cases, and there are others.
Thank you. I also like the wording of *collapsing* additions better. I've updated names and comments accordingly.
> test/hotspot/jtreg/compiler/c2/TestSerialAdditions.java line 24:
> 
>> 22:  */
>> 23: 
>> 24: package compiler.c2;
> 
> I would put the test in a more specific directory. I think the `igvn` directory would be a good canditate, because `Ideal` is part of IGVN ;)
Move to the `.gvn` package.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23506#discussion_r2393460358
PR Review Comment: https://git.openjdk.org/jdk/pull/23506#discussion_r2393460843
    
    
More information about the hotspot-compiler-dev
mailing list