public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/18] Improve generic string routines
@ 2018-01-10 12:48 Adhemerval Zanella
  2018-01-10 12:48 ` [PATCH v3 07/18] string: Improve generic memrchr Adhemerval Zanella
                   ` (18 more replies)
  0 siblings, 19 replies; 46+ messages in thread
From: Adhemerval Zanella @ 2018-01-10 12:48 UTC (permalink / raw)
  To: libc-alpha

It is an update of previous Richard's patchset [1] to provide generic 
string implementation for newer ports and make them only focus on 
just specific routines to get a better overall improvement.
It is done by:

  1. parametrizing the internal routines (for instance the find zero
     in a word) so each architecture can reimplement without the need
     to reimplement the whole routine.

  2. vectorizing more string implementations (for instance strcpy 
     and strcmp).

  3. Change some implementations to use already possible optimized
     ones (for instance strnlen).  It makes new ports to focus on
     only provide optimized implementation of a hardful symbols
     (for instance memchr) and make its improvement to be used in
     a larger set of routines.

For the rest of #5806 I think we can handle them later and if 
performance of generic implementation is closer I think it is better
to just remove old assembly implementations.

I also checked on x86_64-linux-gnu, i686-linux-gnu, sparc64-linux-gnu,
and sparcv9-linux-gnu by removing the arch-specific assembly 
implementation and disabling multiarch (it covers both LE and BE
for 64 and 32 bits). I also checked the string routines on alpha, hppa,
and sh.

Changes since v2:

  * Move string-fz{a,b,i} to its own patch.
 
  * Add a inline implementation for __builtin_c{l,t}z to avoid using
    compiler provided symbols.

  * Add a new header, string-maskoff.h, to handle unaligned accesses
    on some implementation.

  * Fixed strcmp on LE machines.

  * Added a unaligned strcpy variant for architecture that define
    _STRING_ARCH_unaligned.

  * Add SH string-fzb.h (which uses cmp/str instruction to find
    a zero in word).

Changes since v1:

  * Marked ChangeLog entries with [BZ #5806], as appropriate.

  * Reorganized the headers, so that armv6t2 and power6 need override
    as little as possible to use their (integer) zero detection insns.

  * Hopefully fixed all of the coding style issues.

  * Adjusted the memrchr algorithm as discussed.

  * Replaced the #ifdef STRRCHR etc that are used by the multiarch files.

  * Tested on i386, i686, x86_64 (verified this is unused), ppc64,
    ppc64le --with-cpu=power8 (to use power6 in multiarch), armv7,
    aarch64, alpha (qemu) and hppa (qemu).

PS: This patchset is aimed for 2.28.

[1] https://sourceware.org/ml/libc-alpha/2016-12/msg00830.html

Adhemerval Zanella (5):
  Add string-maskoff.h generic header
  Add string vectorized find and detection functions
  string: Improve generic strnlen
  string: Improve generic strcpy
  sh: Add string-fzb.h

Richard Henderson (13):
  Parameterize op_t from memcopy.h
  Parameterize OP_T_THRES from memcopy.h
  string: Improve generic strlen
  string: Improve generic memchr
  string: Improve generic memrchr
  string: Improve generic strchr
  string: Improve generic strchrnul
  string: Improve generic strcmp
  hppa: Add memcopy.h
  hppa: Add string-fzb.h and string-fzi.h
  alpha: Add string-fzb.h and string-fzi.h
  arm: Add string-fza.h
  powerpc: Add string-fza.h

 config.h.in                                        |   8 +
 configure                                          |  54 ++++++
 configure.ac                                       |  34 ++++
 string/memchr.c                                    | 157 ++++-----------
 string/memcmp.c                                    |   4 -
 string/memrchr.c                                   | 193 ++++--------------
 string/strchr.c                                    | 166 +++-------------
 string/strchrnul.c                                 | 146 +++-----------
 string/strcmp.c                                    |  97 +++++++++-
 string/strcpy.c                                    | 109 ++++++++++-
 string/strlen.c                                    |  83 ++------
 string/strnlen.c                                   | 139 +------------
 string/test-strcpy.c                               |  24 ++-
 sysdeps/alpha/string-fzb.h                         |  51 +++++
 sysdeps/alpha/string-fzi.h                         | 113 +++++++++++
 sysdeps/arm/armv6t2/string-fza.h                   |  69 +++++++
 sysdeps/generic/memcopy.h                          |  11 +-
 sysdeps/generic/string-extbyte.h                   |  35 ++++
 sysdeps/generic/string-fza.h                       | 117 +++++++++++
 sysdeps/generic/string-fzb.h                       |  49 +++++
 sysdeps/generic/string-fzi.h                       | 215 +++++++++++++++++++++
 sysdeps/generic/string-maskoff.h                   |  64 ++++++
 sysdeps/generic/string-opthr.h                     |  25 +++
 sysdeps/generic/string-optype.h                    |  31 +++
 sysdeps/hppa/memcopy.h                             |  44 +++++
 sysdeps/hppa/string-fzb.h                          |  69 +++++++
 sysdeps/hppa/string-fzi.h                          | 135 +++++++++++++
 sysdeps/i386/i686/multiarch/memrchr-c.c            |   2 +
 sysdeps/i386/i686/multiarch/strnlen-c.c            |  19 +-
 sysdeps/i386/memcopy.h                             |   3 -
 sysdeps/i386/string-opthr.h                        |  25 +++
 sysdeps/m68k/memcopy.h                             |   3 -
 sysdeps/powerpc/power6/string-fza.h                |  65 +++++++
 sysdeps/powerpc/powerpc32/power4/memcopy.h         |   5 -
 .../powerpc32/power4/multiarch/strnlen-ppc32.c     |  19 +-
 sysdeps/powerpc/powerpc32/power6/string-fza.h      |   1 +
 sysdeps/powerpc/powerpc64/power6/string-fza.h      |   1 +
 sysdeps/s390/multiarch/memrchr-c.c                 |   2 +
 sysdeps/s390/multiarch/strchr-c.c                  |   1 +
 sysdeps/s390/multiarch/strnlen-c.c                 |  18 +-
 sysdeps/sh/string-fzb.h                            |  53 +++++
 sysdeps/tile/memcmp.c                              |   1 -
 sysdeps/tile/memcopy.h                             |   7 -
 sysdeps/tile/tilegx32/gmp-mparam.h                 |  30 +++
 44 files changed, 1707 insertions(+), 790 deletions(-)
 create mode 100644 sysdeps/alpha/string-fzb.h
 create mode 100644 sysdeps/alpha/string-fzi.h
 create mode 100644 sysdeps/arm/armv6t2/string-fza.h
 create mode 100644 sysdeps/generic/string-extbyte.h
 create mode 100644 sysdeps/generic/string-fza.h
 create mode 100644 sysdeps/generic/string-fzb.h
 create mode 100644 sysdeps/generic/string-fzi.h
 create mode 100644 sysdeps/generic/string-maskoff.h
 create mode 100644 sysdeps/generic/string-opthr.h
 create mode 100644 sysdeps/generic/string-optype.h
 create mode 100644 sysdeps/hppa/memcopy.h
 create mode 100644 sysdeps/hppa/string-fzb.h
 create mode 100644 sysdeps/hppa/string-fzi.h
 create mode 100644 sysdeps/i386/string-opthr.h
 create mode 100644 sysdeps/powerpc/power6/string-fza.h
 create mode 100644 sysdeps/powerpc/powerpc32/power6/string-fza.h
 create mode 100644 sysdeps/powerpc/powerpc64/power6/string-fza.h
 create mode 100644 sysdeps/sh/string-fzb.h
 create mode 100644 sysdeps/tile/tilegx32/gmp-mparam.h

-- 
2.7.4

^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: [PATCH v3 04/18] Add string vectorized find and detection functions
@ 2018-01-11 19:36 Wilco Dijkstra
  0 siblings, 0 replies; 46+ messages in thread
From: Wilco Dijkstra @ 2018-01-11 19:36 UTC (permalink / raw)
  To: adhemerval.zanella; +Cc: nd, libc-alpha

Hi,

I haven't looked at it in detail, but this immediately stands out:

>> +static inline unsigned
>> +__clz (op_t x)

The point being that we're working on bytes so we're not interested in the first/last
set bit, but first/last non-zero byte. That simplifies the implementation for targets
that don't support clz/ctz as now we only have 4 or 8 possible values to return
instead of 32 or 64.

Wilco

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

end of thread, other threads:[~2018-01-12 18:37 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 12:48 [PATCH v3 00/18] Improve generic string routines Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 07/18] string: Improve generic memrchr Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 14/18] hppa: Add string-fzb.h and string-fzi.h Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 03/18] Add string-maskoff.h generic header Adhemerval Zanella
2018-01-10 23:25   ` Paul Eggert
2018-01-11 10:54     ` Adhemerval Zanella
2018-01-11 13:29   ` Joseph Myers
2018-01-11 17:57     ` Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 05/18] string: Improve generic strlen Adhemerval Zanella
2018-01-11 17:21   ` Paul Eggert
2018-01-12 18:00     ` Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 16/18] arm: Add string-fza.h Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 10/18] string: Improve generic strchrnul Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 15/18] alpha: Add string-fzb.h and string-fzi.h Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 09/18] string: Improve generic strchr Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 01/18] Parameterize op_t from memcopy.h Adhemerval Zanella
2018-01-11 13:28   ` Joseph Myers
2018-01-11 18:04     ` Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 12/18] string: Improve generic strcpy Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 13/18] hppa: Add memcopy.h Adhemerval Zanella
2018-01-11 13:36   ` Joseph Myers
2018-01-12 18:01     ` Adhemerval Zanella
2018-01-12 18:18       ` Joseph Myers
2018-01-12 18:37         ` Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 18/18] sh: Add string-fzb.h Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 17/18] powerpc: Add string-fza.h Adhemerval Zanella
2018-01-10 12:56   ` Tulio Magno Quites Machado Filho
2018-01-10 12:48 ` [PATCH v3 06/18] string: Improve generic memchr Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 11/18] string: Improve generic strcmp Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 04/18] Add string vectorized find and detection functions Adhemerval Zanella
2018-01-11 13:34   ` Joseph Myers
2018-01-11 18:25     ` Adhemerval Zanella
2018-01-11 13:44   ` Luis Machado
2018-01-11 18:25     ` Adhemerval Zanella
2018-01-11 16:47   ` Paul Eggert
2018-01-11 18:54     ` Adhemerval Zanella
2018-01-12  1:08       ` Paul Eggert
2018-01-12 17:08         ` Joseph Myers
2018-01-12 17:59           ` Adhemerval Zanella
2018-01-12 13:30       ` Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 02/18] Parameterize OP_T_THRES from memcopy.h Adhemerval Zanella
2018-01-10 12:48 ` [PATCH v3 08/18] string: Improve generic strnlen Adhemerval Zanella
2018-01-10 22:30 ` [PATCH v3 00/18] Improve generic string routines Ondřej Bílka
2018-01-11 10:54   ` Adhemerval Zanella
2018-01-11 13:50     ` Joseph Myers
2018-01-11 19:36 [PATCH v3 04/18] Add string vectorized find and detection functions Wilco Dijkstra

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).