From patchwork Wed Aug 19 15:02:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 508764 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A6B42140D4D for ; Thu, 20 Aug 2015 01:03:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JlRTcDDI; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=JTFQNXyv3e88eXa19xZxqgkgfpFaPPcWx/UZnYTuMae LCgSEDTCa8/uZoWNO0p4XVl57lNH6E/Q2sKSHqfdQB78vTaFe2Uz9RA/I8V10SaA yOj1gBFjtH1AInWw6G+tTg27jvojWwGlEmm+CFCp6GF63T+4Pi914YrZkssgDP6w = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=ag8luxHuZkMg1TBlLY2gsAJkg6Q=; b=JlRTcDDIzhjv+52ss vOrfTBc5D9XX5Xi0sGl+27HDSM8JaiaUkjywWt/R/U28TFFc0mQ7oVJgpounbMBb Fb8Xa0wW4tithSDoeoDEpkcROl7IOp/rBcbb0h5p/6bHYguL2vZeWtUDS+x4hiyX KRE3lQCIYSoZ3gkjXRQZxQgq7k= Received: (qmail 71183 invoked by alias); 19 Aug 2015 15:02:58 -0000 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 Received: (qmail 70569 invoked by uid 89); 19 Aug 2015 15:02:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Aug 2015 15:02:46 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-18-Vl3v8AjRSVWJCVoNqCemRg-1; Wed, 19 Aug 2015 16:02:42 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 19 Aug 2015 16:02:41 +0100 Message-ID: <55D49A91.9070503@arm.com> Date: Wed, 19 Aug 2015 16:02:41 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: [PATCH][AArch64] Use popcount_hwi instead of homebrew version X-MC-Unique: Vl3v8AjRSVWJCVoNqCemRg-1 X-IsSubscribed: yes Hi all, I noticed we have a hand-crafted "bit_count" function in the aarch64 backend that implements the popcount operation. We already have a midend popcount_hwi function operating on HOST_WIDE_INTs which seems to be exactly what we need. This patch removes the aarch64-specific version and updates the one callsite where it's used, the '%P' output operand, which itself is only used by the *andim_ashift_bfiz pattern in aarch64.md. Bootstrapped and tested on aarch64. Ok for trunk? Thanks, Kyrill 2015-08-19 Kyrylo Tkachov * config/aarch64/aarch64.c (bit_count): Delete prototype and definition. (aarch64_print_operand): Use popcount_hwi instead of the above. commit d52a7d4a0a4e1a8bcf11e549ded207851b6086b3 Author: Kyrylo Tkachov Date: Wed Aug 19 14:28:45 2015 +0100 [AArch64] Use popcount_hwi instead of homebrew version diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b16e511..86eabac 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -150,7 +150,6 @@ static void aarch64_elf_asm_constructor (rtx, int) ATTRIBUTE_UNUSED; static void aarch64_elf_asm_destructor (rtx, int) ATTRIBUTE_UNUSED; static void aarch64_override_options_after_change (void); static bool aarch64_vector_mode_supported_p (machine_mode); -static unsigned bit_count (unsigned HOST_WIDE_INT); static bool aarch64_vectorize_vec_perm_const_ok (machine_mode vmode, const unsigned char *sel); static int aarch64_address_cost (rtx, machine_mode, addr_space_t, bool); @@ -4170,19 +4169,6 @@ aarch64_const_vec_all_same_int_p (rtx x, HOST_WIDE_INT val) return aarch64_const_vec_all_same_in_range_p (x, val, val); } -static unsigned -bit_count (unsigned HOST_WIDE_INT value) -{ - unsigned count = 0; - - while (value) - { - count++; - value &= value - 1; - } - - return count; -} /* N Z C V. */ #define AARCH64_CC_V 1 @@ -4337,7 +4323,7 @@ aarch64_print_operand (FILE *f, rtx x, char code) return; } - asm_fprintf (f, "%u", bit_count (INTVAL (x))); + asm_fprintf (f, "%u", popcount_hwi (INTVAL (x))); break; case 'H':