[PATCH] D36395: [InstCombine] narrow rotate left/patterns to eliminate zext/trunc (PR34046)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 07:44:11 PDT 2017
spatel created this revision.
Herald added a subscriber: mcrosier.
I couldn't find any smaller folds to help the cases in:
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. Note that rotate-by-constant doesn't have this problem - smaller folds should already produce the narrow IR ops.
For the motivating cases from the bug report, in addition to using narrow ops, we have a net win of two less instructions (kill 3 zext/trunc but add a mask op). I initially forgot that we need that mask, but Alive confirms that it would be wrong to leave the mask of the opposite shift amount off:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 8444 bytes
Desc: not available
More information about the llvm-commits