I know nothing about GCC internals, but it appears that it knows
which bits are used in expressions:
unsigned char foo(int x) {
return (x + 1) & 0x0f & 0x0c & 0x3ff;
}
.file "test.c"
.section .text
.p2align 4,,15
.globl _foo
_foo:
pushl %ebp
movl %esp, %ebp
movb 8(%ebp), %al
popl %ebp
in
The following code:
#include
void Switch4(int x) {
switch (x & 7) {
case 0: printf("0\n"); break;
case 1: printf("1\n"); break;
case 2: printf("2\n"); break;
case 3: printf("3\n"); break;
case 4: printf("4\n"); break;
case 5: printf("5\n"); break;
case 6: printf("