Re: Redundant limit check for switch

2005-08-28 Thread Paolo Bonzini
Why can't this information be used to optimize comparisons? My patch caused GCC to infer that x & 7 > 7 is false. But I couldn't think of a quick way to use this to optimize away the check, because then GCC crashed. Does it work only for consecutive ands? Or is it just an early constant

Re: Redundant limit check for switch

2005-08-27 Thread Piotr Fusik
? Piotr - Original Message - From: "Paolo Bonzini" <[EMAIL PROTECTED]> To: "GCC Development" ; <[EMAIL PROTECTED]>; "Diego Novillo" <[EMAIL PROTECTED]>; "Giovanni Bajo" <[EMAIL PROTECTED]> Sent: Monday, Au

Re: Redundant limit check for switch

2005-08-22 Thread Paolo Bonzini
void Switch4(int x) { switch (x & 7) { } } >> .globl _Switch4 .def _Switch4; .scl 2; .type 32; .endef _Switch4: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax andl $7, %eax cmpl $7, %eax ja L12 jmp *L11(,%eax,4) cmpl+ja are redundant in both cases. Do you think it is possible for gcc t

Re: Redundant limit check for switch

2005-08-22 Thread Giovanni Bajo
Piotr Fusik <[EMAIL PROTECTED]> wrote: > 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"); bre