Date: Mon, 11 Sep 2000 20:36:46 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Doug Rabson <dfr@nlsystems.com> Cc: John Baldwin <jhb@pike.osd.bsdi.com>, Doug Rabson <dfr@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys ktr.h Message-ID: <Pine.BSF.4.21.0009112012540.955-100000@besplex.bde.org> In-Reply-To: <Pine.BSF.4.21.0009110944090.49106-100000@salmon.nlsystems.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0009112012540.955-100000>