Inserting an element at index 0, into a shuffle that's an identity shuffle past the first
element, can be achieved with a single v{,f}slide1up. This patch detects such shuffles with
the isIdentityMask logic and lowers it to said vslide1up.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
6189 | This function seems to assert that the mask is not empty. Is it all possible we could end up triggering this assert with one-element vectors? Would we better be moving the VecVT.getVectorNumElements() > 1 check before calling isIdentityMask? Could we try and add testing for the above case? |
Description wise, calling an slideup-by-one mask an identity mask feels very odd to me. It took me a bit reading the code to figure out what you meant by that, and I'd suggest rewording. I'd suggest something along the lines of "would be identity mask if shifted down by one position" or something along those lines.
Did you look at the alternative of adding a DAG combine to reverse the shuffle+insert form into the insert+shuffle form? That'd been what I'd been tentatively thinking about, but I hadn't explored it past idea phase.
llvm/test/CodeGen/RISCV/rvv/fixed-vector-shuffle-vslide1up.ll | ||
---|---|---|
318 | You can go ahead and precommit these tests without further review. |
Not yet, but I'd like to explore that option before returning to this patch. This combine feels very specific and doesn't seem to be catch any cases in the benchmarks I've been looking at.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
6189 | Good catch, definitely meant to move the`VecVT.getVectorNumElements() > 1` first. |
This function seems to assert that the mask is not empty. Is it all possible we could end up triggering this assert with one-element vectors? Would we better be moving the VecVT.getVectorNumElements() > 1 check before calling isIdentityMask?
Could we try and add testing for the above case?