[InstCombine] narrow rotate left/right patterns to eliminate zext/trunc (PR34046)
authorSanjay Patel <spatel@rotateright.com>
Wed, 9 Aug 2017 18:37:41 +0000 (18:37 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 9 Aug 2017 18:37:41 +0000 (18:37 +0000)
commitc50e55d0e63db1e740e95de1246272332d3bca5e
tree5af87b064bbd11bcdbe0803bf728dbddf70c5315
parent2385825aab8de8012a599030363f17b41a440b6b
[InstCombine] narrow rotate left/right patterns to eliminate zext/trunc (PR34046)

I couldn't find any smaller folds to help the cases in:
https://bugs.llvm.org/show_bug.cgi?id=34046
after:
rL310141

The truncated rotate-by-variable patterns elude all of the existing transforms because
of multiple uses and knowledge about demanded bits and knownbits that doesn't exist
without the whole pattern. So we need an unfortunately large pattern match. But by
simplifying this pattern in IR, the backend is already able to generate
rolb/rolw/rorb/rorw for x86 using its existing rotate matching logic (although
there is a likely extraneous 'and' of the rotate amount).

Note that rotate-by-constant doesn't have this problem - smaller folds should already
produce the narrow IR ops.

Differential Revision: https://reviews.llvm.org/D36395

llvm-svn: 310509
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/test/Transforms/InstCombine/rotate.ll [new file with mode: 0644]