Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143542

C2 doesn't eliminate identical checks

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 9
    • hotspot
    • None
    • b108

      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;

            roland Roland Westrelin
            vlivanov Vladimir Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: