unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Cc: "Gabriel F . T . Gomes" <gabriel@inconstante.eti.br>
Subject: [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr
Date: Wed, 13 Mar 2019 11:03:16 -0300	[thread overview]
Message-ID: <20190313140317.8894-5-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20190313140317.8894-1-adhemerval.zanella@linaro.org>

This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

	* wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize
	the loop unroll.
---
 wcsmbs/wcsrchr.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/wcsmbs/wcsrchr.c b/wcsmbs/wcsrchr.c
index 0d4bad0704..3175df357d 100644
--- a/wcsmbs/wcsrchr.c
+++ b/wcsmbs/wcsrchr.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
+#include <loop_unroll.h>
 
 #ifndef WCSRCHR
 # define WCSRCHR wcsrchr
@@ -26,12 +27,21 @@
 wchar_t *
 WCSRCHR (const wchar_t *wcs, const wchar_t wc)
 {
-  const wchar_t *retval = NULL;
+  wchar_t *retval = NULL;
 
-  do
-    if (*wcs == wc)
-      retval = wcs;
-  while (*wcs++ != L'\0');
+#define ITERATION(index)		\
+  ({					\
+    if (*wcs == wc)			\
+      retval = (wchar_t*) wcs;		\
+    *wcs++ != L'\0';	\
+  })
 
-  return (wchar_t *) retval;
+#ifndef UNROLL_NTIMES
+# define UNROLL_NTIMES 1
+#endif
+
+  while (1)
+    UNROLL_REPEAT(UNROLL_NTIMES, ITERATION);
+
+  return retval;
 }
-- 
2.17.1


  parent reply	other threads:[~2019-03-13 14:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 14:03 [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Adhemerval Zanella
2019-03-13 14:03 ` [PATCH v2 2/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
2019-03-23 14:56   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 3/6] wcsmbs: Use loop_unroll on wcschr Adhemerval Zanella
2019-03-23 15:00   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 4/6] powerpc: Use generic wcschr optimization Adhemerval Zanella
2019-03-23 15:00   ` Gabriel F. T. Gomes
2019-03-13 14:03 ` Adhemerval Zanella [this message]
2019-03-23 15:00   ` [PATCH v2 5/6] wcsmbs: Use loop_unroll on wcsrchr Gabriel F. T. Gomes
2019-03-13 14:03 ` [PATCH v2 6/6] powerpc: Use generic wcscpy optimization Adhemerval Zanella
2019-03-23 15:01   ` Gabriel F. T. Gomes
2019-03-23 15:00 ` [PATCH v2 1/6] wcsmbs: Add wcscpy loop unroll option Gabriel F. T. Gomes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313140317.8894-5-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=gabriel@inconstante.eti.br \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).