From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3118 invoked by alias); 11 Feb 2008 19:31:31 -0000 Received: (qmail 3106 invoked by uid 22791); 11 Feb 2008 19:31:31 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 11 Feb 2008 19:31:04 +0000 Received: from zps38.corp.google.com (zps38.corp.google.com [172.25.146.38]) by smtp-out.google.com with ESMTP id m1BJUvG6021105; Mon, 11 Feb 2008 19:30:58 GMT Received: from smtp.corp.google.com (spacemonkey1.corp.google.com [192.168.120.115]) by zps38.corp.google.com with ESMTP id m1BJUswL005469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 11 Feb 2008 11:30:54 -0800 Received: from localhost.localdomain.google.com (adsl-76-249-168-94.dsl.pltn13.sbcglobal.net [76.249.168.94]) (authenticated bits=0) by smtp.corp.google.com (8.13.8/8.13.8) with ESMTP id m1BJUrsK016014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 11 Feb 2008 11:30:54 -0800 To: "Godmar Back" Cc: gcc-help@gcc.gnu.org Subject: Re: optimization of switch statements on i386 References: <719dced30802081629g19f67f6fi76dfaa0ede35b7aa@mail.gmail.com> <719dced30802081630q6fca95a4u747533463c9177f7@mail.gmail.com> <719dced30802081901j4db41c18wbb930be9d9791e4c@mail.gmail.com> <719dced30802111013j661b2e25u45e5c775f6a8a2ec@mail.gmail.com> From: Ian Lance Taylor Date: Mon, 11 Feb 2008 19:31:00 -0000 In-Reply-To: <719dced30802111013j661b2e25u45e5c775f6a8a2ec@mail.gmail.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg00082.txt.bz2 "Godmar Back" writes: > Thanks. I did see that gcc_unreachable() showed up as a symbol in the > assembly (consistent with it not meaning anything special); I suppose > I was misled by this comment in the gcc coding conventions at > http://gcc.gnu.org/codingconventions.html > > "Use gcc_unreachable() to mark places that should never be reachable > (such as an unreachable default case of a switch). Do not use > gcc_assert(0) for such purposes, as gcc_unreachable gives the compiler > more information." > > Apparently, this discussion refers to the (currently executing) > compiler, not the compiler used to compile the gcc code. Those coding convention are for people working on gcc itself, not for people using gcc. > I assume a corollary of that statement is that there is no way to > trick the compiler into omitting the default branch without incurring > runtime checks (or is there a clever way I'm not realizing)? In general, yes. There has been some discussion of implementing __builtin_unreachable() which would direct the optimizers to assume that the code path was never taken. Howver, as far as I know no actual woek has been done on this. Ian