[RISCV] Add a test showing an incorrect VSETVLI insertion
authorFraser Cormack <fraser@codeplay.com>
Mon, 31 Jan 2022 17:43:37 +0000 (17:43 +0000)
committerFraser Cormack <fraser@codeplay.com>
Tue, 1 Feb 2022 10:21:29 +0000 (10:21 +0000)
commitb00bce2a93b3c14379e088225c45a341ad75ba0f
tree6813ebc53d17d0c791747b2581fde71fa1ba0883
parentdf3d121bb9f20e0b547f159020eab309a87acef6
[RISCV] Add a test showing an incorrect VSETVLI insertion

This test shows a loop, whose preheader uses a SEW=64, LMUL=1 vector
operation. The loop body starts off with another SEW=64, LMUL=1 VADD
vector operation, before switching to a SEW=32, LMUL=1/2 vector store
instruction.

We can see that the VSETVLI insertion pass omits a VSETVLI before the
VADD (thinking it inherits its configuration from the preheader) but
does place a SEW=32, LMUL=1/2 VSETVLI before the store. This results in
a miscompilation as when the loop comes back around, the VADD is
incorrectly configured with SEW=32, LMUL=1/2.

It appears to be a bad load/store optimization, as replacing the vector
store with an SEW=32, LMUL=1/2 VADD does correctly insert a VSETVLI. The
issue is therefore possibly arising from canSkipVSETVLIForLoadStore.

Differential Revision: https://reviews.llvm.org/D118629
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.mir