From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13106 invoked by alias); 24 Jan 2007 21:51:26 -0000 Received: (qmail 13089 invoked by uid 22791); 24 Jan 2007 21:51:25 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Jan 2007 21:51:18 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id l0OLsEr3015506; Wed, 24 Jan 2007 22:54:14 +0100 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id l0OLsEXI015504; Wed, 24 Jan 2007 22:54:14 +0100 Date: Wed, 24 Jan 2007 21:51:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , edwintorok@gmail.com Cc: Glibc hackers Subject: [PATCH] Re: bswap on prescott Message-ID: <20070124215414.GM3819@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek References: <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4354d3270701241326v596084d5m2341d6ce2cfa201f@mail.gmail.com> User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00010.txt.bz2 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 * 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