Check Type::isSized before calling ScalarEvolution::getAllocSizeExpr,

rather than after.

llvm-svn: 94742
This commit is contained in:
Dan Gohman 2010-01-28 06:32:46 +00:00
parent cc9a6f0580
commit 9f4ea22c88
1 changed files with 23 additions and 21 deletions

View File

@ -365,11 +365,12 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
// the indices index into the element or field type selected by the
// preceding index.
for (;;) {
const SCEV *ElSize = SE.getAllocSizeExpr(ElTy);
// If the scale size is not 0, attempt to factor out a scale for
// array indexing.
SmallVector<const SCEV *, 8> ScaledOps;
if (ElTy->isSized() && !ElSize->isZero()) {
if (ElTy->isSized()) {
const SCEV *ElSize = SE.getAllocSizeExpr(ElTy);
if (!ElSize->isZero()) {
SmallVector<const SCEV *, 8> NewOps;
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
const SCEV *Op = Ops[i];
@ -392,6 +393,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
SimplifyAddOperands(Ops, Ty, SE);
}
}
}
// Record the scaled array index for this level of the type. If
// we didn't find any operands that could be factored, tentatively