This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Lower build_vector of VID sequence with one inconsistent element to vid and insert_vector_elt.
Needs ReviewPublic

Authored by jacquesguan on Jun 8 2022, 2:23 AM.

Details

Summary

This patch supports to identify build_vector of the VID sequence with just one inconsistent element, and will lower it to vid and insert_vector_elt.

Diff Detail

Event Timeline

jacquesguan created this revision.Jun 8 2022, 2:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2022, 2:23 AM
jacquesguan requested review of this revision.Jun 8 2022, 2:23 AM
reames added a subscriber: reames.Jun 8 2022, 7:52 AM
reames added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
1914

This is algorithmically slow.

You can achieve the same effect with a direct change to the matching code which allows it to fuzzy match exactly one element.

Doing so is non trivial, but once you find the first three non-undefs in the sequence it should be easy to distinguish.

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-shuffles.ll
142

Its not clear to me that a six instruction sequence is worthwhile to remove a constant pool entry. Can you make an argument as to why this change is worthwhile?

frasercrmck added inline comments.Jun 8 2022, 7:55 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
1914

I agree. It seems unfortunate to pessimise almost all BUILD_VECTOR compile times just for this case. Does this really show up in real-world code often enough to warrant this optimization?

Do we really want to match a v256 build vector where only element 148 is out of sequence, for example?