Implement getSCEVAtScope for SCEV cast expressions.

llvm-svn: 70422
This commit is contained in:
Dan Gohman 2009-04-29 22:29:01 +00:00
parent 494dac3f84
commit 0098d01ef9
1 changed files with 25 additions and 2 deletions

View File

@ -2707,8 +2707,31 @@ SCEVHandle ScalarEvolution::getSCEVAtScope(SCEV *V, const Loop *L) {
return UnknownValue;
}
//assert(0 && "Unknown SCEV type!");
return UnknownValue;
if (SCEVZeroExtendExpr *Cast = dyn_cast<SCEVZeroExtendExpr>(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
return Cast; // must be loop invariant
return getZeroExtendExpr(Op, Cast->getType());
}
if (SCEVSignExtendExpr *Cast = dyn_cast<SCEVSignExtendExpr>(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
return Cast; // must be loop invariant
return getSignExtendExpr(Op, Cast->getType());
}
if (SCEVTruncateExpr *Cast = dyn_cast<SCEVTruncateExpr>(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
return Cast; // must be loop invariant
return getTruncateExpr(Op, Cast->getType());
}
assert(0 && "Unknown SCEV type!");
}
/// getSCEVAtScope - Return a SCEV expression handle for the specified value