diff options
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 5 | ||||
-rw-r--r-- | polly/test/Isl/CodeGen/variant_load_empty_domain.ll | 47 | ||||
-rw-r--r-- | polly/test/ScopInfo/cond_constant_in_loop.ll | 10 | ||||
-rw-r--r-- | polly/test/ScopInfo/switch-4.ll | 4 | ||||
-rw-r--r-- | polly/test/ScopInfo/switch-5.ll | 6 | ||||
-rw-r--r-- | polly/test/ScopInfo/variant_load_empty_domain.ll | 52 |
6 files changed, 110 insertions, 14 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index f5fb5fa57b9..a530acfa9e4 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -2373,7 +2373,10 @@ void Scop::simplifySCoP(bool RemoveIgnoredStmts) { ? Stmt.getRegion()->getNode() : getRegion().getBBNode(Stmt.getBasicBlock()); - if (StmtIt->isEmpty() || (RemoveIgnoredStmts && isIgnored(RN))) { + if (StmtIt->isEmpty() || + isl_set_is_empty(DomainMap[getRegionNodeBasicBlock(RN)]) || + (RemoveIgnoredStmts && isIgnored(RN))) { + // Remove the statement because it is unnecessary. if (Stmt.isRegionStmt()) for (BasicBlock *BB : Stmt.getRegion()->blocks()) diff --git a/polly/test/Isl/CodeGen/variant_load_empty_domain.ll b/polly/test/Isl/CodeGen/variant_load_empty_domain.ll new file mode 100644 index 00000000000..5757b448a7c --- /dev/null +++ b/polly/test/Isl/CodeGen/variant_load_empty_domain.ll @@ -0,0 +1,47 @@ +; RUN: opt %loadPolly -polly-codegen -polly-detect-unprofitable -analyze < %s +; +; +; void f(int *A) { +; for (int i = 1; i < 10; i++) { +; A[i]++; +; if (i > 10) +; A[i] += A[0]; +; } +; } +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @f(i32* %A) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %entry ] + %exitcond = icmp ne i64 %indvars.iv, 10 + br i1 %exitcond, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv + %tmp = load i32, i32* %arrayidx, align 4 + %inc = add nsw i32 %tmp, 1 + store i32 %inc, i32* %arrayidx, align 4 + br i1 false, label %if.then, label %if.end + +if.then: ; preds = %for.body + %tmp1 = load i32, i32* %A, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv + %tmp2 = load i32, i32* %arrayidx4, align 4 + %add = add nsw i32 %tmp2, %tmp1 + store i32 %add, i32* %arrayidx4, align 4 + br label %if.end + +if.end: ; preds = %if.then, %for.body + br label %for.inc + +for.inc: ; preds = %if.end + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} diff --git a/polly/test/ScopInfo/cond_constant_in_loop.ll b/polly/test/ScopInfo/cond_constant_in_loop.ll index f864c45522b..d86615a0342 100644 --- a/polly/test/ScopInfo/cond_constant_in_loop.ll +++ b/polly/test/ScopInfo/cond_constant_in_loop.ll @@ -43,9 +43,7 @@ return: ; preds = %bb3, %entry ret void } -; CHECK: Stmt_bb1 -; CHECK: Domain := -; CHECK: [M, N] -> { Stmt_bb1[i0] : i0 >= 0 and i0 <= -1 + M }; -; CHECK: Stmt_bb2 -; CHECK: Domain := -; CHECK: [M, N] -> { Stmt_bb2[i0] : 1 = 0 }; +; CHECK: Stmt_bb1 +; CHECK: Domain := +; CHECK: [M] -> { Stmt_bb1[i0] : i0 >= 0 and i0 <= -1 + M }; +; CHECK-NOT: Stmt_bb2 diff --git a/polly/test/ScopInfo/switch-4.ll b/polly/test/ScopInfo/switch-4.ll index 5cce7662cb1..627d6ed7f78 100644 --- a/polly/test/ScopInfo/switch-4.ll +++ b/polly/test/ScopInfo/switch-4.ll @@ -22,9 +22,7 @@ ; } ; ; CHECK: Statements { -; CHECK: Stmt_sw_default -; CHECK: Domain := -; CHECK: [N] -> { Stmt_sw_default[i0] : 1 = 0 }; +; CHECK-NOT: Stmt_sw_default ; CHECK: Stmt_sw_bb ; CHECK: Domain := ; CHECK: [N] -> { Stmt_sw_bb[i0] : exists (e0 = floor((i0)/4): 4e0 = i0 and i0 >= 0 and i0 <= -1 + N) }; diff --git a/polly/test/ScopInfo/switch-5.ll b/polly/test/ScopInfo/switch-5.ll index 834c703852a..73622674911 100644 --- a/polly/test/ScopInfo/switch-5.ll +++ b/polly/test/ScopInfo/switch-5.ll @@ -19,10 +19,8 @@ ; CHECK: Domain := ; CHECK: [N] -> { Stmt_for_body[0] : N >= 1 }; ; CHECK: Schedule := -; CHECK: [N] -> { Stmt_for_body[i0] -> [0, 0] }; -; CHECK: Stmt_sw_bb -; CHECK: Domain := -; CHECK: [N] -> { Stmt_sw_bb[i0] : 1 = 0 }; +; CHECK: [N] -> { Stmt_for_body[i0] -> [0] }; +; CHECK-NOT: Stmt_sw_bb ; CHECK: } ; ; AST: if (N >= 1) diff --git a/polly/test/ScopInfo/variant_load_empty_domain.ll b/polly/test/ScopInfo/variant_load_empty_domain.ll new file mode 100644 index 00000000000..d42d24818f3 --- /dev/null +++ b/polly/test/ScopInfo/variant_load_empty_domain.ll @@ -0,0 +1,52 @@ +; RUN: opt %loadPolly -polly-scops -polly-detect-unprofitable -analyze < %s | FileCheck %s +; +; CHECK: Invariant Accesses: { +; CHECK-NEXT: } +; +; CHECK-NOT: Stmt_if_then +; +; +; void f(int *A) { +; for (int i = 1; i < 10; i++) { +; A[i]++; +; if (i > 10) +; A[i] += A[0]; +; } +; } +; +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @f(i32* %A) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %entry ] + %exitcond = icmp ne i64 %indvars.iv, 10 + br i1 %exitcond, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv + %tmp = load i32, i32* %arrayidx, align 4 + %inc = add nsw i32 %tmp, 1 + store i32 %inc, i32* %arrayidx, align 4 + br i1 false, label %if.then, label %if.end + +if.then: ; preds = %for.body + %tmp1 = load i32, i32* %A, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv + %tmp2 = load i32, i32* %arrayidx4, align 4 + %add = add nsw i32 %tmp2, %tmp1 + store i32 %add, i32* %arrayidx4, align 4 + br label %if.end + +if.end: ; preds = %if.then, %for.body + br label %for.inc + +for.inc: ; preds = %if.end + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} |