This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add patterns for vnsr[a,l].wx where shift amount has different type than vector element
ClosedPublic

Authored by luke on Jul 19 2023, 6:24 AM.

Details

Summary

We're currently only matching scalar shift amounts where the type is the same
as the vector element type. But because only the bottom log2(2*SEW) bits are
used, only 7 bits will be used at most so we can use any scalar type >= i8.

This patch adds patterns for the case above, as well as for when the shift
amount type is the same as the widened element type and doesn't need extended.

Diff Detail

Event Timeline

luke created this revision.Jul 19 2023, 6:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 6:24 AM
luke requested review of this revision.Jul 19 2023, 6:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 6:24 AM
luke retitled this revision from [RISCV] Add more patterns for vnsr[a,l].wx to [RISCV] Add patterns for vnsr[a,l].wx where shift amount has different type than vector element.
luke added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1436

Iterating over this fixed list of scalars is a bit hairy. Are there any other ways that we can get a list of vectors with the same length but different element type?

craig.topper added inline comments.Jul 19 2023, 7:16 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1436

I wonder if we've reached the point where we should use a ComplexPattern to look through the extend and find the scalar?

luke updated this revision to Diff 542427.Jul 20 2023, 4:51 AM

Use a ComplexPattern to work around type inference, and use PatFrags to merge the zext and sext patterns together

This revision is now accepted and ready to land.Jul 20 2023, 9:39 PM