RFR: 8282204: Use lea instructions for arithmetic operations on x86_64 [v5]

Quan Anh Mai duke at openjdk.java.net
Sat Feb 26 01:49:54 UTC 2022


On Fri, 25 Feb 2022 12:11:43 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

>> Hi,
>> 
>> This patch adds several matching rules for x86_64 backend to use `lea` instructions for several fused arithmetic operations. Also, `lea`s don't kill flags and allow different `dst` and `src`, so it is preferred over `sll` if possible, too. 
>> 
>> Thank you very much.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   address reviews

I'm really confused here because I can't reproduce this locally as well as on Godbolt with all relevant architectures, and also I don't see why clang is trying to change stack frame in such a small function in your generated code. Maybe the compiler is a little different on MacOS?

By the way, as noted in the manual as well as experimenting with various different compilers, I think 2 `add`s would be more efficient for pre-Icelakes since it offers a little better latency and removes the concern of bottleneck on port 1.

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

PR: https://git.openjdk.java.net/jdk/pull/7560


More information about the hotspot-compiler-dev mailing list