public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Re: bswap on prescott
       [not found] <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com>
@ 2007-01-24 21:51 ` Jakub Jelinek
  2007-01-25  1:23   ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2007-01-24 21:51 UTC (permalink / raw)
  To: Ulrich Drepper, edwintorok; +Cc: Glibc hackers

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

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

* Re: [PATCH] Re: bswap on prescott
  2007-01-24 21:51 ` [PATCH] Re: bswap on prescott Jakub Jelinek
@ 2007-01-25  1:23   ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2007-01-25  1:23 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

It really would be more reasonable if GCC defined some things meaning "this
or later" or "has these features", so that things like this don't have to
change every year to still mean ">= i486".

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

end of thread, other threads:[~2007-01-25  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com>
2007-01-24 21:51 ` [PATCH] Re: bswap on prescott Jakub Jelinek
2007-01-25  1:23   ` Roland McGrath

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