This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Redundant limit check for switch
- From: "Giovanni Bajo" <rasky at develer dot com>
- To: "Piotr Fusik" <pfusik at op dot pl>
- Cc: <gcc at gcc dot gnu dot org>,"Diego Novillo" <dnovillo at redhat dot com>
- Date: Mon, 22 Aug 2005 13:53:42 +0200
- Subject: Re: Redundant limit check for switch
- References: <20050822075555Z1189347-7791+1182@kps9.test.onet.pl>
Piotr Fusik <pfusik@op.pl> 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"); break;
> case 6: printf("6\n"); break;
> case 7: printf("7\n"); break;
> }
> }
> .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 to optimize them away?
I believe VRP could be taught about inferring ranges from bit_and_expr and
similar operations. Right?
--
Giovanni Bajo