From owner-freebsd-current@FreeBSD.ORG Tue Apr 22 05:56:10 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE3E037B401; Tue, 22 Apr 2003 05:56:10 -0700 (PDT) Received: from HAL9000.homeunix.com (12-233-57-131.client.attbi.com [12.233.57.131]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA26C43FAF; Tue, 22 Apr 2003 05:56:09 -0700 (PDT) (envelope-from das@freebsd.org) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.9/8.12.5) with ESMTP id h3MCu8jC008568; Tue, 22 Apr 2003 05:56:08 -0700 (PDT) (envelope-from das@freebsd.org) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.9/8.12.5/Submit) id h3MCu8r0008567; Tue, 22 Apr 2003 05:56:08 -0700 (PDT) (envelope-from das@freebsd.org) Date: Tue, 22 Apr 2003 05:56:08 -0700 From: David Schultz To: Bruce Evans Message-ID: <20030422125608.GB8074@HAL9000.homeunix.com> Mail-Followup-To: Bruce Evans , Robert Watson , current@freebsd.org, David O'Brien References: <20030420192319.GB4963@HAL9000.homeunix.com> <20030421102341.GA3482@HAL9000.homeunix.com> <20030421231756.H11214@gamplex.bde.org> <20030421211440.GA5507@HAL9000.homeunix.com> <20030422210632.U16843@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030422210632.U16843@gamplex.bde.org> cc: Robert Watson cc: current@freebsd.org Subject: Re: HEADS UP: UFS2 now the default creation type on 5.0-CURRENT X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Apr 2003 12:56:11 -0000 On Tue, Apr 22, 2003, Bruce Evans wrote: > On Mon, 21 Apr 2003, David Schultz wrote: > > > On Mon, Apr 21, 2003, Bruce Evans wrote: > > > On Mon, 21 Apr 2003, David Schultz wrote: > > > > Index: ufsread.c > > > > =================================================================== > > > > RCS file: /cvs/src/sys/boot/common/ufsread.c,v > > > > retrieving revision 1.11 > > > > diff -u -r1.11 ufsread.c > > > > --- ufsread.c 25 Feb 2003 00:10:20 -0000 1.11 > > > > +++ ufsread.c 21 Apr 2003 10:10:01 -0000 > > > > ... > > > > @@ -47,11 +59,11 @@ > > > > ... > > > > -#define FS_TO_VBA(fs, fsb, off) (fsbtodb(fs, fsb) + \ > > > > - ((off) / VBLKSIZE) * DBPERVBLK) > > > > +#define FS_TO_VBA(fs, fsb, off) ma((off) / VBLKSIZE, DBPERVBLK, \ > > > > + fsbtodb((fs), (fsb))) > > > > > > The division by VBLKSIZE should probably be a shift. ufsread.c has > > > VBLKSHIFT and uses it for all multiplications and divisions by VBLKSIZE > > > except this one. gcc can't optimize to just a shift since all the > > > types are signed and C99 specifies that division of negative integers > > > by positive ones has the usual hardware brokenness. > > > > As I recall, signed division gets optimized into a sign test, some > ^ by a power of 2 > > bit fiddling for negative numbers, and a division. The additional > shift > > cost is nominal if you only care about speed, but I'm sure using a > > shift directly would save a few more bytes. > > I tried this, but it had no effect since FS_TO_VBA() is never actually used. > So there is a much better optimization for it :-). I think this makes ma() > unused too. In that case, I'm wondering how I managed to save a few bytes by adding ma(). (Isn't the other macro that uses it expanded twice?) Anyway, when I have time I'll look for a more elegant way to save a few bytes.