]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Fix vsetvl compatibility predicate [PR118154].
authorRobin Dapp <rdapp@ventanamicro.com>
Thu, 9 Jan 2025 19:45:10 +0000 (20:45 +0100)
committerKito Cheng <kito.cheng@sifive.com>
Wed, 9 Apr 2025 14:03:07 +0000 (22:03 +0800)
commit6f549f865d02f897f682dddf56f392a22c01df6c
tree3e65dd54187c5154058f1f9001e6aaa1e1e20c1e
parent1eb6bf312839d0ff6f0f1a246f9b0b715d1c4b7a
RISC-V: Fix vsetvl compatibility predicate [PR118154].

In PR118154 we emit strided stores but the first of those does not
always have the proper VTYPE.  That's because we erroneously delete
a necessary vsetvl.

In order to determine whether to elide

(1)
      Expr[7]: VALID (insn 116, bb 17)
        Demand fields: demand_ratio_and_ge_sew demand_avl
        SEW=8, VLMUL=mf2, RATIO=16, MAX_SEW=64
        TAIL_POLICY=agnostic, MASK_POLICY=agnostic
        AVL=(reg:DI 0 zero)

when e.g.

(2)
      Expr[3]: VALID (insn 360, bb 15)
        Demand fields: demand_sew_lmul demand_avl
        SEW=64, VLMUL=m1, RATIO=64, MAX_SEW=64
        TAIL_POLICY=agnostic, MASK_POLICY=agnostic
        AVL=(reg:DI 0 zero)
        VL=(reg:DI 13 a3 [345])

is already available, we use
sew_ge_and_prev_sew_le_next_max_sew_and_next_ratio_valid_for_prev_sew_p.

(1) requires RATIO = SEW/LMUL = 16 and an SEW >= 8.  (2) has ratio = 64,
though, so we cannot directly elide (1).

This patch uses ratio_eq_p instead of next_ratio_valid_for_prev_sew_p.

PR target/118154

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (MAX_LMUL): New define.
(pre_vsetvl::earliest_fuse_vsetvl_info): Use.
(pre_vsetvl::pre_global_vsetvl_info): New predicate with equal
ratio.
* config/riscv/riscv-vsetvl.def: Use.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr118154-1.c: New test.
* gcc.target/riscv/rvv/autovec/pr118154-2.c: New test.
gcc/config/riscv/riscv-vsetvl.cc
gcc/config/riscv/riscv-vsetvl.def
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr118154-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr118154-2.c [new file with mode: 0644]