473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 #1
65 2503
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<sp****@gmail.comwrote in comp.lang.c:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Mar 18 '08 #2
On 18 Mar, 02:20, Jack Klein <jackkl...@spamcop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.comwrote in comp.lang.c:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?

On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.
How do you choose which variables to declare register ?
Is it on a general feel on which gets used the most or
do you keep precise statistics or a different method ?
Mar 18 '08 #3
On 18 Mar, 02:20, Jack Klein <jackkl...@spamcop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.comwrote in comp.lang.c:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?

On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.

--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?

Nick
Mar 18 '08 #4
polas wrote:
On 18 Mar, 02:20, Jack Klein <jackkl...@spamcop.netwrote:
>On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.comwrote in comp.lang.c:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?

On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.
[ ... ]
Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?
It is certainly *possible,* but I would be surprised if any actual
implementation's optimisers were so affected, since register is mostly
taken as a mild hint and nothing more under most extant
implementations.

Mar 18 '08 #5
On Mar 18, 10:17 am, polas <n...@helpforce.comwrote:
On 18 Mar, 02:20, Jack Klein <jackkl...@spamcop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.comwrote in comp.lang.c:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
On quite a few embedded architectures, 8 to 32 bit.
The last time was this morning.
--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html

Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?

Nick
register is a hint, not a requirement. So the compiler is free to
ignore it.
You have control over the compiler via its optimization options.

At least that is my understanding.
Ed
Mar 18 '08 #6
In article <9d**********************************@s8g2000prg.g ooglegroups.compolas <ni**@helpforce.comwrites:
....
Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?
O, certainly. When the compiler honours the register statement, and you
are putting the least used variables in registers, for instance.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Mar 18 '08 #7
Dik T. Winter wrote:
In article
<9d**********************************@s8g2000prg.g ooglegroups.com>
polas <ni**@helpforce.comwrites: ...
Is it possible at all that, variables declared to be register
located might confuse the compiler's optimisation methods and
actually reduce the efficiency of the overall code?

O, certainly. When the compiler honours the register statement, and
you are putting the least used variables in registers, for instance.
I wonder how much suboptimal register allocation would matter with
modern processors with huge L1 and L2 caches.

Mar 18 '08 #8
santosh <sa*********@gmail.comwrote:
polas wrote:
Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?

It is certainly *possible,* but I would be surprised if any actual
implementation's optimisers were so affected, since register is mostly
taken as a mild hint and nothing more under most extant
implementations.
Not these days, probably, but it used to be true for some MS-DOS
implementations that you could register the wrong variable and the
compiler would merrily do as you told it.

Richard
Mar 18 '08 #9
Spiros Bousbouras wrote:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
Yes. It also affected the size of the generated code. This was using the
3bcc cross compiler for the AT&T 3B20D processor. The year was about
1980. I put pointer variables into registers as that seemed to help the
most. The optimizer wasn't as powerful as one could hope for back then.
I believe newer versions of the 3bcc compiler/optimizer did a better job
so using the register keyword wasn't as critical later.

Phil Schoonover
Mar 18 '08 #10
On Mar 18, 3:14 pm, santosh <santosh....@gmail.comwrote:
I wonder how much suboptimal register allocation would matter with
modern processors with huge L1 and L2 caches.
The size of the L1 cache doesn't make any difference to this problem,
and the L2 cache most certainly doesn't.

A typical x86 system can perform three or four micro operations per
cycle. Operations between registers are one micro operation;
operations using one memory variable use at least three micro
operations (calculate address, load, process) which means throughput
is reduced by a factor of three, you get much bigger latencies which
is a killer with long dependency chains, you run out of resources for
checking memory dependencies, so all in all using memory instead of
registers is awfully bad for your code's performance.
Mar 18 '08 #11
On Mar 18, 3:37 pm, r...@hoekstra-uitgeverij.nl (Richard Bos) wrote:
Not these days, probably, but it used to be true for some MS-DOS
implementations that you could register the wrong variable and the
compiler would merrily do as you told it.
If you write code like
for (i = 0; i < n; ++i) use (x);
for (i = 0; i < m; ++j) use (y);

and the compiler can put either x or y into a register, but not both,
then I would expect it to use the variable that was declared as a
"register" variable. And if n = 10, m = 1000000000, and the compiler
doesn't know this, then using the wrong declaration will still make
your code slower. (Of course a compiler could just ignore "register"
completely except for giving an error if you take the address of a
variable, giving you a 50:50 chance of picking the right variable).
Mar 18 '08 #12
On Mar 17, 3:40 pm, Kenneth Brody <kenbr...@spamcop.netwrote:
There were other "tricks" I learned way back then which are no longer
relevant as well. For example, rewriting a for-loop properly could
make a big improvement on 680x0-based systems, as the compiler would
then take advantage of the 680x0's "decrement and branch on non-zero"
instruction.
That was a very nice thing about the CodeWarrior C compiler: It
produced faster code if you wrote for-loops in the most readable way,
like

for (i = start; i < end; ++i) ...

which was deserved punishment for all those who thought

while (i--) ...

or something similar unreadable would produce faster code.

Unfortunately later compiler versions did all kinds of loop with fast
code :-(
Mar 18 '08 #13
polas wrote:
Jack Klein <jackkl...@spamcop.netwrote:
>Spiros Bousbouras <spi...@gmail.comwrote:
>>Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?

On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.

Is it possible at all that, variables declared to be register
located might confuse the compiler's optimisation methods and
actually reduce the efficiency of the overall code?
If it does and the code you wrote meets the requirements of the C
standard, the compiler is buggy. The odds are that your code is
the buggy componenet.

Please do not quote signatures. Those are anything that follows
the "-- " sig marker in the original message.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 18 '08 #14
CBFalconer wrote:
polas wrote:
>Jack Klein <jackkl...@spamcop.netwrote:
>>Spiros Bousbouras <spi...@gmail.comwrote:

Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.
Is it possible at all that, variables declared to be register
located might confuse the compiler's optimisation methods and
actually reduce the efficiency of the overall code?

If it does and the code you wrote meets the requirements of the C
standard, the compiler is buggy. The odds are that your code is
the buggy componenet.
In what way exactly is the compiler buggy? The C standard does not
guarantee that if you use "register" then your code will run faster.
Mar 19 '08 #15
In article <fr**********@aioe.org>, Philip Potter <pg*@doc.ic.ac.ukwrote:
>If it does and the code you wrote meets the requirements of the C
standard, the compiler is buggy. The odds are that your code is
the buggy componenet.
>In what way exactly is the compiler buggy? The C standard does not
guarantee that if you use "register" then your code will run faster.
A C compiler may aim to conform to the C standard, but that does not
mean that only errors of conformance count as bugs.

But I agree that it's not necessarily a bug if using "register" slows
your program down. It may well be that sometimes register
declarations will help and sometimes they will make things worse: if
so, the user can use a profile to decide whether it's worth it.

-- Richard
--
:wq
Mar 19 '08 #16
CBFalconer <cb********@yahoo.comwrites:
polas wrote:
>Jack Klein <jackkl...@spamcop.netwrote:
>>Spiros Bousbouras <spi...@gmail.comwrote:

Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?

On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.

Is it possible at all that, variables declared to be register
located might confuse the compiler's optimisation methods and
actually reduce the efficiency of the overall code?

If it does and the code you wrote meets the requirements of the C
standard, the compiler is buggy. The odds are that your code is
the buggy componenet.

Please do not quote signatures. Those are anything that follows
the "-- " sig marker in the original message.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Please fix your own double signature before lecturing others you pompous
fool.

Mar 19 '08 #17
In article <fr***********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
>In article <fr**********@aioe.org>, Philip Potter <pg*@doc.ic.ac.ukwrote:
>>If it does and the code you wrote meets the requirements of the C
standard, the compiler is buggy. The odds are that your code is
the buggy componenet.
>>In what way exactly is the compiler buggy? The C standard does not
guarantee that if you use "register" then your code will run faster.

A C compiler may aim to conform to the C standard, but that does not
mean that only errors of conformance count as bugs.
In this newsgroup, it does.

Mar 29 '08 #18
polas wrote:
On 18 Mar, 02:20, Jack Klein <jackkl...@spamcop.netwrote:
>On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.comwrote in comp.lang.c:
>>Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
On quite a few embedded architectures, 8 to 32 bit.

The last time was this morning.

--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html

Is it possible at all that, variables declared to be register located
might confuse the compiler's optimisation methods and actually reduce
the efficiency of the overall code?

"register" is part of the language standard, if a compiler considers it
unneeded, it is free to ignore it. Proper uses of "register" making the
compiler to produce less-efficient code than not using it at all, is a
compiler-defect.
Mar 29 '08 #19
Ioannis wrote:
) "register" is part of the language standard, if a compiler considers it
) unneeded, it is free to ignore it. Proper uses of "register" making the
) compiler to produce less-efficient code than not using it at all, is a
) compiler-defect.

I disagree.

It's possible that there are multiple code-paths through a function, and
that declaring a certain variable makes one of those code-paths more
efficient at the expense of the others. In this case, the compiler in
essence takes the register declaration as a hint that that specific code
path is more important to be optimized.

So, if a programmer then mistakenly declares such a variable register when
in fact the other code paths are more in need of optimization, the code
will be less-efficient, but I would not call that a compiler-defect.
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 29 '08 #20
Walter Roberson wrote:
>

The placement of the variable into a register would often reduce the
number of registers available, lowering the compiler's freedom to place
other variables into the same register. If (perhaps only
for that particular combination of data) placing the variable
in a register (as requested by the program author) was not the optimal
thing to do, then the program can end up running more slowly.

Most machines have a relatively limited number of registers; using
a register for one purpose may preclude it being used for another.

.... as long as the "register" variable remains in scope.
Mar 29 '08 #21
Richard wrote:
>Yes, if "register" is taken under consideration by the compiler,
obviously there will be one register less for the rest of the program,
and yes it can affect the run-time execution of another part of the
program (as long as the register variable remains in scope *and* at the
same time multiple-variables needing to be stored in registers are used
concurrently) , but this falls in the "proper uses of register" I wrote
above.

No. You are wrong. Even if other variables do not need to be stored the
code can vary and efficiency suffer.

Why?
Mar 29 '08 #22
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrites:
Richard wrote:
>>Yes, if "register" is taken under consideration by the compiler,
obviously there will be one register less for the rest of the program,
and yes it can affect the run-time execution of another part of the
program (as long as the register variable remains in scope *and* at the
same time multiple-variables needing to be stored in registers are used
concurrently) , but this falls in the "proper uses of register" I wrote
above.

No. You are wrong. Even if other variables do not need to be stored the
code can vary and efficiency suffer.


Why?
The key word here is "need" - I took this to mean you meant other
register declarations.

But regardless its common sense. If you stick ONE value in a register
that is one less register to play with for other compiler generated
optimizations.

Mar 29 '08 #23
Ioannis wrote:
) Yes, if "register" is taken under consideration by the compiler,
) obviously there will be one register less for the rest of the program,
) and yes it can affect the run-time execution of another part of the
) program (as long as the register variable remains in scope *and* at the
) same time multiple-variables needing to be stored in registers are used
) concurrently) , but this falls in the "proper uses of register" I wrote
) above.

Ah, so now you're claiming that if a use of 'register' makes the code
run less efficiently, then it's not "proper use" ?

Where I come from we call that a circular argument.
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 29 '08 #24
Ioannis wrote:
) Willem wrote:
)Ah, so now you're claiming that if a use of 'register' makes the code
)run less efficiently, then it's not "proper use" ?
)>
)Where I come from we call that a circular argument.
)
) In general, "register" should be used in small scopes. Consider an
) example I posted in another message in the thread:

And what about the not 'in general' cases where there are valid reasons
for variables to be declared register in large scopes ?

Those are the interesting cases that are counterexamples to your claim
that a compiler is defective if it generates less-efficient code when
'register' is used. Therefore those are the cases under discussion.

Or are you claiming that *all* those cases are 'improper use' ?
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 29 '08 #25
Willem wrote:
Ioannis wrote:
) Willem wrote:
)Ah, so now you're claiming that if a use of 'register' makes the code
)run less efficiently, then it's not "proper use" ?
)>
)Where I come from we call that a circular argument.
)
) In general, "register" should be used in small scopes. Consider an
) example I posted in another message in the thread:

And what about the not 'in general' cases where there are valid reasons
for variables to be declared register in large scopes ?

Those are the interesting cases that are counterexamples to your claim
that a compiler is defective if it generates less-efficient code when
'register' is used. Therefore those are the cases under discussion.

Or are you claiming that *all* those cases are 'improper use' ?

I think "register" should be used in as small scopes as possible, the
same way that "inline" should be used with as small functions as possible.
Mar 29 '08 #26
Ioannis wrote:
) Willem wrote:
)And what about the not 'in general' cases where there are valid reasons
)for variables to be declared register in large scopes ?
)>
)Those are the interesting cases that are counterexamples to your claim
)that a compiler is defective if it generates less-efficient code when
)'register' is used. Therefore those are the cases under discussion.
)>
)Or are you claiming that *all* those cases are 'improper use' ?
)
) I think "register" should be used in as small scopes as possible, the
) same way that "inline" should be used with as small functions as possible.

And I think that cases exist where the smallest scope possible is such that
it will touch multiple code paths, making one more efficient at the cost of
others. It is the programmers discretion to make this choice.
These cases are counterexamples to your claim.
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 29 '08 #27
Willem wrote:
Ioannis wrote:
) Willem wrote:
)And what about the not 'in general' cases where there are valid reasons
)for variables to be declared register in large scopes ?
)>
)Those are the interesting cases that are counterexamples to your claim
)that a compiler is defective if it generates less-efficient code when
)'register' is used. Therefore those are the cases under discussion.
)>
)Or are you claiming that *all* those cases are 'improper use' ?
)
) I think "register" should be used in as small scopes as possible, the
) same way that "inline" should be used with as small functions as possible.

And I think that cases exist where the smallest scope possible is such that
it will touch multiple code paths, making one more efficient at the cost of
others. It is the programmers discretion to make this choice.
These cases are counterexamples to your claim.

Can you provide some code example where this happens, since I am not a
compiler writer?
Mar 29 '08 #28
In article <fs***********@ulysses.noc.ntua.gr>,
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>"An example of proper use:
for(register int i= 0; i< INT_MAX; ++i)
array[i]*= i;
Is there *any* C compiler out there that accepts this syntax but has
such a useless optimiser that using "register" is worthwhile? A loop
variable has to be the most obvious case where any reasonable compiler
will use a register anyway.

-- Richard
--
:wq
Mar 29 '08 #29
Richard Tobin wrote:
In article <fs***********@ulysses.noc.ntua.gr>,
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>"An example of proper use:
for(register int i= 0; i< INT_MAX; ++i)
array[i]*= i;

Is there *any* C compiler out there that accepts this syntax but has
such a useless optimiser that using "register" is worthwhile? A loop
variable has to be the most obvious case where any reasonable compiler
will use a register anyway.

Essentially you are saying that "register" is not needed for application
programming with a modern C compiler, which is true.
Mar 29 '08 #30
Richard Tobin wrote:
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>"An example of proper use:

for (register int i= 0; i < INT_MAX; ++i)
array[i] *= i;

Is there *any* C compiler out there that accepts this syntax but
has such a useless optimiser that using "register" is worthwhile?
A loop variable has to be the most obvious case where any
reasonable compiler will use a register anyway.
I seriously doubt that example. If any element of a[] is greater
than 1 it will cause overflow, and un or implementation defined
action.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

--
Posted via a free Usenet account from http://www.teranews.com

Mar 30 '08 #31
CBFalconer wrote:
Richard Tobin wrote:
>Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:
>>"An example of proper use:

for (register int i= 0; i < INT_MAX; ++i)
array[i] *= i;
Is there *any* C compiler out there that accepts this syntax but
has such a useless optimiser that using "register" is worthwhile?
A loop variable has to be the most obvious case where any
reasonable compiler will use a register anyway.

I seriously doubt that example. If any element of a[] is greater
than 1 it will cause overflow, and un or implementation defined
action.

Consider sizeof(array)/sizeof(*array)== INT_MAX and the elements of the
array being 1s and 0s.

Mar 30 '08 #32
Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrites:
CBFalconer wrote:
>Richard Tobin wrote:
>>Ioannis Vranos <iv*****@nospam.no.spamfreemail.grwrote:

"An example of proper use:

for (register int i= 0; i < INT_MAX; ++i)
array[i] *= i;
Is there *any* C compiler out there that accepts this syntax but
has such a useless optimiser that using "register" is worthwhile?
A loop variable has to be the most obvious case where any
reasonable compiler will use a register anyway.

I seriously doubt that example. If any element of a[] is greater
than 1 it will cause overflow, and un or implementation defined
action.


Consider sizeof(array)/sizeof(*array)== INT_MAX and the elements of the
array being 1s and 0s.
Don't worry, you're just witnessing the wondrous Chuck being obstructive
and pedantic as usual. Everyone else knew what you were driving at.

Mar 30 '08 #33
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?
Mar 30 '08 #34
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 ?
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 #35
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?
Mar 30 '08 #36
Ioannis Vranos <iv*****@nospam.no.spamfreemail.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 ...

Mar 30 '08 #37
Richard wrote:
Ioannis Vranos <iv*****@nospam.no.spamfreemail.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.

Mar 30 '08 #38
Corrected:

Ioannis Vranos wrote:
Richard wrote:
>Ioannis Vranos <iv*****@nospam.no.spamfreemail.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 doesn't affect code that is not intended to be affected.

Mar 30 '08 #39
On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
Ioannis Vranos <iv*****@nospam.no.spamfreemail.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.
Mar 30 '08 #40
Harald van Dijk wrote:
On Sun, 30 Mar 2008 16:55:58 +0200, Richard wrote:
>Ioannis Vranos <iv*****@nospam.no.spamfreemail.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.spamfreemail.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.spamfreemail.grwrites:
Richard wrote:
>Ioannis Vranos <iv*****@nospam.no.spamfreemail.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.spamfreemail.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.spamfreemail.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.