A simple optimization proposal
john.r.rose at oracle.com
Thu Feb 13 12:32:22 PST 2014
On Feb 13, 2014, at 9:11 AM, Krystal Mok <rednaxelafx at gmail.com> wrote:
> Here, the code in line 1 should ensure a.length > 2, and that predicate should propagate to line 2. But in the generated code, there's still a bounds check (a.length != 0) in line 2, right before the actual element load.
We use two main sources of information to delete redundant tests: type information (such as integer ranges) and pattern matching on dominating tests (IfNode::). In this case, the array type information does not carry the path-dependent information about a.length. And, the dominating checks are not sufficiently similar to fold together. But the common case is optimized, so I'm happy.
You might want to look at the code for HashMap.getNode, which (I think) optimizes with your existing logic.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-compiler-dev