We have RROTATE_EXPR and LROTATE_EXPR, but the patterns are not reliably detected at the tree level. I'm attaching a testcase reduced from the Linux kernel, which has at least one sequence that can be rewritten using a rolw instruction:
movzwl %cx, %edx movzwl %ax, %eax shrw $8, %cx movl %edx, -44(%ebp) sall $8, %edx movw %cx, -50(%ebp) orw %dx, -50(%ebp) Other opportunities exist. At the most basic level, a function like unsigned short rol8 (unsigned short word, unsigned int shift) { return (word << 8) | (word >> 8); } should be transformed at the tree level by recognizing the rotate. -- Summary: Rotate expressions not recognized at tree level Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bernds at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45216