[PATCH] D120253: [InstSimplify] remove shift that is redundant with part of funnel shift

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 21 07:37:30 PST 2022


spatel created this revision.
spatel added reviewers: fzhinkin, lebedev.ri, RKSimon.
Herald added subscribers: hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In D111530 <https://reviews.llvm.org/D111530>, I suggested that we add some relatively basic pattern-matching folds for shifts and funnel shifts and avoid a more specialized solution if possible.

We can start by implementing at least one of these in IR because it's easier to write the code and verify with Alive2:
https://alive2.llvm.org/ce/z/qHpmNn

This will need to be adapted/extended for SDAG to handle the motivating bug because the patterns only appear later with that example (added some tests: bb850d422b64 <https://reviews.llvm.org/rGbb850d422b6449d00c999ba4a1f2d1d68a9a2823>)

This can be extended within InstSimplify to handle cases where we 'and' with a shift too (in that case, kill the funnel shift). 
We could also handle patterns where the shift and funnel shift directions are inverted, but I think it's better to canonicalize that instead to avoid pattern-match case explosion.


https://reviews.llvm.org/D120253

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/or.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120253.410297.patch
Type: text/x-patch
Size: 4426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220221/28dad508/attachment.bin>


More information about the llvm-commits mailing list