Loop invariance of externals.

davidm@Rational.COM (David Moore)
Thu, 9 Mar 1995 21:09:12 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: davidm@Rational.COM (David Moore)
Keywords: optimize, question, comment
Organization: Rational Software Corporation
Date: Thu, 9 Mar 1995 21:09:12 GMT

I am seeking some advice about the following. Especially, war stories.


Consider the following C code fragment:


extern int i;
extern int j;


....
          while (something) {
i=i+a[j];
}


It seems automatic to say that j is invariant around this
loop.


BUT WAIT!. Suppose i and j happen to be the same address.


entry i
entry j
i: bss 0
j: bss 1


(or whatever).


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.


My questions are:


1) Does your compiler take the conservative or the permissive
      approach for extern's.


2) If the permissive approach, has this caused problems
      in the field.


Of course, this question is not specifically about C, C is
just a simple language in which to give the example.


Thanks in advance for any replies - David L Moore
[Seems to me that this is exactly what volatile was invented for. -John]
--


Post a followup to this message

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