Re: Loop invariance of externals.

cdg@nullstone.com (Christopher Glaeser)
Fri, 17 Mar 1995 17:23:10 GMT

          From comp.compilers

Related articles
Loop invariance of externals. davidm@Rational.COM (1995-03-09)
Re: Loop invariance of externals. cliffc@crocus.hpl.hp.com (1995-03-15)
Re: Loop invariance of externals. cdg@nullstone.com (1995-03-17)
| List of all articles for this month |
Newsgroups: comp.compilers
From: cdg@nullstone.com (Christopher Glaeser)
Keywords: optimize
Organization: Compilers Central
References: 95-03-060
Date: Fri, 17 Mar 1995 17:23:10 GMT

David Moore <uunet!Rational.COM!davidm> writes:


> while (something) { i=i+a[j]; }
>
> Or, slightly less bizarre, j might be bound to an input register
> of an external device. In this case we don't even need to assign
> to a potentially conflicting extern to get j non-invariant.


As mentioned by the moderator, j should be defined as volatile or
const volatile.


However, even if j is defined volatile or const volatile, not all
compilers implement the standard correctly, and you may want to
review the code generated by your compiler, particularly when using
the optimizer. Of eighteen commercially available compilers that I
evaluated, sixteen (90%) of these compilers hoisted references to
volatile and/or const volatile objects out of a loop.


Best regards,
Christopher Glaeser
Nullstone Corporation
--


Post a followup to this message

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