JDK-8143542 : C2 doesn't eliminate identical checks
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-11-20
  • Updated: 2021-12-03
  • Resolved: 2016-02-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 9
9 b108Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
There are cases when C2 fails to remove redundant check (has identical dominating check).  

Reported by Vitaly Davidovich:
  http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-November/019930.html

Final IR from attached test case:
RedundantNullCheck::doIt() {
  w = Load this._w
  If (w == NULL) deopt
  i = Load w._i
  If (i != NULL) {  // check #1
    If (!i instanceof C) deopt
  } v1 = Phi(T:1,F:-1);
  If (i != NULL) {  // check #2
    If (!i instanceof C) deopt
  } v2 = Phi(T:2,F:-1)
  return v1+v2
}

Checks #1 & #2 are identical. #1 dominates #2, but C2 doesn't remove #2.

Next transformations should be:
  w = Load this._w
  If (w == NULL) deopt
  i = Load w._i
  If (i != NULL) {
    If (!i instanceof C) deopt
    If (!i instanceof C) deopt
  } v1 = Phi(T:1,F:-1)
    v2 = Phi(T:2,F:-1)
  return v1+v2

and

  w = Load this._w
  If (w == NULL) deopt
  i = Load w._i
  If (i != NULL) {
    If (!i instanceof C) deopt
  } v1 = Phi(T:1,F:-1)
    v2 = Phi(T:2,F:-1)
  return i1+i2;
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/894c8b63e200 User: lana Date: 2016-03-02 19:34:38 +0000
02-03-2016

URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/894c8b63e200 User: roland Date: 2016-02-12 20:44:53 +0000
12-02-2016

Regarding lack of test case: affects code generation (and not correctness) that can't be observed from a test case.
12-02-2016