A simple optimization proposal (original) (raw)
Martin Grajcar maaartinus at gmail.com
Wed Feb 12 09:40:30 PST 2014
- Previous message: Redundant barrier elimination
- Next message: A simple optimization proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Most hash tables are power-of-two sized so that they can use masking for the access. It looks like the bounds check doesn't get eliminated, although it could be.
Based on the equivalence a[x & (a.length - 1)] throws if and only if a.length == 0, I'm proposing this simple algorithm:
- For each array access, check if the index has been computed via a bitwise and.
- If so, check if either of the operands was computed as length minus one.
- If so, replace the bounds check by a zero-length check.
This zero-length check can then be easily moved out of the loop by the existing optimizations.
I hope I'm not talking non-sense. For more details see http://stackoverflow.com/questions/21702939/why-the-bounds-check-doesnt-get-eliminated
Regards, Martin. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20140212/8550239f/attachment.html
- Previous message: Redundant barrier elimination
- Next message: A simple optimization proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the hotspot-compiler-dev mailing list