public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v1 2/2] x86_64: Add {u}int_fast defs ideal for x86_64
Date: Sun, 10 Apr 2022 20:09:13 -0500	[thread overview]
Message-ID: <20220411010913.1061799-2-goldstein.w.n@gmail.com> (raw)
In-Reply-To: <20220411010913.1061799-1-goldstein.w.n@gmail.com>

{u}int_fast{16|32} should never use 64-bit types. 64-bit instructions
often use more code size (REX prefix) and a variety of instructions are
slower on many implementations (div, bswap, etc...).

Full xcheck passes on x86_64.
---
 sysdeps/x86_64/int-fast.h | 50 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 sysdeps/x86_64/int-fast.h

diff --git a/sysdeps/x86_64/int-fast.h b/sysdeps/x86_64/int-fast.h
new file mode 100644
index 0000000000..8f341de646
--- /dev/null
+++ b/sysdeps/x86_64/int-fast.h
@@ -0,0 +1,50 @@
+/* Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _INT_FAST_X86_64_H
+#define _INT_FAST_X86_64_H	1
+
+#define __HAS_INT_FAST_DEFS	1
+
+/* Signed.  */
+typedef signed char		int_fast8_t;
+/* On x86_64 32-bit instructions are almost always fastest.  */
+typedef int			int_fast16_t;
+typedef int			int_fast32_t;
+typedef long int		int_fast64_t;
+
+/* Unsigned.  */
+typedef unsigned char		uint_fast8_t;
+/* On x86_64 32-bit instructions are almost always fastest.  */
+typedef unsigned int		uint_fast16_t;
+typedef unsigned int		uint_fast32_t;
+typedef unsigned long int	uint_fast64_t;
+
+
+# define __INT_FAST8_BASE		INT8
+# define __INT_FAST16_BASE		INT32
+# define __INT_FAST32_BASE		INT32
+# define __INT_FAST64_BASE		INT64
+
+# define __UINT_FAST8_BASE		UINT8
+# define __UINT_FAST16_BASE		UINT32
+# define __UINT_FAST32_BASE		UINT32
+# define __UINT_FAST64_BASE		UINT64
+
+# include <sysdeps/generic/int-fast.h>
+
+#endif
-- 
2.25.1


  reply	other threads:[~2022-04-11  1:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  1:09 [PATCH v1 1/2] stdlib: Refactor {u}int_fast defs in stdint Noah Goldstein
2022-04-11  1:09 ` Noah Goldstein [this message]
2022-04-11  2:15   ` [PATCH v1 2/2] x86_64: Add {u}int_fast defs ideal for x86_64 Adam Sampson
2022-04-11  6:34     ` Florian Weimer
2022-04-14 22:24   ` Joseph Myers
2022-04-14 22:44     ` Noah Goldstein
2022-04-14 22:21 ` [PATCH v1 1/2] stdlib: Refactor {u}int_fast defs in stdint Joseph Myers

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

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

  git send-email \
    --in-reply-to=20220411010913.1061799-2-goldstein.w.n@gmail.com \
    --to=goldstein.w.n@gmail.com \
    --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).