[PATCH] D120933: [SDAG] match rotate pattern with extra 'or' operation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 12:28:45 PST 2022


spatel created this revision.
spatel added reviewers: fzhinkin, RKSimon, dmgreen.
Herald added subscribers: ecnelises, pengfei, hiraditya, kristof.beyls, mcrosier.
Herald added a project: All.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is another fold generalized from D111530 <https://reviews.llvm.org/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 <https://reviews.llvm.org/rG74a65e3834d9487a3030ce48ef1022db11a01dfb> ) - 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 <https://reviews.llvm.org/D111530>. We still need a couple of enhancements to setcc pattern matching with rotate/funnel-shift to get the rest.


https://reviews.llvm.org/D120933

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/icmp-shift-opt.ll
  llvm/test/CodeGen/AArch64/logic-shift.ll
  llvm/test/CodeGen/ARM/consthoist-icmpimm.ll
  llvm/test/CodeGen/ARM/icmp-shift-opt.ll
  llvm/test/CodeGen/X86/rotate_vec.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120933.412794.patch
Type: text/x-patch
Size: 12992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220303/6d803584/attachment.bin>


More information about the llvm-commits mailing list