From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11690 invoked by alias); 11 Oct 2002 20:22:33 -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 11681 invoked from network); 11 Oct 2002 20:22:32 -0000 Received: from unknown (HELO web80303.mail.yahoo.com) (66.218.79.19) by sources.redhat.com with SMTP; 11 Oct 2002 20:22:32 -0000 Message-ID: <20021011202232.85226.qmail@web80303.mail.yahoo.com> Received: from [206.149.208.33] by web80303.mail.yahoo.com via HTTP; Fri, 11 Oct 2002 13:22:32 PDT Date: Fri, 11 Oct 2002 15:12:00 -0000 From: Kevin Lawton Subject: Re: Request of new __attribute__ for switch statements (elimination of the bounds check) To: Robert Dewar , gcc@gcc.gnu.org In-Reply-To: <20021011190858.BB0D0F2DF6@nile.gnat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-10/txt/msg00629.txt.bz2 --- Robert Dewar wrote: > < a bounds check on the switch variable 'byte'. All of the target > space is covered. > > To solve this, could we add an attribute to switch? > > switch (byte) __attribute (( no-bounds-check )) { > ... > } > >> > > Surely this is NOT the solution in a case when it is obvious that no > check is needed. We have noticed this junk check being a problem in > GNAT, and what we do is to turn the last case into a default, but this > of course is definitely not optimial. It may not always be easy for the compiler to know. If GCC could eliminate the unnecessary check for the obvious cases, that'd be great. But such an attribute (or whatever method you propose) is needed when the programmer knows more about the data flow than the compiler. Which for high performance programs, tends to be quite a few. 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. -Kevin __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com