http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46935
Summary: We should recognize expanded switch statement and convert 2 way switch statements into shift & mask test Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassig...@gcc.gnu.org ReportedBy: hubi...@gcc.gnu.org As observed at http://blog.regehr.org/archives/320 (example 7) testcase: int crud (unsigned char c) { return (((((((((((int) c <= 32 || (int) c == 46) || (int) c == 44) || (int) c == 58) || (int) c == 59) || (int) c == 60) || (int) c == 62) || (int) c == 34) || (int) c == 92) || (int) c == 39) != 0); } Can be compiled using shift and mask test operation as: crud: movzbl %dil, %edi cmpl $32, %edi jle ..B1.4 addl $-34, %edi cmpl $64, %edi jae ..B1.5 movl $1, %eax movl %edi, %ecx shlq %cl, %rax movq $0x400000017001421, %rdx testq %rdx, %rax je ..B1.5 ..B1.4: movl $1, %eax ret ..B1.5: xorl %eax, %eax ret Probably switch conversion pass could be responsible for this. Honza