From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2504 invoked by alias); 12 Oct 2003 03:20:35 -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 2497 invoked from network); 12 Oct 2003 03:20:34 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 12 Oct 2003 03:20:34 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h9C3KXM18414; Sat, 11 Oct 2003 23:20:33 -0400 Received: from speedy.slc.redhat.com (vpn50-14.rdu.redhat.com [172.16.50.14]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h9C3KVr14991; Sat, 11 Oct 2003 23:20:31 -0400 Received: from redhat.com (law@localhost) by speedy.slc.redhat.com (8.12.10/8.12.8/Submit) with ESMTP id h9C3KlMC009932; Sat, 11 Oct 2003 21:20:47 -0600 Message-Id: <200310120320.h9C3KlMC009932@speedy.slc.redhat.com> X-Authentication-Warning: speedy.slc.redhat.com: law owned process doing -bs To: Matthew Wilcox cc: gcc@gcc.gnu.org, acpi-devel@lists.sourceforge.net Reply-To: law@redhat.com Subject: Re: Why does gcc suck at switch()? In-Reply-To: Your message of "Fri, 03 Oct 2003 15:56:14 BST." <20031003145614.GP24824@parcelfarce.linux.theplanet.co.uk> From: law@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 12 Oct 2003 05:49:00 -0000 X-SW-Source: 2003-10/txt/msg00413.txt.bz2 In message <20031003145614.GP24824@parcelfarce.linux.theplanet.co.uk>, Matthew Wilcox writes: > >Why does gcc generate worse code for switch() statements than for >multiple-if? Because it apparently is trying to do the tests in range form rather than naively generating a simple test for each case in the switch (there's no way to actually verify that since you didn't provide a complete testcase). The range-forms can be more effective in some cases or at least that's the claim. I'm not particularly familiar with that code so I've never tried to re-tune it. [ I have noticed it generating spectacularly bad code in certain circumstances, yours may just be another of those cases. ] jeff