https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107671
--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> --- Created attachment 53901 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53901&action=edit Patch that adds relevant zero_extract patterns This patch adds relevant zero_extract patterns that optimize: return ((v & (1 << (bitnum & 31)))) != 0; return ((v & (1L << (bitnum & 63)))) != 0; return (v >> (bitnum & 31)) & 1; return (v >> (bitnum & 63)) & 1; from: movl %esi, %ecx movl $1, %eax sall %cl, %eax testl %edi, %eax setne %al movzbl %al, %eax to: xorl %eax, %eax btl %esi, %edi setc %al The patch adapts *jcc_bt patterns to similar *scc_bt patterns. Please note that the patch optimizes only to SETB conditional set instruction, since it builds on a combine transformation to the ZERO_EXTRACT rtx.