diff options
author | Tobias Grosser <tobias@grosser.es> | 2013-09-07 01:54:13 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2013-09-07 01:54:13 +0000 |
commit | 3613fd7a35fbdfe03d7a0b2a2aba1812442940cf (patch) | |
tree | 52455909fc633f1276f7624249aa905c99d615b7 /polly | |
parent | 9f9bc4f7700bdba35f9f4f6521fc8f57a64d4b04 (diff) | |
download | bcm5719-llvm-3613fd7a35fbdfe03d7a0b2a2aba1812442940cf.tar.gz bcm5719-llvm-3613fd7a35fbdfe03d7a0b2a2aba1812442940cf.zip |
ScopInfo: Correctly handle true/false conditions
This is a modified version of the orignally contributed patch.
Contributed-by: alexandre.isoard@gmail.com
llvm-svn: 190237
Diffstat (limited to 'polly')
-rw-r--r-- | polly/lib/Analysis/TempScopInfo.cpp | 7 | ||||
-rw-r--r-- | polly/test/Cloog/CodeGen/single_loop_zero_iterations.ll | 2 | ||||
-rw-r--r-- | polly/test/Isl/CodeGen/single_loop_zero_iterations.ll | 2 | ||||
-rw-r--r-- | polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll | 2 | ||||
-rw-r--r-- | polly/test/ScopInfo/cond_constant_in_loop.ll | 53 |
5 files changed, 59 insertions, 7 deletions
diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp index 5aa8d9669e9..066f06811a4 100644 --- a/polly/lib/Analysis/TempScopInfo.cpp +++ b/polly/lib/Analysis/TempScopInfo.cpp @@ -230,13 +230,12 @@ void TempScopInfo::buildLoopBounds(TempScop &Scop) { void TempScopInfo::buildAffineCondition(Value &V, bool inverted, Comparison **Comp) const { if (ConstantInt *C = dyn_cast<ConstantInt>(&V)) { - // If this is always true condition, we will create 1 >= 0, - // otherwise we will create 1 == 0. + // If this is always true condition, we will create 0 == 0, + // otherwise we will create 0 != 0. const SCEV *LHS = SE->getConstant(C->getType(), 0); - const SCEV *RHS = SE->getConstant(C->getType(), 1); if (C->isOne() == inverted) - *Comp = new Comparison(RHS, LHS, ICmpInst::ICMP_NE); + *Comp = new Comparison(LHS, LHS, ICmpInst::ICMP_NE); else *Comp = new Comparison(LHS, LHS, ICmpInst::ICMP_EQ); diff --git a/polly/test/Cloog/CodeGen/single_loop_zero_iterations.ll b/polly/test/Cloog/CodeGen/single_loop_zero_iterations.ll index ee00c6abe62..6956fddbfb2 100644 --- a/polly/test/Cloog/CodeGen/single_loop_zero_iterations.ll +++ b/polly/test/Cloog/CodeGen/single_loop_zero_iterations.ll @@ -67,4 +67,4 @@ return: ; preds = %if.else, %if.then ; CHECK: for region: 'for.cond => for.end.region' in function 'main': ; CHECK-NEXT: main(): -; CHECK-NEXT: Stmt_for_body(0); +; CHECK-NOT: Stmt_for_body(0); diff --git a/polly/test/Isl/CodeGen/single_loop_zero_iterations.ll b/polly/test/Isl/CodeGen/single_loop_zero_iterations.ll index 23354ffab3c..48403f57dc0 100644 --- a/polly/test/Isl/CodeGen/single_loop_zero_iterations.ll +++ b/polly/test/Isl/CodeGen/single_loop_zero_iterations.ll @@ -67,4 +67,4 @@ return: ; preds = %if.else, %if.then ; CHECK: for region: 'for.cond => for.end.region' in function 'main': ; CHECK-NEXT: main(): -; CHECK-NEXT: Stmt_for_body(0); +; CHECK-NOT: Stmt_for_body(0); diff --git a/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll b/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll index fb316921bab..894d57d7daf 100644 --- a/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll +++ b/polly/test/ScheduleOptimizer/2012-10-14-Zero-Bands.ll @@ -24,4 +24,4 @@ return: } ; CHECK: Calculated schedule: -; CHECK: { Stmt_if_then[] -> [] } +; CHECK-NOT: Stmt_if_then diff --git a/polly/test/ScopInfo/cond_constant_in_loop.ll b/polly/test/ScopInfo/cond_constant_in_loop.ll new file mode 100644 index 00000000000..a71ec46b1cc --- /dev/null +++ b/polly/test/ScopInfo/cond_constant_in_loop.ll @@ -0,0 +1,53 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s + +;void f(long a[], long N, long M) { +; long i, j, k; +; for (j = 0; j < M; ++j) +; if (true) +; a[j] = j; +; else { +; a[j] = M; +; a[j - N] = 0; +; } +;} + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @f(i64* nocapture %a, i64 %N, i64 %M) nounwind { +entry: + %0 = icmp sgt i64 %M, 0 ; <i1> [#uses=1] + br i1 %0, label %bb, label %return + +bb: ; preds = %bb3, %entry + %1 = phi i64 [ 0, %entry ], [ %2, %bb3 ] ; <i64> [#uses=5] + %scevgep = getelementptr i64* %a, i64 %1 ; <i64*> [#uses=2] + br i1 true, label %bb1, label %bb2 + +bb1: ; preds = %bb + store i64 %1, i64* %scevgep, align 8 + br label %bb3 + +bb2: ; preds = %bb + %tmp7 = sub i64 %1, %N ; <i64> [#uses=1] + %scevgep8 = getelementptr i64* %a, i64 %tmp7 ; <i64*> [#uses=1] + store i64 %M, i64* %scevgep, align 8 + store i64 0, i64* %scevgep8, align 8 + br label %bb3 + +bb3: ; preds = %bb2, %bb1 + %2 = add nsw i64 %1, 1 ; <i64> [#uses=2] + %exitcond = icmp eq i64 %2, %M ; <i1> [#uses=1] + br i1 %exitcond, label %return, label %bb + +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 }; + |