[PATCH] D145953: [RISCV] Fallback to scalable lowering costs for fixed length vectors

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 09:45:39 PDT 2023


luke added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp:342-348
+    //   csrr a0, vlenb
+    //   srli a0, a0, 3
+    //   addi a0, a0, -1
+    //   vsetvli a1, zero, e8, mf8, ta, mu (ignored)
+    //   vid.v v9
+    //   vrsub.vx v10, v9, a0
+    //   vrgather.vv v9, v8, v10
----------------
Patch makes sense to me. 
Just something I saw whilst testing, we don't use vscale with fixed length vectors and could subtract it from the cost:

```
define <4 x i8> @reverse(<4 x i8> %v0) {
  %v4i8 = shufflevector <4 x i8> %v0, <4 x i8> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  ret <4 x i8> %v4i8
}
```
```
reverse:
	vsetivli	zero, 4, e8, mf4, ta, ma
	vid.v	v9
	vrsub.vi	v10, v9, 3
	vrgather.vv	v9, v8, v10
	vmv1r.v	v8, v9
	ret
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145953



More information about the llvm-commits mailing list