Value range tracing

jeremy@suede.sw.oz.au (Jeremy Fitzhardinge)
Fri, 1 Dec 1995 08:58:59 GMT

          From comp.compilers

Related articles
Value range tracing jeremy@suede.sw.oz.au (1995-12-01)
Re: value range tracing whalley@sed.cs.fsu.edu (David Whalley) (1995-12-09)
Re: Value range tracing hbaker@netcom.com (1995-12-09)
Re: Value range tracing preston@tera.com (1995-12-09)
Re: Value range tracing schinz@guano.alphanet.ch (1995-12-09)
Value range tracing dave@occl-cam.demon.co.uk (Dave Lloyd) (1995-12-09)
Re: Value range tracing bernecky@eecg.toronto.edu (1995-12-09)
[7 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: jeremy@suede.sw.oz.au (Jeremy Fitzhardinge)
Keywords: analysis, optimize, question
Organization: Softway Pty Limited
Date: Fri, 1 Dec 1995 08:58:59 GMT

Hi all,


I'm wondering if people bother with value range tracing. That is,
keeping track of the possible range of variables at each point in the
program. For example:


bar(int i) { /* "i" has no known properties */
if (i < 10) {
int arry[4];
/* We know i < 10, so we can give a warning that it may be over 4 */
arry[i] = bar();
return;
}
/* We know i >= 10 here */
if (i < 4) { /* Whole block deleted */
...
}
switch(i) {
case 0: ... /* delete */
case 2: ... /* delete */
case 8: ... /* maybe... */
/* i is the constant "8" */
etc.
}


Is this kind of thing useful? Is it useful enough to implement?
This isn't very complex, so I assume people have thought about it,
but I've seen very little literature on it.


I suppose it is, in effect, a more general handling of constant
propagation. Rather than saying "this particular value is here", you
can say "this range is possible". On the other hand, ranges are
somewhat limited as well, since you might want to say "this variable is
a power of 2" or something similar. However, I suspect attaching
general functions expressing constraints to variables in the compiler
would be hard to deal with to get useful information (unless, I
suppose, you wrote the compiler in prolog).


So what do people do in practice? Or does everyone just use
constants?


Thanks,
J


--


Post a followup to this message

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