This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add RISCVISD opcodes for CLZW and CTZW.
ClosedPublic

Authored by craig.topper on Mar 24 2021, 10:46 PM.

Details

Summary

Our CLZW isel pattern is quite easily broken by surrounding code
preventing it from matching sometimes. This usually results in
failing to remove the and X, 0xffffffff inserted by type
legalization. The add with -32 that type legalization also inserts
often get combined into other add/sub nodes so that doesn't
usually result in extra code when we don't use clzw.

CTTZ is seems to less fragile, but I wanted to keep it consistent
with CTLZ.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 24 2021, 10:46 PM
craig.topper requested review of this revision.Mar 24 2021, 10:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2021, 10:46 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
This revision is now accepted and ready to land.Mar 31 2021, 2:35 AM
asb accepted this revision.Mar 31 2021, 8:05 AM

LGTM, this seems the right direction to go in.

In theory I much prefer patterns in .td files wherever possible (shorter pattern description, harder for silly logic mistakes to hide within boilerplate etc). But the reality is obviously they can become brittle if above a certain level of complexity, as with many RV64 '*W' patterns.

This revision was landed with ongoing or failed builds.Mar 31 2021, 9:40 AM
This revision was automatically updated to reflect the committed changes.