Integrated: 8323503: x86: Shorter movptr(reg, imm) for 32-bit unsigned immediates
Aleksey Shipilev
shade at openjdk.org
Mon Jan 29 20:27:47 UTC 2024
On Wed, 10 Jan 2024 11:05:03 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> We noticed in [JDK-8323497](https://bugs.openjdk.org/browse/JDK-8323497) that `movptr` optimization done in [JDK-8319406](https://bugs.openjdk.org/browse/JDK-8319406) is not covering the case of immediates that fit in 32-bit unsigned, but do not fit in 32-bit signed. In that case, we can maybe do `mov r32, imm32` and rely on x86 zero-extending 32->64 bit for us. Since `movl` encoding is smaller than sign-extending `movq`, we also save more code on most paths that [JDK-8319406](https://bugs.openjdk.org/browse/JDK-8319406) improved.
>
> There are a few interesting conversions along the way:
> 1. `intptr_t` -> `uint32_t` (this method)
> 2. `uint32_t` -> `int32_t` (argument conversion for `movl`)
> 3. `int32_t` -> `uint32_t` (in `emit_int32`)
>
> I believe these are safe after `is_uimm32` check, but please check (sic) me on this.
>
> Note that x86_64 matcher already does similar thing for immediates:
>
>
> // Long Immediate 32-bit unsigned
> operand immUL32()
> %{
> predicate(n->get_long() == (unsigned int) (n->get_long()));
> match(ConL);
> ...
> %}
>
> instruct loadConUL32(rRegL dst, immUL32 src)
> %{
> ...
> format %{ "movl $dst, $src\t# long (unsigned 32-bit)" %}
> ins_encode %{
> __ movl($dst$$Register, $src$$constant);
> %}
> %}
>
>
> Additional testing:
> - [x] Linux x86_64 server fastdebug, `tier{1,2,3,4}`
>
> Code sizes for `Hello World`, `-Xcomp`:
>
>
> # Before
> tier1 nmethod code size : 426208 bytes
> tier2 nmethod code size : 462880 bytes
> tier3 nmethod code size : 889992 bytes
> tier4 nmethod code size : 1244448 bytes
>
> # After
> tier1 nmethod code size : 425768 bytes (-0.1%)
> tier2 nmethod code size : 462400 bytes (-0.1%)
> tier3 nmethod code size : 882072 bytes (-0.8%)
> tier4 nmethod code size : 1236448 bytes (-0.6%)
This pull request has now been integrated.
Changeset: e999dfcb
Author: Aleksey Shipilev <shade at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/e999dfcb405962bc4d77b9740d36193f1ebe4a2c
Stats: 4 lines in 2 files changed: 3 ins; 0 del; 1 mod
8323503: x86: Shorter movptr(reg, imm) for 32-bit unsigned immediates
Reviewed-by: stuefe, kvn, eastigeevich
-------------
PR: https://git.openjdk.org/jdk/pull/17343
More information about the hotspot-dev
mailing list