This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Re: bswap on prescott


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]