This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] match rotate pattern with extra 'or' operation
ClosedPublic

Authored by spatel on Mar 3 2022, 12:28 PM.

Details

Summary

This is another fold generalized from D111530. We can find a common source for a rotate operation hidden inside an 'or':
https://alive2.llvm.org/ce/z/9pV8hn

Deciding when this is profitable vs. a funnel-shift is tricky, but this does not show any regressions: if a target has a rotate but it does not have a funnel-shift, then try to form the rotate here. That is why we don't have x86 test diffs for the scalar tests that are duplicated from AArch64 ( 74a65e3834d9487 ) - shld/shrd are available. That also makes it difficult to show vector diffs - the only case where I found a diff was on x86 AVX512 or XOP with i64 elements.

There's an additional check for a legal type to avoid a problem seen with x86-32 where we form a 64-bit rotate but then it gets split inefficiently. We might avoid that by adding more rotate folds, but I didn't check to see what is missing on that path.

This gets most of the motivating patterns for AArch64 / ARM that are in D111530. We still need a couple of enhancements to setcc pattern matching with rotate/funnel-shift to get the rest.

Diff Detail

Event Timeline

spatel created this revision.Mar 3 2022, 12:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 12:28 PM
spatel requested review of this revision.Mar 3 2022, 12:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 12:28 PM
fzhinkin accepted this revision.Mar 9 2022, 6:19 AM
This revision is now accepted and ready to land.Mar 9 2022, 6:19 AM
This revision was landed with ongoing or failed builds.Mar 9 2022, 10:19 AM
This revision was automatically updated to reflect the committed changes.