473,804 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Experiences using "register"

Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
Mar 17 '08
65 2619
Harald van Dijk wrote:
On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
>Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
>>Willem wrote:
You're arguing in circles again.
Why should 'register' be used only when it has minimal effect on the
code ?
Why "inline" should be used with small functions only?
Because it adversely affects code size is one thing I can think of ...

If the function is huge, but it's only called from one place, inlining
may even decrease the code size.

Still, you don't know how many times it will be called in the future, so
it is a bad practice.
Mar 30 '08 #41
On Sun, 30 Mar 2008 18:01:45 +0300, Ioannis Vranos wrote:
Harald van Dijk wrote:
>On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
>>Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
Willem wrote:
You're arguing in circles again.
Why should 'register' be used only when it has minimal effect on the
code ?
Why "inline" should be used with small functions only?
Because it adversely affects code size is one thing I can think of ...

If the function is huge, but it's only called from one place, inlining
may even decrease the code size.

Still, you don't know how many times it will be called in the future, so
it is a bad practice.
Yes, I do, if it's something like the main loop of an event-driven
program, or library initialisation. It doesn't make any sense to call
that more than once, or from different locations.
Mar 30 '08 #42
Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
Richard wrote:
>Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
>>Willem wrote:
Ioannis wrote:
) Richard wrote:
)>If the function is more than 5-6 lines of code, "register" should not be
)>used for the function scope but only for local scopes in the function
)>(like small loops).
)>
)Where do you get these "facts" that you maintain are true with zero to
)back them up? It all depends on the compiler and also depend, in a
)larger function, on how often your register variable was used and how it
)was used. Length in lines has absolutely nothing to do with it.
)
) The smaller the scope, the less effect it has on the rest of code. Where
) do you disagree with this?

You're arguing in circles again.
Why should 'register' be used only when it has minimal effect on the code ?

Why "inline" should be used with small functions only?

Because it adversely affects code size is one thing I can think of ...


Exactly. "register" should be used in as a small scope as possible, so
as it affects (or better: doesn't affect) code that is not intended to
be affected.
You could have a function 100 lines long where the register variable is
used on every line and its use does not impede the rest of the code.
Mar 30 '08 #43
Ioannis wrote:
) Exactly. "register" should be used in as a small scope as possible, so
) as it doesn't affect code that is not intended to be affected.

Here, again, you say 'as small a scope as possible'.
That _doesn't_ necessarily mean 'a small scope'.

You *still* haven't given any reason why 'register' should only
be used on _small scopes_. You're just going in circles.

Again: 'as small a scope as possible' is *NOT* the same as 'small scope'.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Mar 30 '08 #44
Ioannis wrote:
) Willem wrote:
)You're arguing in circles again.
)Why should 'register' be used only when it has minimal effect on the code ?
)
) Why "inline" should be used with small functions only?

You tell me. I sometimes use it on quite large functions.

And besides, what does that have to do with 'register' ?
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Mar 30 '08 #45
Willem wrote:
Ioannis wrote:
) Exactly. "register" should be used in as a small scope as possible, so
) as it doesn't affect code that is not intended to be affected.

Here, again, you say 'as small a scope as possible'.
That _doesn't_ necessarily mean 'a small scope'.

You *still* haven't given any reason why 'register' should only
be used on _small scopes_. You're just going in circles.

Again: 'as small a scope as possible' is *NOT* the same as 'small scope'.

OK, we have a comprehension problem. Replace my phrase "as small a scope
as possible" with "a small scope".
Mar 30 '08 #46
Richard wrote:
>
You could have a function 100 lines long where the register variable is
used on every line and its use does not impede the rest of the code.
.... theoretically speaking.
Mar 30 '08 #47
Harald van Dijk wrote:
On Sun, 30 Mar 2008 18:01:45 +0300, Ioannis Vranos wrote:
>Harald van Dijk wrote:
>>On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
Willem wrote:
>You're arguing in circles again.
>Why should 'register' be used only when it has minimal effect on the
>code ?
Why "inline" should be used with small functions only?
Because it adversely affects code size is one thing I can think of ...
If the function is huge, but it's only called from one place, inlining
may even decrease the code size.
Still, you don't know how many times it will be called in the future, so
it is a bad practice.

Yes, I do, if it's something like the main loop of an event-driven
program, or library initialisation. It doesn't make any sense to call
that more than once, or from different locations.

This reminds me something I have read elsewhere. Something like "no rule
is so general that it has no exceptions".

In any case, how much size will you save if you make this one-called
function inlined? The same minus a function call (an address) in the
automatic storage.
Mar 30 '08 #48
Ioannis Vranos <iv*****@nospam .no.spamfreemai l.grwrites:
Richard wrote:
>>
You could have a function 100 lines long where the register variable is
used on every line and its use does not impede the rest of the code.

... theoretically speaking.
Practically speaking actually.
Mar 30 '08 #49
Ioannis wrote:
) Willem wrote:
)Ioannis wrote:
)) Exactly. "register" should be used in as a small scope as possible, so
)) as it doesn't affect code that is not intended to be affected.
)>
)Here, again, you say 'as small a scope as possible'.
)That _doesn't_ necessarily mean 'a small scope'.
)>
)You *still* haven't given any reason why 'register' should only
)be used on _small scopes_. You're just going in circles.
)>
)Again: 'as small a scope as possible' is *NOT* the same as 'small scope'.
)
) OK, we have a comprehension problem. Replace my phrase "as small a scope
) as possible" with "a small scope".

If you make that replacement, then suddenly your statement doesn't sound
so self-evident any more, as I already indicated.

So answer the question above: *WHY* should 'register' only be used
on small scopes ? If I use it on a large scope, then I *intend* that
it affects a lot of code. I see no reason why I shouldn't do that.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
Mar 30 '08 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.