This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use tail agnostic policy more often when lowering insert_subvector
ClosedPublic

Authored by luke on Mar 31 2023, 11:55 AM.

Details

Summary

If we're inserting a fixed length subvector into a fixed length vector,
then we can use a tail agnostic policy as long as we're inserting up to
or past the end of the main vector.
I.e., because we're overwriting all of the main vector's tail elements,
and we don't care what the elements after that are.
As noted by Philip in https://reviews.llvm.org/D146711#4220341

Diff Detail

Event Timeline

luke created this revision.Mar 31 2023, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2023, 11:55 AM
luke requested review of this revision.Mar 31 2023, 11:55 AM
luke updated this revision to Diff 510094.Mar 31 2023, 11:57 AM

Use a more accurate comment

craig.topper added inline comments.Mar 31 2023, 12:06 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6589

Can EndIndex ever be > than VecVT.getVectorNumElements()?

luke added inline comments.Mar 31 2023, 1:27 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6589

Would cases like insert_subvector a:v4i8, b:v2i8, 3:i32 reach here? Not sure if this is legal, but I thought EndIndex here would be 2+3=5

craig.topper added inline comments.Mar 31 2023, 9:40 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6589

I think the insertion index must be a multiple of the known minimum length of the subvector.

luke added inline comments.Apr 2 2023, 7:12 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
6589

Ah you're right, that makes sense. I put in an assert to see if EndIndex > VecVT.getVectorNumElements() ever triggers, and it doesn't seem to.

luke updated this revision to Diff 510348.Apr 2 2023, 7:13 AM

Update test case that resides outside of rvv and account for the fact that EndIndex can never be > VecVT.getNumberOfElements()

This revision is now accepted and ready to land.Apr 5 2023, 5:29 PM
This revision was landed with ongoing or failed builds.Apr 6 2023, 2:32 AM
This revision was automatically updated to reflect the committed changes.