PR16726: extend rol/ror matching
authorKai Nacke <kai.nacke@redstar.de>
Thu, 19 Sep 2013 23:00:28 +0000 (23:00 +0000)
committerKai Nacke <kai.nacke@redstar.de>
Thu, 19 Sep 2013 23:00:28 +0000 (23:00 +0000)
commitd09bb4614b81cb9969240f7db4b706dbd7f61ec6
tree0a14e4de3f792ad7c348aa3cf6ac1aa3d6b30a62
parent2d967b2751924b7904033b6cfc537fd21b33ccaa
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.

llvm-svn: 191049
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/rotate3.ll [new file with mode: 0644]