Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llvm/lib/Analysis/DependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,12 @@ bool DependenceInfo::isKnownLessThan(const SCEV *S, const SCEV *Size) const {
// Special check for addrecs using BE taken count
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(S))
if (AddRec->isAffine() && AddRec->hasNoSignedWrap()) {
const SCEV *BECount = SE->getBackedgeTakenCount(AddRec->getLoop());
const SCEV *BECount = collectUpperBound(AddRec->getLoop(), MaxType);
// If the BTC cannot be computed, check the base case for S.
if (!BECount)
return false;
if (isa<SCEVCouldNotCompute>(BECount))
return SE->isKnownNegative(SE->getMinusSCEV(S, Size));
const SCEV *Start = AddRec->getStart();
const SCEV *Step = AddRec->getStepRecurrence(*SE);
const SCEV *End = AddRec->evaluateAtIteration(BECount, *SE);
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/Analysis/DependenceAnalysis/becount-couldnotcompute.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 | FileCheck %s

; Test for function isKnownLessThan that calculates a back-edge taken count,
; which can return a CouldNotCompute SCEV.

define void @test(i64 %conv, ptr %a) {
; CHECK-LABEL: 'test'
; CHECK-NEXT: Src: %ld = load i32, ptr %arrayidx12, align 4 --> Dst: %ld = load i32, ptr %arrayidx12, align 4
; CHECK-NEXT: da analyze - none!
;
entry:
%sub = add i64 %conv, 1
br label %loop

loop:
%i = phi i64 [ %add26, %loop ], [ 0, %entry ]
%arrayidx12 = getelementptr i32, ptr %a, i64 %i
%ld = load i32, ptr %arrayidx12, align 4
%add26 = add nsw i64 %sub, %i
br label %loop
}