JDK-8259624 : C2: Fix disabled reduction in AddLNode::Ideal
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,16,17
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-01-12
  • Updated: 2021-05-12
  • Resolved: 2021-05-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17Resolved
Related Reports
Duplicate :  
Relates :  
Description
SonarCloud reports this branch is never taken in AddLNode::Ideal:

  // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)"
  // into "(X<<1)+Y" and let shift-folding happen.
  if( op2 == Op_AddL &&
      in2->in(1) == in1 &&
      op1 != Op_ConL &&
      0 ) {
    Node *shift = phase->transform(new LShiftLNode(in1,phase->intcon(1)));
    return new AddLNode(shift,in2->in(2));
  }

Notice the trailing "&& 0" in the condition. Seems to be that way since the initial load. 
Comments
https://github.com/openjdk/jdk/pull/3955
11-05-2021

Sounds good, marked this as "starter".
29-01-2021

There was similar code in AddINode::Ideal() which was removed by cleanup changes JDK-6258968. I don't think latency wise shift is better than addition. I would suggest to remove this code too.
28-01-2021

We need to check if there was a good reason to disable this optimization.
12-01-2021