[PATCH] D130895: [RISCV] Make VL choosing for a splat-like VMV based on its users

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 11:38:36 PST 2022


reames requested changes to this revision.
reames added a comment.
This revision now requires changes to proceed.

I spent some time this morning creating a minimal version of this patch.  This change is still too complicated, and I'm unconvinced of it's correctness.  Please see https://reviews.llvm.org/D137856.

While doing this, I realize this change is definitely incorrect.  Consider the following test case:
setvli x1, 5, <fixed lmul, flags>
vmv.v.i v8, -1
setvli x1, 1, <fixed lmul, flags>
vle8 v8, (a5)  // memory contains an -1 vector
setvli x1, 5, <fixed lmul, flags>
vmseq v9, v8, -1

In this case, vle8 stands in for any instruction with a merge operand.   The fact it's a load is not meant to be important.

The required semantics of this program is to produce a mask with five ones - regardless of the TA/TU status of the vle8.  TA allows either the original value or -1, and in this case, both choices result in the same result.

However, this patch would produce the following:
setvli x1, 1, <fixed lmul, flags>
vmv.v.i v8, -1
setvli x1, 1, <fixed lmul, flags>
vle8 v8, (a5)  // memory contains an -1 vector
setvli x1, 5, <fixed lmul, flags>
vmseq v9, v8, -1

In this case, lanes 1 through 4 (inclusive) are undefined, and may result in a mask without those lanes set.  As such, the transform is unsound as currently implemented.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130895/new/

https://reviews.llvm.org/D130895



More information about the llvm-commits mailing list