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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
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;

    @Benchmark
    public void mult() {
        doMult();
    }

    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    private int doMult() {
        int mult = flag ? 1 : 2;
        return idx * mult;
    }

Complete benchmark, some performance data and generated code:
  http://cr.openjdk.java.net/~shade/8130273/StrengthReduction.java

Runnable JAR:
  http://cr.openjdk.java.net/~shade/8130273/benchmarks.jar