RFR: 8304258: x86: Improve the code generation of VectorRearrange with int and float [v2]

Jatin Bhateja jbhateja at openjdk.org
Thu Mar 23 17:01:27 UTC 2023


On Wed, 22 Mar 2023 20:22:22 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hi,
>> 
>> This small patch changes the code generation of VectorRearrangeNode with respect to int and float elements. With not-larger-than-128-bit vectors, we can use `vpermilps` instead of promoting to operating on the extended 256-bit vector. This also helps the code generation of AVX1 to not rely on the sse version.
>> 
>> Please take a look and leave some reviews.
>> Thanks a lot.
>
> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
> 
>  - Merge branch 'master' into rearrangeI
>  - improve rearrangeI

src/hotspot/cpu/x86/assembler_x86.cpp line 4230:

> 4228: 
> 4229: void Assembler::vpermps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) {
> 4230:   assert(vector_len <= AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_evex(), "");

Instruction support 256 and 512 bit vectors only and assertion should comply with that.

src/hotspot/cpu/x86/x86.ad line 8645:

> 8643:     int vlen_enc = vector_length_encoding(this);
> 8644:     if (vlen_enc == Assembler::AVX_128bit) {
> 8645:       __ vpermilps($dst$$XMMRegister, $src$$XMMRegister, $shuffle$$XMMRegister, vlen_enc);

Since you are emitting different instruction to save on domain switch over penalty for > 128 bit vectors, same can be done for 128 bit vectors also, you may use vpshufd for integers.

src/hotspot/cpu/x86/x86.ad line 8649:

> 8647:       __ vpermd($dst$$XMMRegister, $shuffle$$XMMRegister, $src$$XMMRegister, vlen_enc);
> 8648:     } else {
> 8649:       __ vpermps($dst$$XMMRegister, $shuffle$$XMMRegister, $src$$XMMRegister, vlen_enc);

Please move this to a macro assembly routine.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13042#discussion_r1146449816
PR Review Comment: https://git.openjdk.org/jdk/pull/13042#discussion_r1146477783
PR Review Comment: https://git.openjdk.org/jdk/pull/13042#discussion_r1146497128


More information about the hotspot-compiler-dev mailing list