register variables in C.
Wed, 22 Apr 1992 21:13:50 GMT

          From comp.compilers

Related articles
register variables in C. (1992-04-22)
register variables in C. (1992-04-22)
Re: register variables in C. (1992-04-23)
Re: register variables in C. (1992-04-23)
Re: register variables in C. dave.howell@ColumbiaSC.NCR.COM (Dave Howell) (1992-04-24)
Re: register variables in C. (1992-04-29)
Re: register variables in C. (1992-04-30)
Re: register variables in C. Brian.Scearce@Eng.Sun.COM (1992-04-30)
[9 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
Keywords: C, optimize, registers
Organization: Compilers Central
References: 92-04-108
Date: Wed, 22 Apr 1992 21:13:50 GMT

In article 92-04-108 writes:
>In other words, should a programmer ever use the "register" storage class?
>[My impression is that the compiler can do a much better job, particularly
>with a graph coloring register allocator, but I'd be interested in some
>real data. -John]

The `register' declaration can provide an important hint to the optimizer
-- that no pointer ever points to the variable in question.

Data flow analysis for determining what variables can be altered by an
assignment through a pointer is complicated. Many compilers simply beg
the question and assume that anything at all can be trashed by a pointer
assignment -- or by a function call, since the function (which is
unavailable at compile time) might contain an assignment through a global
pointer that designates the variable.

I'm having trouble remembering the specifics, but I seem to recall that
there was a case where a simple static check that the & (address-of)
operator fails to detect an aliasing problem. The `register' declaration
functions as an assertion that there is no aliasing problem for a given

Do any other readers remember more about this?

73 de ke9tv/2, Kevin
[It's true that "register" may be useful as an assertion, but I'm very
sceptical of any claims that a compiler can't reliably identify statically
unaliased variables. If it couldn't, there'd be no way to generate
reliably correct object code even with register declarations since on most
architectures registers don't have addresses. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.