summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp4
-rw-r--r--polly/test/ScopInfo/constant-non-integer-branch-condition.ll27
2 files changed, 29 insertions, 2 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index f513c81e198..043fc61884a 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -421,8 +421,8 @@ bool ScopDetection::isValidCFG(BasicBlock &BB, bool IsLoopBranch,
if (isa<UndefValue>(Condition))
return invalid<ReportUndefCond>(Context, /*Assert=*/true, TI, &BB);
- // Constant conditions are always affine.
- if (isa<Constant>(Condition))
+ // Constant integer conditions are always affine.
+ if (isa<ConstantInt>(Condition))
return true;
if (BranchInst *BI = dyn_cast<BranchInst>(TI))
diff --git a/polly/test/ScopInfo/constant-non-integer-branch-condition.ll b/polly/test/ScopInfo/constant-non-integer-branch-condition.ll
new file mode 100644
index 00000000000..c58f92d6dca
--- /dev/null
+++ b/polly/test/ScopInfo/constant-non-integer-branch-condition.ll
@@ -0,0 +1,27 @@
+; RUN: opt %loadPolly -analyze -polly-scops %s | FileCheck %s
+;
+; At some point this caused a problem in the domain generation as we
+; assumed any constant branch condition to be valid. However, only constant
+; integers are interesting and can be handled.
+;
+; CHECK: Stmt_entry_split__TO__cleanup
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; Function Attrs: nounwind uwtable
+define i32 @main(i32* %A) #0 {
+entry:
+ br label %entry.split
+
+entry.split: ; preds = %entry
+ br i1 icmp ne (i32 (...)* @test_weak, i32 (...)* null), label %if.then, label %cleanup
+
+if.then: ; preds = %entry.split
+ store i32 0, i32* %A
+ br label %cleanup
+
+cleanup: ; preds = %if.then, %entry.split
+ ret i32 0
+}
+
+declare extern_weak i32 @test_weak(...)
OpenPOWER on IntegriCloud