This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][RISCV] Allow rotates by non-constant to be match for i32 on riscv64 with Zbb.
ClosedPublic

Authored by craig.topper on Feb 5 2022, 1:11 PM.

Details

Summary

rv64izbb has a RORW/ROLW instructions that operate on the lower
32-bits of a 64-bit value and sign extend bit 31 of the result.

DAGCombiner won't match rotate idioms because the i32 type isn't Legal
on riscv64.

This patch teaches DAGCombiner to allow it if the type is going to
be promoted and the target has Custom type legalization for ISD::ROTL
or ISD::ROTR. I've restricted this to scalar types. It doesn't appear
any in tree targets other than riscv64 have custom type legalization
for rotates.

If this patch isn't acceptable, I guess I can match SRLW, SLLW, and OR
after type legalization, but I'd like to avoid that if possible.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 5 2022, 1:11 PM
craig.topper requested review of this revision.Feb 5 2022, 1:11 PM
RKSimon accepted this revision.Feb 6 2022, 3:16 AM

LGTM

This revision is now accepted and ready to land.Feb 6 2022, 3:16 AM
This revision was landed with ongoing or failed builds.Feb 6 2022, 10:58 AM
This revision was automatically updated to reflect the committed changes.