From patchwork Tue Jul 17 13:55:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 171433 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 69AE82C0098 for ; Tue, 17 Jul 2012 23:55:49 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343138150; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC: Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=3q3vX1+luscFyfcqsLNxB/X48l8=; b=UhzKSTdgh3+4d2ZmguNP0vlWbBfLuUUv3pJREszjXKH5IBnnNyzqwc8yPDB3Y5 sdAMx7RvXTGnlHA6mwXTUPVa4wTgclC7KwEIJRSIvtn/VN4dfeZoQNLDMXTf7xCN nrYiozqpKoG8fovM7Iu1XQENgLJj9pjuHcbhzqLCpbeaM= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=X6I7be//JvkIHhBXreX569YXLGWSQOeDABdXgBuN02LhvR+LIp7CcRi604pXNe ovsVIEH0Ljm9iTMLFL+CRrmUIdbCGwBkxfbxVWnJq51+vp24ot7tUSjBD2ZEfpQo u1GbabIdaahmT4eQDX6EhyvB89FsohJMq11k8yXTK7Gbw=; Received: (qmail 1497 invoked by alias); 17 Jul 2012 13:55:46 -0000 Received: (qmail 1486 invoked by uid 22791); 17 Jul 2012 13:55:45 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jul 2012 13:55:32 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Sr8FN-0003EA-UN from Tom_deVries@mentor.com ; Tue, 17 Jul 2012 06:55:29 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 17 Jul 2012 06:55:36 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 17 Jul 2012 14:55:28 +0100 Message-ID: <50056ECC.903@mentor.com> Date: Tue, 17 Jul 2012 15:55:24 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Richard Guenther CC: "gcc-patches@gcc.gnu.org" , Jakub Jelinek , Steven Bosscher , Jan Hubicka , Mark Grosberg Subject: Re: [PATCH 2/2] if-to-switch conversion pass -- infrastructure References: <50054A9C.4030404@mentor.com> <50054BA9.5020104@mentor.com> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 17/07/12 13:29, Richard Guenther wrote: > On Tue, Jul 17, 2012 at 1:25 PM, Tom de Vries wrote: >> On 17/07/12 13:21, Tom de Vries wrote: >>> attached patch implements an if-to-switch conversion tree pass >>> pass_if_to_switch. I will follow up this email with an infrastructure patch that >>> provides double_int_popcount and popcount_hwi. >> >> Bootstrapped and reg-tested (Ada inclusive) on x86_64, with pass_if_to_switch as >> only client. >> Mark pointed out that the popcount_hwi function had a bug: The loop should visit all bits of the type but uses sizeof (type) as loop counter which returns the number of bytes of the type. Unit-tested and committed. Thanks, - Tom 2012-07-17 Tom de Vries * hwint.c: Fix loop range. Index: gcc/hwint.c =================================================================== --- gcc/hwint.c (revision 189575) +++ gcc/hwint.c (working copy) @@ -113,8 +113,9 @@ int popcount_hwi (unsigned HOST_WIDE_INT x) { int i, ret = 0; + size_t bits = sizeof (x) * CHAR_BIT; - for (i = 0; i < sizeof (x); i += 1) + for (i = 0; i < bits; i += 1) { ret += x & 1; x >>= 1;