[RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli
authorKito Cheng <kito.cheng@sifive.com>
Thu, 5 Jan 2023 15:10:12 +0000 (23:10 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 5 Jan 2023 16:44:30 +0000 (00:44 +0800)
commit05a2ae1b4aadf9537b49c5429f5085c78c669c33
tree30a4c37c3f7923b7c6d7d39ff36ccddf94adcc3f
parent11e92bd61fd640bb1c833b0e185979d80204eb9e
[RISCV][InsertVSETVLI] Using right instruction during mutate AVL of vsetvli

Fixing a crash during vsetvli insertion pass.

We have a testcase with 3 vsetvli:

1. vsetivli        zero, 2, e8, m4, ta, ma
2. li      a1, 32;  vsetvli zero, a1, e8, m4, ta, mu
3. vsetivli        zero, 2, e8, m4, ta, ma

and then we trying to optimize 2nd vsetvli since the only user is vmv.x.s, so
it could mutate the AVL operand to the AVL operand of the 3rd vsetvli.
OK, so we propagate 2 to vsetvli, BUT it's vsetvli not vsetivli, so it expect a
register rather than a immediate value, so we have to update the opcode
if needed.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D141061
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
llvm/test/CodeGen/RISCV/rvv/mutate-prior-vsetvli-avl.ll [new file with mode: 0644]