This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Lower shuffles as rotates without zvbb
ClosedPublic

Authored by luke on Sep 1 2023, 5:43 AM.

Details

Summary

Now that the codegen for the expanded ISD::ROTL sequence has been improved,
it's probably profitable to lower a shuffle that's a rotate to the
vsll+vsrl+vor sequence to avoid a vrgather where possible, even if we don't
have the vror instruction.

This patch relaxes the restriction on ISD::ROTL being legal in
lowerVECTOR_SHUFFLEAsRotate. It also attempts to do the lowering twice: Once
if zvbb is enabled before any of the interleave/deinterleave/vmerge lowerings,
and a second time unconditionally just before it falls back to the vrgather.
This way it doesn't interfere with any of the above patterns that may be more
profitable than the expanded ISD::ROTL sequence.

Diff Detail

Event Timeline

luke created this revision.Sep 1 2023, 5:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2023, 5:43 AM
luke requested review of this revision.Sep 1 2023, 5:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2023, 5:43 AM
luke added inline comments.Sep 1 2023, 5:48 AM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-rotate.ll
481–491

There's still some improvements we can make to the rv32 splat lowering/pattern matching here

This revision is now accepted and ready to land.Sep 1 2023, 3:42 PM
This revision was automatically updated to reflect the committed changes.