When we want to create an splat vector that only the first element is initialized, we could use vmv.x.s to build it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Do you have a particular microarchitecture where this is a faster sequence?
Why only integer and not FP?
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2258 | benefited->benefit |
I think that vmv.s.x has less demand on VL and VTYPE, so using vmv.s.x instead vmv.v.x might reduce the amount of VSETVLI instructions that we will insert.
I missed the floating point scalar move instruction, if you think it make sense, I will add it.
Can this prevent .vx instructions from being recognized from an arithmetic operation plus a splat?
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2258 | Done |
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2258 | I'm not sure what "benefit from immediate" is saying. Is this a workaround to keep immediate patterns like vadd.vi matching? |
llvm/test/CodeGen/RISCV/rvv/vreductions-int-rv32.ll | ||
---|---|---|
1599 | Spec said If SEW > XLEN, the value is sign-extended to SEW bits. |
This patch only seems to handle reductions and vmv.v.x intrinsics. A single element BUILD_VECTOR would still produce a vmv.v.x.
I think that vmv.s.x has less demand on VL and VTYPE, so using vmv.s.x instead vmv.v.x might reduce the amount of VSETVLI instructions that we will insert.
Do any of the test cases show this benefit? If not, can you create one?
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2258 | It's preventing vmv.v.i from becoming li+vmv.s.x. Splat matching isn't affected because this patch doesn't change the behavior of BUILD_VECTOR handling. |
Yes, there are serval cases that already show the changes, for example, llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp.ll and llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp.ll.
llvm/test/CodeGen/RISCV/rvv/vreductions-int-rv32.ll | ||
---|---|---|
1599 | Done, thanks. |
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2257 | Use bool and isa instead of dyn_cast since you don't care about the value. |
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
2257 | I add a check if the constant could be an immediate in the below if condition. |
Use bool and isa instead of dyn_cast since you don't care about the value.