https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122065

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Avinash Jayakar <[email protected]>:

https://gcc.gnu.org/g:abbed7806672d0d6cfd6169d084d031d6e737fe1

commit r16-4675-gabbed7806672d0d6cfd6169d084d031d6e737fe1
Author: Avinash Jayakar <[email protected]>
Date:   Tue Oct 28 09:49:21 2025 +0530

    vect: Add vector lowering for MULT_EXPR for constant pow2 multiplication.

    Use logic similar to lowering the vector operation for MULT_EXPR as done in
    expand_mult in expmed.cc, but in this commit only bare bones version of
what
    is done in vect_synth_mult_by_constant is implemented that only works if
    constant is a positive power of 2 constant.

    Previously, if the source code is written in a vector dialect, for example
the
    vector types of altivec.h, the vectorizer would lower the MULT_EXPR to
scalar
    variant if the target did not support the vector insn for that type. But
better
    code could be generated had it recognized the pattern and transformed it to
    shifts.
    For example, this code

    vector unsigned long long
    lshift1_64_altivec (vector unsigned long long a)
    {
      return a * (vector unsigned long long) { 4, 4 };
    }

    generates the scalar code in power8/9

            .cfi_startproc
            xxpermdi 0,34,34,3
            mfvsrd 9,34
            mfvsrd 10,0
            sldi 9,9,2
            mtvsrd 0,9
            sldi 10,10,2
            mtvsrd 34,10
            xxpermdi 34,0,34,0
            blr
            .long 0
            .byte 0,0,0,0,0,0,0,0
            .cfi_endproc

    although it has a vector insn for left shift. With this change now the
    following is generated

            .cfi_startproc
            lxvd2x 32,0,3
            vspltisw 1,2
            vsld 0,0,1
            stxvd2x 32,0,3
            blr
            .long 0
            .byte 0,0,0,0,0,0,0,0
            .cfi_endproc

    2025-11-28  Avinash Jayakar  <[email protected]>

    gcc/ChangeLog:
            PR tree-optimization/122065
            * tree-vect-generic.cc (add_rshift): Update name and add code
parameter.
            (add_shift): Update name.
            (expand_vector_mult): New lowering for MULT_EXPR.
            (expand_vector_divmod): Use updated function name.
            (expand_vector_operation): Use updated function name.

Reply via email to