Skip to content

Commit 02f0097

Browse files
committed
Address review comments, thanks!
1 parent e3e2f5a commit 02f0097

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

llvm/lib/Analysis/Delinearization.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static std::optional<APInt> tryIntoAPInt(const SCEV *S) {
494494

495495
/// Collects the absolute values of constant steps for all induction variables.
496496
/// Returns true if we can prove that all step recurrences are constants and \p
497-
/// Expr is dividable by \p ElementSize. Each step recurrence is stored in \p
497+
/// Expr is divisible by \p ElementSize. Each step recurrence is stored in \p
498498
/// Steps after divided by \p ElementSize.
499499
static bool collectConstantAbsSteps(ScalarEvolution &SE, const SCEV *Expr,
500500
SmallVectorImpl<unsigned> &Steps,
@@ -567,7 +567,7 @@ static bool findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
567567
// in like Arr[UnknownSize][8][32] with elements of size 8 bytes, where Arr is
568568
// a base pointer.
569569
//
570-
// TODO: Catch more cases, e.g., when a step recurrence is not dividable by
570+
// TODO: Catch more cases, e.g., when a step recurrence is not divisible by
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());
@@ -615,14 +615,11 @@ static bool findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
615615
/// subscript, so the caller should perform additional boundary checks if
616616
/// necessary.
617617
///
618-
/// TODO: At the moment, this function can handle only simple cases. For
619-
/// example, we cannot handle a case where a step recurrence is not dividable by
620-
/// the next smaller step recurrence, e.g., A[i][3*j]. Furthermore, this
621-
/// function doesn't guarantee that the original array size is restored
622-
/// "correctly". For example, in the following case:
618+
/// Also note that this function doesn't guarantee that the original array size
619+
/// is restored "correctly". For example, in the following case:
623620
///
624-
/// double A[42][4][32];
625-
/// double B[42][8][64];
621+
/// double A[42][4][64];
622+
/// double B[42][8][32];
626623
/// for i
627624
/// for j
628625
/// for k
@@ -635,6 +632,10 @@ static bool findFixedSizeArrayDimensions(ScalarEvolution &SE, const SCEV *Expr,
635632
///
636633
/// The array sizes for both A and B will be computed as
637634
/// ArrayDecl[UnknownSize][4][64], which matches for A, but not for B.
635+
///
636+
/// TODO: At the moment, this function can handle only simple cases. For
637+
/// example, we cannot handle a case where a step recurrence is not divisible
638+
/// by the next smaller step recurrence, e.g., A[i][3*j].
638639
void llvm::delinearizeFixedSizeArray(ScalarEvolution &SE, const SCEV *Expr,
639640
SmallVectorImpl<const SCEV *> &Subscripts,
640641
SmallVectorImpl<const SCEV *> &Sizes,

llvm/test/Analysis/Delinearization/fixed_size_array.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ exit:
199199
}
200200

201201
; Fail to delinearize because the step recurrence of the j-loop is not
202-
; dividable by that of the k-loop.
202+
; divisible by that of the k-loop.
203203
;
204204
; void f(int A[][8][32]) {
205205
; for (i = 0; i < 42; i++)
@@ -408,10 +408,10 @@ exit:
408408
; *((int *)((char *)A + i*256 + j*32 + k)) = 1;
409409
; }
410410

411-
; CHECK: Delinearization on function non_dividable_by_element_size:
411+
; CHECK: Delinearization on function non_divisible_by_element_size:
412412
; CHECK: AccessFunction: {{...}}0,+,256}<nuw><nsw><%for.i.header>,+,32}<nw><%for.j.header>,+,1}<nw><%for.k>
413413
; CHECK-NEXT: failed to delinearize
414-
define void @non_dividable_by_element_size(ptr %a) {
414+
define void @non_divisible_by_element_size(ptr %a) {
415415
entry:
416416
br label %for.i.header
417417

0 commit comments

Comments
 (0)