PR16726: extend rol/ror matching
authorKai Nacke <kai.nacke@redstar.de>
Thu, 19 Sep 2013 22:36:39 +0000 (22:36 +0000)
committerKai Nacke <kai.nacke@redstar.de>
Thu, 19 Sep 2013 22:36:39 +0000 (22:36 +0000)
commita5950e0149871671847c051c95113460f161e384
tree3c2bf30dedf4859fed2ba9ed1d5ec8671df97fb4
parent18a6ade6cd638c1e5d2c7c7d044cec0fec5c63d3
PR16726: extend rol/ror matching

C-like languages promote types like unsigned short to unsigned int before
performing an arithmetic operation. Currently the rotate matcher in the
DAGCombiner does not consider this situation.

This commit extends the DAGCombiner in the way that the pattern

(or (shl ([az]ext x), (*ext y)), (srl ([az]ext x), (*ext (sub 32, y))))

is folded into

([az]ext (rotl x, y))

The matching is restricted to aext and zext because in this cases the upper
bits are either undefined or known. Test case is included.

This fixes PR16726.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191045 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/rotate3.ll [new file with mode: 0644]