From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075324106684.tru64-unix-managers.marc@archive.invalid> From: Cary Talbot Date: Mon, 23 Oct 1995 15:53:25 +0000 To: tru64-unix-managers Subject: SUMMARY: register variables X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075324106684 Original post: > Anyone know how many register variables are available per function > using > > 1) gcc > > 2) cc > > on Digital Unix 3.2A ? Answers: from Jason Yanowitz you can't count on ansi c compilers paying attention to your register declaration. I do know that cc (using -O3 or '-migrate -O5') produces better code than gcc. cc has a better register allocator (in fact, it has an excellent register allocator)(*). If it is critical to you that certain variables stay in registers and the compiler isn't doing it (use -S to geenrate assembly output, cc does the most beautiful commenting of its assembly output too, by the way.. it's a work of article really), that I would code those routines in assembler. you can also try and psyche out the compiler by keeping some registers live over greater portioons of your code (making them global) but then of course, you up the chances they get spilled, which is what you are trying to avoid. [the alpha has 32 float and 32 int registers, though some of them are reserved.] from Selden E Ball Jr Alphas have 32 64bit integer registers and 32 64bit floating point registers. You should probably get a copy of the Alpha Architecture Handbook. You cannot be guaranteed that register variables are actually kept in machine registers. Modern C compilers only use register declarations as hints to help optimize program performance, otherwise your programs would be uncompilable on different computer architectures with fewer registers than your original system. There are two different DEC Alpha architectures: EV4 and EV5. EV5 has more functional units (integer and floating point units). DEC's compilers can be told to optimize for one or the other or to generate code which runs almost as well on both. EV5 systems only started shipping relatively recently. and from Brad Daniels On most modern compilation systems, including the ones you mention, the register keyword is useless at best, and at the worst, can actually degrade performance. Modern optimizers do carfeul analysis of data flow to determine which entities can be stored in registers, and at which points in the code a register can be re-used. The register keyword sometimes overrides the optimizer's analysis and keeps a value in a register even when it's no longer used and the register is in fact free for use with another value. If you don't use the register keyword, the optimizer will decide when to put things in registers and when (and even whether) variables need to be saved on the stack. Thanks for the replies. _____________________________________________________________________ Cary A. Talbot, Hydraulic Engineer US Army Corps of Engineers ATTN: CEWES-HH-G Waterways Experiment Station 3909 Halls Ferry Road Vicksburg, Mississippi 39180 phone:(601)634-4286 fax:(601)634-4208 email:talbot@hl.wes.army.mil