From owner-cvs-all Mon Sep 11 2:37:12 2000 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id D4BE137B422; Mon, 11 Sep 2000 02:37:05 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id UAA29432; Mon, 11 Sep 2000 20:36:48 +1100 Date: Mon, 11 Sep 2000 20:36:46 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Doug Rabson Cc: John Baldwin , Doug Rabson , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys ktr.h In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 11 Sep 2000, Doug Rabson wrote: > On Mon, 11 Sep 2000, Bruce Evans wrote: > > gcc reduces divisions and moduluses by a (constant) power of 2 to shifts > > and masks fairly well even for signed operations (except possibly for > > quad operations). > > Not this one. With the modulus, the code sequence was something like: > > addl t1, 0x1, t1 > lda t0, 1023(t1) > cmovge t1, t1, t0 > sra t0, 0xa, t0 > sll t0, 0xa, t0 > subl t1, t0, t1 This seems to be reduced fairly well (it has no divisions, if I'm reading it right). The "and" got replaced by a shift-right-shift-left for some reason. The i386 code uses a test-and-branch instead of the conditional move. > and with logical and: > > lda t4, 1023(zero) > addq t0, 0x1, t0 > and t0, t4, t0 > > Also, the compiler managed to mix several other instructions into this > sequence which probably improved pipelining significantly > > The ktr macros are inefficient, so another division wouldn't be much more > > of a disaster for performance. > > The KTR_EXTEND ones are very slow but the non-extended ones are a bit more > reasonable. The KTR_EXTEND version of _TR would be reasonable if it used strncpy() instead of snprintf(). _CTR0 seems to have an array overruns from using memcpy() instead of strncpy(). The portability given by different _CTR macros for different numbers of args is defeated by using gcc's variadic macro feature in NULLFSDEBUG(). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message