From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25000 invoked by alias); 12 Oct 2002 04:23:30 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 24991 invoked from network); 12 Oct 2002 04:23:29 -0000 Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200) by sources.redhat.com with SMTP; 12 Oct 2002 04:23:29 -0000 Received: from free.redhat.lsd.ic.unicamp.br (aoliva2.cipe.redhat.com [10.0.1.156]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id g9C4NQP01607; Sat, 12 Oct 2002 00:23:26 -0400 Received: from free.redhat.lsd.ic.unicamp.br (localhost.localdomain [127.0.0.1]) by free.redhat.lsd.ic.unicamp.br (8.12.5/8.12.5) with ESMTP id g9C4NPZ0029466; Sat, 12 Oct 2002 01:23:25 -0300 Received: (from aoliva@localhost) by free.redhat.lsd.ic.unicamp.br (8.12.5/8.12.5/Submit) id g9C4NNWV029462; Sat, 12 Oct 2002 01:23:23 -0300 To: Kevin Lawton Cc: Robert Dewar , gcc@gcc.gnu.org Subject: Re: Request of new __attribute__ for switch statements (elimination of the bounds check) References: <20021011202232.85226.qmail@web80303.mail.yahoo.com> From: Alexandre Oliva Organization: GCC Team, Red Hat Date: Sat, 12 Oct 2002 10:43:00 -0000 In-Reply-To: <20021011202232.85226.qmail@web80303.mail.yahoo.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-10/txt/msg00643.txt.bz2 On Oct 11, 2002, Kevin Lawton wrote: > I haven't tried turning the last case into the default, but I > can't see how that eliminates a check, so I'm not clear on the > win there. it (kind of) turns: if (x == 255) goto case_255; ... else if (x == 0) goto case_0; else /* do nothing */; into if ((unsigned)x >= 255) goto case_255; ... else if (x == 0) goto case_0; Admittedly, this is still not as efficient as the compiler knowing that x is in [0,255] and just loading the jump from a jump table, but it's already some improvement. -- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist Professional serial bug killer