RFR: 8305783: x86_64: Optimize AbsI and AbsL

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Mon Apr 10 02:55:53 UTC 2023


On Sun, 9 Apr 2023 09:41:08 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

> Hi,
> 
> This patch optimizes the sequence emitted by `AbsINode` and `AbsLNode` to save some instructions and 1 temp register. Please take a look and kindly leave your reviews.
> 
> Thanks a lot.

Patch looks nice! (I am not a reviewer.) I have one comment with the code.

I was also thinking that the unconditional usage of cmov here may lead to performance issues if the abs is part of a loop-carried dependency, as I've seen that happen before with MinI/MaxI nodes before. I did a [small test](https://gist.github.com/jaskarth/d502adfe3a0e82c30b885ce660262161) to see if that was the case here and it seems there's no regression, so very nice!

src/hotspot/cpu/x86/x86_64.ad line 8469:

> 8467:   match(Set dst (AbsI src));
> 8468:   effect(TEMP dst, KILL cr);
> 8469:   format %{ "xorl    $dst, $dst\n\t"

Suggestion:

  format %{ "xorl    $dst, $dst\t # int abs\n\t"

It would be nice to add a comment like this to indicate in the OptoAssembly where the code is coming from, same with the long version.

-------------

PR Review: https://git.openjdk.org/jdk/pull/13402#pullrequestreview-1376995455
PR Review Comment: https://git.openjdk.org/jdk/pull/13402#discussion_r1161375772


More information about the hotspot-compiler-dev mailing list