[ForwardOpTree] Test the max operations quota.

cl::opt<unsigned long> is not specialized and hence the option
-polly-optree-max-ops impossible to use.

Replace by supported option cl::opt<unsigned>.

Also check for an error state when computing the written value, which
happens when the quota runs out.

llvm-svn: 313546
This commit is contained in:
Michael Kruse 2017-09-18 17:43:50 +00:00
parent 078d5d978c
commit ef8325ba50
3 changed files with 50 additions and 2 deletions

View File

@ -51,7 +51,7 @@ static cl::opt<bool>
cl::desc("Analyze array contents for load forwarding"),
cl::cat(PollyCategory), cl::init(true), cl::Hidden);
static cl::opt<unsigned long>
static cl::opt<unsigned>
MaxOps("polly-optree-max-ops",
cl::desc("Maximum number of ISL operations to invest for known "
"analysis; 0=no limit"),

View File

@ -422,7 +422,7 @@ isl::map ZoneAlgorithm::getWrittenValue(MemoryAccess *MA, isl::map AccRel) {
: Stmt->getSurroundingLoop();
if (AccVal &&
AccVal->getType() == MA->getLatestScopArrayInfo()->getElementType() &&
AccRel.is_single_valued())
AccRel.is_single_valued().is_true())
return makeValInst(AccVal, Stmt, L);
// memset(_, '0', ) is equivalent to writing the null value to all touched

View File

@ -0,0 +1,48 @@
; RUN: opt %loadPolly -polly-optree-max-ops=1 -polly-optree -analyze < %s | FileCheck %s -match-full-lines
; RUN: opt %loadPolly -polly-optree-max-ops=1 -polly-optree -disable-output -stats < %s 2>&1 | FileCheck %s -match-full-lines -check-prefix=STATS
; REQUIRES: asserts
;
; for (int j = 0; j < n; j += 1) {
; bodyA:
; double val = B[j];
;
; bodyB:
; A[j] = val;
; }
;
define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) {
entry:
br label %for
for:
%j = phi i32 [0, %entry], [%j.inc, %inc]
%j.cmp = icmp slt i32 %j, %n
br i1 %j.cmp, label %bodyA, label %exit
bodyA:
%B_idx = getelementptr inbounds double, double* %B, i32 %j
%val = load double, double* %B_idx
br label %bodyB
bodyB:
%A_idx = getelementptr inbounds double, double* %A, i32 %j
store double %val, double* %A_idx
br label %inc
inc:
%j.inc = add nuw nsw i32 %j, 1
br label %for
exit:
br label %return
return:
ret void
}
; CHECK: ForwardOpTree executed, but did not modify anything
; STATS-NOT: IMPLEMENTATION ERROR: Unhandled error state
; STATS: 1 polly-optree - Analyses aborted because max_operations was reached
; STATS-NOT: IMPLEMENTATION ERROR: Unhandled error state