[comp.lang.c] 'register' type

braner@batcomputer.tn.cornell.edu (braner) (12/30/86)

[]

The C programmer is currently free to avoid declaring variables 'register',
in the hope that the compiler is smart enough to do it optimally.  Also, if
'register' IS used (with reason), it should not hamper the smart compiler.

On the other hand, lots of present and future compilers are NOT that smart.
Also, there will always be SOME cases where a tricky algorithm eludes the
compiler's smarts.

The 'register' tool can be VERY valuable, and is one of endearing features
of C.  Don't dump it!

- Moshe Braner

PS:  Wish: May all compilers allow register unions!
           (for small objects, of course...)

eric@cti.UUCP (Eric Black) (01/09/87)

In article <1923@batcomputer.tn.cornell.edu> braner@batcomputer.UUCP (braner) writes:
>
>The C programmer is currently free to avoid declaring variables 'register',
>in the hope that the compiler is smart enough to do it optimally.  Also, if
>'register' IS used (with reason), it should not hamper the smart compiler.
>
>On the other hand, lots of present and future compilers are NOT that smart.
>Also, there will always be SOME cases where a tricky algorithm eludes the
>compiler's smarts.
>

The algorithm doesn't even need to be very tricky.  I expect it would
be quite difficult or impossible for even a smart compiler to be able
to determine program behavior (hence what needs to be optimized) without
any knowledge of the environment (including input data) in which it will
be used.  This is the old distinction between static and dynamic analysis.
The programmer can use the "register" attribute to advise the compiler that
he expects the dynamic behavior of the program to make it desirable for that
variable to reside in a register, even though the static appearance of the
code might not make this apparent.

>The 'register' tool can be VERY valuable, and is one of endearing features
>of C.  Don't dump it!

Hyuh, hyuh!

[first posting from this site using news 2.11 software...]
-- 
Eric Black   "Garbage In, Gospel Out"
UUCP:        {sun,pyramid,hplabs,amdcad}!cti!eric