473,785 Members | 2,396 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 #1
65 2615
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<sp****@gmail.c omwrote 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.l earn.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...@spam cop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.c omwrote 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...@spam cop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.c omwrote 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.l earn.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...@spam cop.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...@spam cop.netwrote:
On Mon, 17 Mar 2008 06:24:27 -0700 (PDT), Spiros Bousbouras
<spi...@gmail.c omwrote 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.l earn.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************ *************** *******@s8g2000 prg.googlegroup s.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************ *************** *******@s8g2000 prg.googlegroup s.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*********@gm ail.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

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.