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

Quan Anh Mai duke at openjdk.java.net
Fri Feb 25 12:29:56 UTC 2022


On Fri, 25 Feb 2022 06:58:15 GMT, Jie Fu <jiefu at openjdk.org> wrote:

> Assembly/Compiler Coding Rule 34. (ML impact, L generality) If an LEA instruction using the
> scaled index is on the critical path, a sequence with ADDs may be better. If code density and bandwidth
> out of the trace cache are the critical factor, then use the LEA instruction. 

As noted in the previous paragraph of the document, this is a trade-off since an `add` sequence may offer a little better latency in the expense of more uops and larger code size. As `lea` is an efficient instruction anyway in general it is more preferable to emit it.

Intels since Icelake can compute complex `lea` on more ports and have less latency, I have a predicate to check for that. Also the second bullet is due to `rbp` and `r13` base leads to the instruction must contain a displacement, effectively transform a 2-operand into a 3-operand `lea`, I have also fixed that. Thanks for noticing.

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

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


More information about the hotspot-compiler-dev mailing list