John Criswell wrote:> Is there an LLVM analysis pass that can, given an LLVM integer value,
> tell me the minimum and maximum values that the value will be at
> run-time? Conservative answers are fine, and execution time isn't too
> important, so the more accurate it is, the better.
Scalar evolutions is the one that's already packaged as an analysis and
is production-ready. However, it only really handles loops. Use
SCEV::getValueRange.
After that you've got Correlated Expression Elimination pass which I
understand isn't enabled by default and isn't being developed any more.
Use ValueInfo::getBounds.
Finally, there's the Predicate Simplifier. It has
ValueRanges::rangeFromValue that turns a Value (and a domtree scope
which you could fix as DTDFS->getNodeForBlock(Value->getParent())) into
a range. Unfortunately, predsimplify's VRP is still unfinished in terms
of tracking through things like sub or mul. I'm working on refactoring
at the moment mostly, for efficient handling of PHI nodes.
But if it's important to you, I can finish up the VRPish bits and hand
you a special version with *in*efficient PHI node handling. :) Be
warned, last time I did this, the pass only took minutes on most
programs. SPASS took 8 hours or so.
Nick