public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, edwintorok@gmail.com
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Re: bswap on prescott
Date: Wed, 24 Jan 2007 21:51:00 -0000	[thread overview]
Message-ID: <20070124215414.GM3819@sunsite.mff.cuni.cz> (raw)
In-Reply-To: <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com>

On Wed, Jan 24, 2007 at 11:26:44PM +0200, T?r?k Edvin wrote:
> If I compile a program using ntohl with '-march=prescott -O2', I get 3
> ror instr., however if I compile it with '-march=pentium4 -O2', I get
> the bswap instr.
> 
> Looking at bits/byteswap.h, it seems that prescott is missing from the list:
> 
> # if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__           
> \
>                          || defined __pentiumpro__ || defined __pentium4__  
>                          \
>                          || defined __k8__ || defined __athlon__            
>                          \
>                          || defined __k6__)
> [...]
> __asm__ ("bswap %0",...
> 
> Is this intended behaviour? Which is faster on prescott: bswap, or the
> 3 rotations?

No, byteswap.h just didn't keep with the speed of new -march macro additions
in GCC.  This adds what has been added recently:

2007-01-24  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/i386/bits/byteswap.h (__bswap_32): Add __nocona__, __core2__
	and __geode__ to the list of i486+ CPUs.
	* sysdeps/x86_64/bits/byteswap.h (__bswap_32): Likewise.

--- libc/sysdeps/i386/bits/byteswap.h.jj	2006-08-24 09:02:16.000000000 +0200
+++ libc/sysdeps/i386/bits/byteswap.h	2007-01-24 22:34:45.000000000 +0100
@@ -1,5 +1,6 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997,1998,2000,2002,2003,2006 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2006, 2007
+   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
@@ -66,7 +67,8 @@ __bswap_16 (unsigned short int __bsx)
    `bswap' opcode.  On i386 we have to use three instructions.  */
 #  if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__ \
       && !defined __pentium4__ && !defined __k8__ && !defined __athlon__ \
-      && !defined __k6__
+      && !defined __k6__ && !defined __nocona__ && !defined __core2__ \
+      && !defined __geode__
 #   define __bswap_32(x)						      \
      (__extension__							      \
       ({ register unsigned int __v, __x = (x);				      \
--- libc/sysdeps/x86_64/bits/byteswap.h.jj	2003-08-17 08:32:00.000000000 +0200
+++ libc/sysdeps/x86_64/bits/byteswap.h	2007-01-24 22:35:36.000000000 +0100
@@ -1,5 +1,6 @@
 /* Macros to swap the order of bytes in integer values.
-   Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2000, 2002, 2003, 2007
+   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
@@ -59,7 +60,8 @@
 # if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__	      \
 			  || defined __pentiumpro__ || defined __pentium4__   \
 			  || defined __k8__ || defined __athlon__	      \
-			  || defined __k6__)
+			  || defined __k6__ || defined __nocona__	      \
+			  || defined __core2__ || defined __geode__)
 /* To swap the bytes in a word the i486 processors and up provide the
    `bswap' opcode.  On i386 we have to use three instructions.  */
 #  define __bswap_32(x) \

	Jakub

       reply	other threads:[~2007-01-24 21:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com>
2007-01-24 21:51 ` Jakub Jelinek [this message]
2007-01-25  1:23   ` Roland McGrath

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=20070124215414.GM3819@sunsite.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=edwintorok@gmail.com \
    --cc=libc-hacker@sources.redhat.com \
    /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).