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

--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Lehua Ding <lh...@gcc.gnu.org>:

https://gcc.gnu.org/g:405096f908e1ceb0d6a1b5420ded20ad85ddae9e

commit r14-7244-g405096f908e1ceb0d6a1b5420ded20ad85ddae9e
Author: Juzhe-Zhong <juzhe.zh...@rivai.ai>
Date:   Mon Jan 15 09:22:40 2024 +0800

    RISC-V: Adjust loop len by costing 1 when NITER < VF

    Rebase in v3: Rebase to the trunk and commit it as it's approved by Robin.
    Update in v2: Add dynmaic lmul test.

    This patch fixes the regression between GCC 13.2.0 and trunk GCC (GCC-14)

    GCC 13.2.0:

            lui     a5,%hi(a)
            li      a4,19
            sb      a4,%lo(a)(a5)
            li      a0,0
            ret

    Trunk GCC:

            vsetvli a5,zero,e8,mf2,ta,ma
            li      a4,-32768
            vid.v   v1
            vsetvli zero,zero,e16,m1,ta,ma
            addiw   a4,a4,104
            vmv.v.i v3,15
            lui     a1,%hi(a)
            li      a0,19
            vsetvli zero,zero,e8,mf2,ta,ma
            vadd.vi v1,v1,1
            sb      a0,%lo(a)(a1)
            vsetvli zero,zero,e16,m1,ta,ma
            vzext.vf2       v2,v1
            vmv.v.x v1,a4
            vminu.vv        v2,v2,v3
            vsrl.vv v1,v1,v2
            vslidedown.vi   v1,v1,17
            vmv.x.s a0,v1
            snez    a0,a0
            ret

    The root cause we are vectorizing the codes inefficiently since we doesn't
cost len when NITERS < VF.
    Leverage loop control of mask targets or rs6000 fixes the regression.

    Tested no regression. Ok for trunk ?

            PR target/113281

    gcc/ChangeLog:

            * config/riscv/riscv-vector-costs.cc
(costs::adjust_vect_cost_per_loop): New function.
            (costs::finish_cost): Adjust cost for LOOP LEN with NITERS < VF.
            * config/riscv/riscv-vector-costs.h: New function.

    gcc/testsuite/ChangeLog:

            * gcc.dg/vect/costmodel/riscv/rvv/pr113281-3.c: New test.
            * gcc.dg/vect/costmodel/riscv/rvv/pr113281-4.c: New test.
            * gcc.dg/vect/costmodel/riscv/rvv/pr113281-5.c: New test.

Reply via email to