public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AArch64] Use popcount_hwi instead of homebrew version
@ 2015-08-19 15:05 Kyrill Tkachov
  2015-08-19 15:16 ` James Greenhalgh
  0 siblings, 1 reply; 2+ messages in thread
From: Kyrill Tkachov @ 2015-08-19 15:05 UTC (permalink / raw)
  To: GCC Patches; +Cc: Marcus Shawcroft, Richard Earnshaw, James Greenhalgh

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

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<mode>_bfiz pattern in aarch64.md.

Bootstrapped and tested on aarch64.

Ok for trunk?

Thanks,
Kyrill

2015-08-19  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/aarch64/aarch64.c (bit_count): Delete prototype
     and definition.
     (aarch64_print_operand): Use popcount_hwi instead of the above.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: aarch64-popcount.patch --]
[-- Type: text/x-patch; name=aarch64-popcount.patch, Size: 1535 bytes --]

commit d52a7d4a0a4e1a8bcf11e549ded207851b6086b3
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
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':

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][AArch64] Use popcount_hwi instead of homebrew version
  2015-08-19 15:05 [PATCH][AArch64] Use popcount_hwi instead of homebrew version Kyrill Tkachov
@ 2015-08-19 15:16 ` James Greenhalgh
  0 siblings, 0 replies; 2+ messages in thread
From: James Greenhalgh @ 2015-08-19 15:16 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Marcus Shawcroft, Richard Earnshaw

On Wed, Aug 19, 2015 at 04:02:41PM +0100, Kyrill Tkachov wrote:
> 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<mode>_bfiz pattern in aarch64.md.
> 
> Bootstrapped and tested on aarch64.
> 
> Ok for trunk?

OK. A change like this which performs useful cleanup is borderline
obvious.

Thanks,
James

> 
> Thanks,
> Kyrill
> 
> 2015-08-19  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
> 
>      * config/aarch64/aarch64.c (bit_count): Delete prototype
>      and definition.
>      (aarch64_print_operand): Use popcount_hwi instead of the above.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-19 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-19 15:05 [PATCH][AArch64] Use popcount_hwi instead of homebrew version Kyrill Tkachov
2015-08-19 15:16 ` James Greenhalgh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).