JDK-8130273 : multiply -> shift reduction fails with complex control flow
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-07-01
  • Updated: 2019-01-15
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.
Related Reports
Relates :  
This was found during the course of Compact String work. This manifests in Integer.toString and Long.toString changes there.
It boils down to this. When there is a strength reduction opportunity to reduce multiplication to shift, it fails when we have a
non-trivial control flow preceding the argument. The breakage would only happen if the alternative branch is not folded into
uncommon trap.

    int idx;
    boolean flag;

    public void mult() {

    private int doMult() {
        int mult = flag ? 1 : 2;
        return idx * mult;

Complete benchmark, some performance data and generated code:

Runnable JAR: