This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add custom isel to select (and (srl X, C1), C2) and (and (shl X, C1), C2)
ClosedPublic

Authored by craig.topper on Jul 17 2021, 10:07 PM.

Details

Summary

Replace some existing isel patterns that are covered by the new
code. SLLIUWPat has been removed in favor of folding its root case
into the new code. The other uses in isel patterns for shXadd.uw
have been switched to using hardcoded AND masks.

This is based on the original version of D49585 from ARM. The final
version of that was made a DAG combine, but I've chosen to keep it
as custom isel. I'm not convinced DAG combine is as good with
shift pairs as it is with and+shift. I saw some issues optimizing
the shifts created by vscale lowering if an and isn't created for
from a shift pair.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 17 2021, 10:07 PM
craig.topper requested review of this revision.Jul 17 2021, 10:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2021, 10:07 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Rebase after adding new tests in div.ll and rem.ll

Refactor the code a little so we can form srliw from and+srl. This improves sdiv16_constant in div.ll

Add another special case (and (srl (sexti32 Y), c2), c1) -> (srliw (sraiw Y, 31), c2-31). This occurs in sdiv/srem by constant power of 2.

luismarques accepted this revision.Jul 20 2021, 6:36 AM

LGTM. Some nice wins!

This revision is now accepted and ready to land.Jul 20 2021, 6:36 AM
This revision was landed with ongoing or failed builds.Jul 20 2021, 8:56 AM
This revision was automatically updated to reflect the committed changes.