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;
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;
- relates to
-
JDK-8275610 C2: Object field load floats above its null check resulting in a segfault
-
- Resolved
-
-
JDK-8149797 Compilation fails with "assert(in_hash) failed: node should be in igvn hash table"
-
- Closed
-
-
JDK-8278228 C2: Improve identical back-to-back if elimination
-
- Resolved
-