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

Kangcheng Xu kxu at openjdk.org
Tue Oct 7 18:06:07 UTC 2025


On Mon, 6 Oct 2025 14:12:25 GMT, Kangcheng Xu <kxu at openjdk.org> wrote:

>> src/hotspot/share/opto/addnode.cpp line 524:
>> 
>>> 522:   if (n->Opcode() == Op_Mul(bt) && (n->in(1)->is_Con() || n->in(2)->is_Con())) {
>>> 523:     // Pattern (1)
>>> 524:     Node* con = n->in(1);
>> 
>> Isn't con always input 2 because `MulNode::Ideal` canonicalize it?
>
> I think you're right. An assertion is also added to verify this.

Upon further investigation, I don't think this is necessarily true. With `compiler/c2/Test6636138_1`  I'm seeing


   2  1052  MulI  === _ 55 1040  [[ 1053 ]] 
   1  1053  ConvI2L  === _ 1052  [[ 1054 ]]  #long:minint..maxint, 0u..maxulong
   1  1046  ConL  === 0  [[ 1047 1054 ]]  #long:4
   0  1054  MulL  === _ 1046 1053  [[ 1055 ]] 


which is not idealized.

I'm reverting this change. Please let me know if you think a input node is necessarily already idealized when the currently addnode is being idealized and I'm potentially missing something.

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

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


More information about the hotspot-compiler-dev mailing list