[PATCH] D133829: [RISCV] Add cost model for insertelement/extractelement of vector type that should be splitted.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 11:37:24 PDT 2022


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

Can you add some test coverage specifically for the insert/extract case as opposed to relying on updates in lowering of more complicated constructs?



================
Comment at: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp:795
+          (Index != -1U &&
+           Index <= LT.second.getVectorElementCount().getKnownMinValue()))) {
+      // Otherwise, firstly, we need to spill it to stack.
----------------
I believe that for a scalable vector, this effectively returns the M in <vscale x M x iN>.  While correct, this is smaller than the maximum index we can prove in the first vector.  

(e.g. for +v, M is 1 for i64, but provably valid indexes are 0 and 1)

Here's an alternative:

```
      unsigned EltSize = VT.getScalarSizeInBits();
      unsigned MinSize = VT.getSizeInBits().getKnownMinValue();
      unsigned VectorBitsMin = Subtarget.getRealMinVLen();
      unsigned MinVLMAX =
          RISCVTargetLowering::computeVLMAX(VectorBitsMin, EltSize, MinSize);
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133829



More information about the llvm-commits mailing list