[Polly][PATCH 3/8] Ensure the runtime condition is always a i1 type

Johannes Doerfert doerfert at cs.uni-saarland.de
Sun Aug 10 00:50:24 PDT 2014


---
 lib/CodeGen/IslAst.cpp                                              | 4 +++-
 lib/CodeGen/IslCodeGeneration.cpp                                   | 4 +++-
 test/Isl/Ast/run-time-condition.ll                                  | 2 +-
 test/Isl/Ast/simple-run-time-condition.ll                           | 2 +-
 test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll | 2 +-
 test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll         | 2 +-
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/CodeGen/IslAst.cpp b/lib/CodeGen/IslAst.cpp
index 6090426..500e219 100644
--- a/lib/CodeGen/IslAst.cpp
+++ b/lib/CodeGen/IslAst.cpp
@@ -294,9 +294,11 @@ void IslAst::buildRunCondition(__isl_keep isl_ast_build *Build) {
   PwZero = isl_pw_aff_intersect_domain(
       PwZero, isl_set_complement(S->getAssumedContext()));
 
-  isl_pw_aff *Cond = isl_pw_aff_union_max(PwOne, PwZero);
+  isl_pw_aff *Cond = isl_pw_aff_union_max(isl_pw_aff_copy(PwOne), PwZero);
 
   RunCondition = isl_ast_build_expr_from_pw_aff(Build, Cond);
+  RunCondition = isl_ast_expr_eq(RunCondition,
+                                 isl_ast_build_expr_from_pw_aff(Build, PwOne));
 }
 
 IslAst::IslAst(Scop *Scop, Dependences &D) : S(Scop) {
diff --git a/lib/CodeGen/IslCodeGeneration.cpp b/lib/CodeGen/IslCodeGeneration.cpp
index 9cf8bf8..73662f1 100644
--- a/lib/CodeGen/IslCodeGeneration.cpp
+++ b/lib/CodeGen/IslCodeGeneration.cpp
@@ -590,7 +590,9 @@ public:
   Value *buildRTC(PollyIRBuilder &Builder, IslExprBuilder &ExprBuilder) {
     Builder.SetInsertPoint(Builder.GetInsertBlock()->getTerminator());
     Value *RTC = ExprBuilder.create(AI->getRunCondition());
-    return Builder.CreateIsNotNull(RTC);
+    assert(RTC->getType()->isIntegerTy(1) &&
+           "Runtime condition should have i1 type");
+    return RTC;
   }
 
   bool runOnScop(Scop &S) {
diff --git a/test/Isl/Ast/run-time-condition.ll b/test/Isl/Ast/run-time-condition.ll
index 8820932..625b79f 100644
--- a/test/Isl/Ast/run-time-condition.ll
+++ b/test/Isl/Ast/run-time-condition.ll
@@ -28,7 +28,7 @@ for.end:                                          ; preds = %for.cond
   ret void
 }
 
-; CHECK: if (1)
+; CHECK: if (1 == 1)
 ; CHECK:     for (int c1 = 0; c1 <= 1023; c1 += 1)
 ; CHECK:       Stmt_for_body(c1);
 ; CHECK: else
diff --git a/test/Isl/Ast/simple-run-time-condition.ll b/test/Isl/Ast/simple-run-time-condition.ll
index 8eff8be..6059c90 100644
--- a/test/Isl/Ast/simple-run-time-condition.ll
+++ b/test/Isl/Ast/simple-run-time-condition.ll
@@ -18,7 +18,7 @@ target triple = "x86_64-unknown-linux-gnu"
 ; for the delinearization is simplified such that conditions that would not
 ; cause any code to be executed are not generated.
 
-; CHECK: if ((q == 100 && o <= 0) || (q == 0 && o >= 1) ? 1 : 0)
+; CHECK: if (((q == 100 && o <= 0) || (q == 0 && o >= 1) ? 1 : 0) == 1)
 
 ; CHECK:     if (o >= 1) {
 ; CHECK:       for (int c1 = 0; c1 < n; c1 += 1)
diff --git a/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll b/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll
index 9d7e406..e098219 100644
--- a/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll
+++ b/test/Isl/CodeGen/multidim_2d_parametric_array_static_loop_bounds.ll
@@ -12,7 +12,7 @@ target triple = "x86_64-unknown-linux-gnu"
 
 ; CHECK: %[[T0:[._a-zA-Z0-9]]] = icmp sge i64 %m, 150
 ; CHECK: %[[T1:[._a-zA-Z0-9]]] = select i1 %[[T0]], i64 1, i64 0
-; CHECK: %[[T2:[._a-zA-Z0-9]]] = icmp ne i64 %[[T1]], 0
+; CHECK: %[[T2:[._a-zA-Z0-9]]] = icmp eq i64 %[[T1]], 1
 ; CHECK: br i1 %[[T2]], label %polly.start, label %for.i
 
 define void @foo(i64 %n, i64 %m, double* %A) {
diff --git a/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll b/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll
index 18e8e27..a3c7ddb 100644
--- a/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll
+++ b/test/Isl/CodeGen/run-time-condition-with-scev-parameters.ll
@@ -5,7 +5,7 @@
 ; CHECK: %[[T0:[._a-zA-Z0-9]]] = zext i32 %n to i64
 ; CHECK: %[[T1:[._a-zA-Z0-9]]] = icmp sge i64 %[[T0]], 1
 ; CHECK: %[[T2:[._a-zA-Z0-9]]] = select i1 %[[T1]], i64 1, i64 0
-; CHECK: %[[T3:[._a-zA-Z0-9]]] = icmp ne i64 %[[T2]], 0
+; CHECK: %[[T3:[._a-zA-Z0-9]]] = icmp eq i64 %[[T2]], 1
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
-- 
2.0.4




More information about the llvm-commits mailing list