[PATCH] DAGCombiner: Add another rotate pattern.

David Majnemer david.majnemer at gmail.com
Thu Jul 18 04:08:50 PDT 2013


It is not uncommon to see code like the following:

(x << n) | (x >> (-n & 31))

This is convenient because it properly handles the cases where n is zero
whereas:

(x << n) | (x >> (32 - n))

suffers from undefined behavior in that case.

The attached patch teaches SelectionDAG's DAGCombiner how to fold the first
pattern into a rotation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130718/da7b5be7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotate.diff
Type: application/octet-stream
Size: 4930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130718/da7b5be7/attachment.obj>


More information about the llvm-commits mailing list