From owner-freebsd-stable Thu Oct 8 17:01:13 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA23990 for freebsd-stable-outgoing; Thu, 8 Oct 1998 17:01:13 -0700 (PDT) (envelope-from owner-freebsd-stable@FreeBSD.ORG) Received: from xylan.com (postal.xylan.com [208.8.0.248]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA23967 for ; Thu, 8 Oct 1998 17:00:50 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from mailhub.xylan.com by xylan.com (8.8.7/SMI-SVR4 (xylan-mgw 2.2 [OUT])) id RAA18627; Thu, 8 Oct 1998 17:00:30 -0700 (PDT) Received: from utah.XYLAN.COM by mailhub.xylan.com (SMI-8.6/SMI-SVR4 (mailhub 2.1 [HUB])) id RAA14041; Thu, 8 Oct 1998 17:00:30 -0700 Received: from softweyr.com by utah.XYLAN.COM (SMI-8.6/SMI-SVR4 (xylan utah [SPOOL])) id SAA15575; Thu, 8 Oct 1998 18:00:29 -0600 Message-ID: <361D521D.CFF9305C@softweyr.com> Date: Thu, 08 Oct 1998 18:00:29 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.07 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) MIME-Version: 1.0 To: Peter Jeremy CC: freebsd-stable@FreeBSD.ORG Subject: Re: Global register variables in gcc and stdio.h?!? References: <98Oct9.071633est.40326@border.alcanet.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Wes Peters wrote: % The compiler is a whole lot smarter about register allocation than % you are, especially on an architecture where there aren't any. Peter Jeremy wrote: > Actually, on a true 0 or 1-address architecture, register allocation > is trivial. The real difficulties occur with architectures that have > a small number of registers which aren't quite all general purpose. Like the x86. Remember AX = accumulator, BX = base, CX = counter, DX = destination, SI = source index, DI = destination index, etc? Yes, I KNOW most programmers use SI and DI like they're general purpose registers, but they're really not. I will amend my original statement, at least for x86, to "The compiler is a whole lot better than you at NOT screwing up it's register allocation and getting something out of whack." As was posted in another response, the best way to approach this is to write the code in the most obvious fashion possible, get it completely and thoroughly debugged, then time it to see if it meets it's goals. If so, LEAVE IT ALONE! If not, profile the code to determine where you can do some good, and optimize the top 1 or 2 functions. Repeat until done. Once you start delving into register allocation to solve performance problems, you're getting to the point where you need to isolate the real performance bottleneck and code that (and ONLY that) in assembler, using somebody who's really good. Especially on the fart-brained x86. (Registers? Huh? Why would you want registers, you already have RAM!) -- Where am I, and what am I doing in this handbasket? Wes Peters +1.801.915.2061 Softweyr LLC wes@softweyr.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message