Skip to content

Commit 3ed1cb7

Browse files
committed
Minor improvements
1 parent c549980 commit 3ed1cb7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/Analysis/Delinearization.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,12 @@ bool llvm::findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
571571
// the next smaller one, like A[i][3*j].
572572
llvm::sort(Sizes.rbegin(), Sizes.rend());
573573
Sizes.erase(llvm::unique(Sizes), Sizes.end());
574+
575+
// The last element in Sizes should be ElementSize. At this point, all values
576+
// in Sizes are assumed to be divided by ElementSize, so replace it with 1.
577+
assert(Sizes.back() != 0 && "Unexpected zero size in Sizes.");
578+
Sizes.back() = 1;
579+
574580
for (unsigned I = 0; I + 1 < Sizes.size(); I++) {
575581
unsigned PrevSize = Sizes[I + 1];
576582
if (Sizes[I] % PrevSize) {
@@ -580,7 +586,7 @@ bool llvm::findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
580586
Sizes[I] /= PrevSize;
581587
}
582588

583-
// The last element should be ElementSize.
589+
// Finally, the last element in Sizes should be ElementSize.
584590
Sizes.back() = *ElementSizeConst;
585591
return true;
586592
}

0 commit comments

Comments
 (0)