[llvm-commits] value range analysis based on scalar-evolutions
Devang Patel
dpatel at apple.com
Tue Jun 3 13:46:04 PDT 2008
On Jun 1, 2008, at 8:54 PM, Nick Lewycky wrote:
> I've implemented an analysis pass that uses SCEV to determine value
> ranges of integer-typed registers.
>
> Currently it maintains a map of Value* to ConstantRange*, which is
> rather inelegant. I was thinking we could have one analysis which
> would do that and others that would update the central analysis.
>
> I also implemented an optz'n pass based on it, but it hardly
> optimized anything and as such is not included in this patch.
>
> Please comment!
+static RegisterPass<LoopVR> X("loopvr", "Loop Value Ranges");
You want to register this as an analysis pass and cfe-only pass.
+static SCEVHandle getTruncateOrZeroExtend(const SCEVHandle &V, const
Type *Ty,
+ ScalarEvolution &SE) {
Why not move this into ScalarEvolution.h ?
+ APInt Spread_X = X.getSetSize(), Spread_Y = Y.getSetSize();
+ APInt NewLower = X.getLower() + Y.getLower(),
+ NewUpper = X.getUpper() + Y.getUpper() - 1;
nit-pick. I'd prefer to write this as
APInt NewLower = ..;
APInt NewUpper = ..;
+bool LoopVR::runOnFunction(Function &F) {
Is there a reason to not make this a LoopPass ?
+ for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
+ Loop *L = *I;
...
+ Loop *LL = LI.getLoopFor(*BI);
+ if (LL->isLoopInvariant(II)) continue;
Do you really want to check LL->isLoopInvariant(II) instead of L-
>isLoopInvariant(II) here ?
-
Devang
More information about the llvm-commits
mailing list