threads / patch / 308

patchRe: [PATCH GIT 0.6] make use of register variables & size_t

Subject: Re: [PATCH GIT 0.6] make use of register variables & size_t

## tl;dr

2 messages between Apr 25, 2005 and Apr 26, 2005. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>· Apr 25, 2005, 17:36 UTC · lore
Matthias-Christian Ott <matthias.christian@tiscali.de> wrote:
> The "git" didn't try store small variables, which aren't referenced, in
> the processor registers. It also didn't use the size_t type. I corrected
> a C++ style comment too.

I have compared functions using 'register' against functions not doing that. Not using register allowed better optimization on my x86.

-- 
The most dangerous thing in the world is a second lieutenant with a map and
a compass.
Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>· Apr 26, 2005, 18:18 UTC · lore
Matthias-Christian Ott <matthias.christian@tiscali.de> wrote:
> And if you think "register" variables are outdated, please remove the
> CONFIG_REGPARM option from the Kernel source.

Register variables are outdated because they hinder the compiler from optimizing by taking away 1/7 of the usable registers on x86. Use six register variables and you're back to a accumulator-machine. Use -O2 or -Os instead, the compiler is smarter than you.

The regparm calling convention will change the load value -> store value on stack -> call sequence into load value -> call -> store if needed Obviously the second form can be better optimized than the first one. Therefore it's a gain instead of a loss.

If you really want to help the compiler, look for something like repeated pointer dereference or access to global variables and cache them in block- local variables (pointers, int and uint only, even for caching chars). Beware of volatile variables, and don't forget to look at the assembler code.

-- 
The generation of random numbers is too important to be left to chance. 

← back to recent threads