Bail for complex execution contexts of invariant loads

llvm-svn: 267146
This commit is contained in:
Johannes Doerfert 2016-04-22 11:41:14 +00:00
parent dffc1410c5
commit d77089e62d
3 changed files with 59 additions and 9 deletions

View File

@ -3176,14 +3176,23 @@ void Scop::addInvariantLoads(ScopStmt &Stmt, MemoryAccessList &InvMAs) {
if (InvMAs.empty())
return;
auto *StmtInvalidCtx = Stmt.getInvalidContext();
// Get the context under which the statement is executed but remove the error
// context under which this statement is reached.
isl_set *DomainCtx = isl_set_params(Stmt.getDomain());
DomainCtx = isl_set_subtract(DomainCtx, Stmt.getInvalidContext());
DomainCtx = isl_set_subtract(DomainCtx, StmtInvalidCtx);
DomainCtx = isl_set_remove_redundancies(DomainCtx);
DomainCtx = isl_set_detect_equalities(DomainCtx);
DomainCtx = isl_set_coalesce(DomainCtx);
if (isl_set_n_basic_set(DomainCtx) >= MaxConjunctsInDomain) {
auto *AccInst = InvMAs.front()->getAccessInstruction();
invalidate(COMPLEXITY, AccInst->getDebugLoc());
isl_set_free(DomainCtx);
return;
}
// Project out all parameters that relate to loads in the statement. Otherwise
// we could have cyclic dependences on the constraints under which the
// hoisted loads are executed and we could not determine an order in which to

View File

@ -0,0 +1,47 @@
; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops \
; RUN: < %s 2>&1 | FileCheck %s
;
; CHECK: Low complexity assumption:
;
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@board = external global [421 x i8], align 16
; Function Attrs: nounwind uwtable
define fastcc void @ping_recurse(i32* nocapture %mx, i32* nocapture %mr, i32 %color) unnamed_addr {
entry:
br label %land.lhs.true38.1
if.end58: ; preds = %land.lhs.true38.2, %if.end54.1
ret void
land.lhs.true38.1: ; preds = %entry
%arrayidx34.1 = getelementptr inbounds [421 x i8], [421 x i8]* @board, i64 0, i64 0
%arrayidx40.1 = getelementptr inbounds i32, i32* %mr, i64 0
%0 = load i32, i32* %arrayidx40.1, align 4
%cmp41.1 = icmp eq i32 %0, 0
br i1 %cmp41.1, label %land.lhs.true43.1, label %if.end54.1
land.lhs.true43.1: ; preds = %land.lhs.true38.1
%arrayidx45.1 = getelementptr inbounds i32, i32* %mx, i64 0
%1 = load i32, i32* %arrayidx45.1, align 4
%cmp46.1 = icmp eq i32 %1, 1
%cmp51.1 = icmp eq i32 0, %color
%or.cond.1 = or i1 %cmp51.1, %cmp46.1
br i1 %or.cond.1, label %if.then53.1, label %if.end54.1
if.then53.1: ; preds = %land.lhs.true43.1
tail call fastcc void @ping_recurse(i32* nonnull %mx, i32* nonnull %mr, i32 %color)
br label %if.end54.1
if.end54.1: ; preds = %if.then53.1, %land.lhs.true43.1, %land.lhs.true38.1
%arrayidx34.2 = getelementptr inbounds [421 x i8], [421 x i8]* @board, i64 0, i64 0
%2 = load i8, i8* %arrayidx34.2, align 1
%cmp36.2 = icmp eq i8 %2, 3
br i1 %cmp36.2, label %if.end58, label %land.lhs.true38.2
land.lhs.true38.2: ; preds = %if.end54.1
%arrayidx40.2 = getelementptr inbounds i32, i32* %mr, i64 0
%3 = load i32, i32* %arrayidx40.2, align 4
br label %if.end58
}

View File

@ -5,14 +5,8 @@ target triple = "x86_64-unknown-linux-gnu"
%struct.hoge = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [8 x [2 x i32]], [8 x [2 x i32]], [4 x [4 x i32]], i32, i32, i32, i32, [256 x i8], [256 x i8], [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, [500 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [1024 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], i32, i32, i32*, i32*, i8*, i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, [5 x double], i32, [8 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [6 x double], [6 x double], [256 x i8], i32, i32, i32, i32, [2 x [5 x i32]], [2 x [5 x i32]], i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i32 }
; The assumed context of this test case has at some point become very complex.
; However, since we keep both the assumed as well as invalid context that
; problem is solved.
;
; CHECK: Assumed Context:
; CHECK-NEXT: [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { : }
; CHECK: Invalid Context:
; CHECK-NEXT: [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { : (tmp37 < 0 and tmp41 < 0 and tmp46 > 0) or (tmp17 < 0 and tmp21 < 0) or (tmp17 < 0 and tmp21 > 0) or (tmp17 > 0 and tmp21 < 0) or (tmp17 > 0 and tmp21 > 0) or (tmp37 < 0 and tmp41 > 0 and tmp46 > 0) or (tmp37 > 0 and tmp41 < 0 and tmp46 > 0) or (tmp37 > 0 and tmp41 > 0 and tmp46 > 0) or (tmp27 = 3 and tmp31 <= 143) or (tmp56 = 0 and tmp52 < 0) or (tmp56 = 0 and tmp52 > 0) }
; The execution context of invalid loads in this test case has at some point become very complex and we should bail.
; CHECK-NOT: Statements
@global = external global [300 x i8], align 16
@global1 = external global %struct.hoge*, align 8