This patch uses vfirst.m to extract the first bit of mask.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/CodeGen/RISCV/rvv/extractelt-i1.ll | ||
---|---|---|
223 | Hm, having a vsetvli toggle here is unfortunate. Can we achieve this in a slightly different way? We could use a id vector, comparison with index, and then and to form a mask which could then be popcnt. This also generalize for any index. We could use a vfirst.m and a scalar comparison against 0. This only works when index is the first potentially set bit. We could extract the bottom ETYPE bits of the mask into a scalar, and then mask out the low bit. This works for any index < min(XLEN, sizeinbits(ETYPE)). Have you given these options (or others) consideration? Your chosen solution appears correct, I'm just looking for some discussion of what other options you considered and rejected before we land this. |
change to vfirst.m.
llvm/test/CodeGen/RISCV/rvv/extractelt-i1.ll | ||
---|---|---|
223 | Let me summarize: 1, For all index: This way uses 3 instruction which is same as the current method, I don't think this way is better. 2, For the fisrt element: vfirst.m + sltu This way will change the vsetvli instruction with a scalar comparison instruction, I think it should be better as maybe avoid potential vsetvl insertion. 3, For the index located in min(XLEN, sizeinbits(ETYPE)): This alreay achieved with fixed vector, but the scalable vector should be improved. |
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td | ||
---|---|---|
1840 | This comment appears to have been copy and pasted without updating |
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td | ||
---|---|---|
1840 | Done. |
This comment appears to have been copy and pasted without updating