Skip to content

Commit 9f8988a

Browse files
authored
[DependenceAnalysis] Improve debug messages (#156367)
This patch prints the reason why delinearization of array subscripts failed in dependence analysis.
1 parent b0f85be commit 9f8988a

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

llvm/lib/Analysis/DependenceAnalysis.cpp

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,20 +3419,32 @@ bool DependenceInfo::tryDelinearizeFixedSize(
34193419
size_t SSize = Subscripts.size();
34203420
for (size_t I = 1; I < SSize; ++I) {
34213421
const SCEV *S = Subscripts[I];
3422-
if (!isKnownNonNegative(S, Ptr))
3422+
if (!isKnownNonNegative(S, Ptr)) {
3423+
LLVM_DEBUG({
3424+
dbgs() << "Check failed: !isKnownNonNegative(S, Ptr)\n";
3425+
dbgs() << " S: " << *S << "\n" << " Ptr: " << *Ptr << "\n";
3426+
});
34233427
return false;
3428+
}
34243429
if (auto *SType = dyn_cast<IntegerType>(S->getType())) {
34253430
const SCEV *Range = SE->getConstant(
34263431
ConstantInt::get(SType, DimensionSizes[I - 1], false));
3427-
if (!isKnownLessThan(S, Range))
3432+
if (!isKnownLessThan(S, Range)) {
3433+
LLVM_DEBUG({
3434+
dbgs() << "Check failed: !isKnownLessThan(S, Range)\n";
3435+
dbgs() << " S: " << *S << "\n"
3436+
<< " Range: " << *Range << "\n";
3437+
});
34283438
return false;
3439+
}
34293440
}
34303441
}
34313442
return true;
34323443
};
34333444

34343445
if (!AllIndicesInRange(SrcSizes, SrcSubscripts, SrcPtr) ||
34353446
!AllIndicesInRange(DstSizes, DstSubscripts, DstPtr)) {
3447+
LLVM_DEBUG(dbgs() << "Check failed: AllIndicesInRange.\n");
34363448
SrcSubscripts.clear();
34373449
DstSubscripts.clear();
34383450
return false;
@@ -3500,17 +3512,27 @@ bool DependenceInfo::tryDelinearizeParametricSize(
35003512
// to the dependency checks.
35013513
if (!DisableDelinearizationChecks)
35023514
for (size_t I = 1; I < Size; ++I) {
3503-
if (!isKnownNonNegative(SrcSubscripts[I], SrcPtr))
3504-
return false;
3505-
3506-
if (!isKnownLessThan(SrcSubscripts[I], Sizes[I - 1]))
3507-
return false;
3508-
3509-
if (!isKnownNonNegative(DstSubscripts[I], DstPtr))
3510-
return false;
3515+
bool SNN = isKnownNonNegative(SrcSubscripts[I], SrcPtr);
3516+
bool DNN = isKnownNonNegative(DstSubscripts[I], DstPtr);
3517+
bool SLT = isKnownLessThan(SrcSubscripts[I], Sizes[I - 1]);
3518+
bool DLT = isKnownLessThan(DstSubscripts[I], Sizes[I - 1]);
3519+
if (SNN && DNN && SLT && DLT)
3520+
continue;
35113521

3512-
if (!isKnownLessThan(DstSubscripts[I], Sizes[I - 1]))
3513-
return false;
3522+
LLVM_DEBUG({
3523+
dbgs() << "Delinearization checks failed: can't prove the following\n";
3524+
if (!SNN)
3525+
dbgs() << " isKnownNonNegative(" << *SrcSubscripts[I] << ")\n";
3526+
if (!DNN)
3527+
dbgs() << " isKnownNonNegative(" << *DstSubscripts[I] << ")\n";
3528+
if (!SLT)
3529+
dbgs() << " isKnownLessThan(" << *SrcSubscripts[I] << ", "
3530+
<< *Sizes[I - 1] << ")\n";
3531+
if (!DLT)
3532+
dbgs() << " isKnownLessThan(" << *DstSubscripts[I] << ", "
3533+
<< *Sizes[I - 1] << ")\n";
3534+
});
3535+
return false;
35143536
}
35153537

35163538
return true;

0 commit comments

Comments
 (0)