On Sun, Jul 9, 2023 at 10:35 PM Roger Sayle <ro...@nextmovesoftware.com> wrote: > > > Following Uros' suggestion, this patch adds support for AVX512VL's > vpro[lr][dq] instructions to the recently added scalar-to-vector (STV) > enhancements to handle DImode and SImode rotations by a constant. > > For the test cases: > > unsigned long long rot1(unsigned long long x) { > return (x>>1) | (x<<63); > } > > void mem1(unsigned long long *p) { > *p = rot1(*p); > } > > with -m32 -O2 -mavx512vl, we currently generate: > > rot1: movl 4(%esp), %eax > movl 8(%esp), %edx > movl %eax, %ecx > shrdl $1, %edx, %eax > shrdl $1, %ecx, %edx > ret > > mem1: movl 4(%esp), %eax > vmovq (%eax), %xmm0 > vpshufd $20, %xmm0, %xmm0 > vpsrlq $1, %xmm0, %xmm0 > vpshufd $136, %xmm0, %xmm0 > vmovq %xmm0, (%eax) > ret > > with this patch, we now generate: > > rot1: vmovq 4(%esp), %xmm0 > vprorq $1, %xmm0, %xmm0 > vmovd %xmm0, %eax > vpextrd $1, %xmm0, %edx > ret > > mem1: movl 4(%esp), %eax > vmovq (%eax), %xmm0 > vprorq $1, %xmm0, %xmm0 > vmovq %xmm0, (%eax) > ret > > > This patch has been tested on x86_64-pc-linux-gnu (cascadelake which has > avx512) with make bootstrap and make -k check, both with and without > --target_board=unix{-m32} with no new failures. Ok for mainline? > > > 2023-07-09 Roger Sayle <ro...@nextmovesoftware.com> > > gcc/ChangeLog > * config/i386/i386-features.cc (compute_convert_gain): Tweak > gains/costs for ROTATE/ROTATERT by integer constant on AVX512VL. > (general_scalar_chain::convert_rotate): On TARGET_AVX512F generate > avx512vl_rolv2di or avx412vl_rolv4si when appropriate. > > gcc/testsuite/ChangeLog > * gcc.target/i386/avx512vl-stv-rotatedi-1.c: New test case.
OK. Thanks, Uros. > > > Cheers, > Roger > -- >