Suboptimal code generation in C2?
Aleksey Shipilev
aleksey.shipilev at oracle.com
Wed Sep 23 18:53:47 UTC 2015
Hi,
On 09/23/2015 08:49 PM, Vitaly Davidovich wrote:
> Consider this simple method:
>
> private static int test(final int ops, int start) {
> for (int i = 0; i < ops; ++i) {
> start++;
> }
> return start;
> }
> test(int, int):
> leal(%rsi,%rdi), %edx
> movl%esi, %eax
> testl%edi, %edi
> cmovg%edx, %eax
> ret
>
> Any ideas on why C2 doesn't generate roughly the same thing? Clang 3.7
> and ICC 13.0.1 are almost the same as the GCC output above.
Yup, could be better:
https://bugs.openjdk.java.net/browse/JDK-8137049
I am not entirely sure conditional move is better than a branch in this
particular case, since $ops is probably always non-negative in practice.
HotSpot generates a branch there, which is good. The arithmetic dance is
indeed not very clean -- I'd speculate that's a leftover from loop peeling.
Thanks,
-Aleksey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150923/4af0f7bc/signature.asc>
More information about the hotspot-compiler-dev
mailing list