[PATCH] D139512: [RISCV] Use vcpop.m to extract the first element from mask vector.
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 07:46:08 PST 2022
reames added inline comments.
================
Comment at: llvm/test/CodeGen/RISCV/rvv/extractelt-i1.ll:223
+; CHECK-NEXT: vmseq.vi v8, v8, 0
+; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
+; CHECK-NEXT: vcpop.m a0, v8
----------------
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.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139512/new/
https://reviews.llvm.org/D139512
More information about the llvm-commits
mailing list