Re: Loop invariance of externals. (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. (1995-03-15)
Re: Loop invariance of externals. (1995-03-17)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (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.