RFR(S): 8143542: C2 doesn't eliminate identical checks

Roland Westrelin roland.westrelin at oracle.com
Wed Feb 3 12:01:57 UTC 2016


http://cr.openjdk.java.net/~roland/8143542/webrev.00/

The test case:

https://bugs.openjdk.java.net/secure/attachment/55176/RedundantNullCheck.java

has two identical tests one after the other:

int ret = 0;
if (_i != null) {
  ret += _i.value();
} else {
  ret += -1;
}
if (_i != null) {
  ret += _i.value2();
} else {
  ret += -1;
}

They can be merged. I picky backed on the split if code to achieve that. Both inlined calls have a null check and a range check. For them to fold nicely after the ifs are merged, ConstraintCastNode::dominating_cast() needs to more aggressively look for redundant casts.

Roland.


More information about the hotspot-compiler-dev mailing list