Allow switch instructions in SCoPs
This patch allows switch instructions with affine conditions in the
SCoP. Also switch instructions in non-affine subregions are allowed.
Both did not require much changes to the code, though there was some
refactoring needed to integrate them without code duplication.
In the llvm-test suite the number of profitable SCoPs increased from
135 to 139 but more importantly we can handle more benchmarks and user
inputs without preprocessing.
Differential Revision: http://reviews.llvm.org/D13200
llvm-svn: 248701
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 69904f0..c55a474 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -345,3 +345,17 @@
return false;
}
+
+Value *polly::getConditionFromTerminator(TerminatorInst *TI) {
+ if (BranchInst *BR = dyn_cast<BranchInst>(TI)) {
+ if (BR->isUnconditional())
+ return ConstantInt::getTrue(Type::getInt1Ty(TI->getContext()));
+
+ return BR->getCondition();
+ }
+
+ if (SwitchInst *SI = dyn_cast<SwitchInst>(TI))
+ return SI->getCondition();
+
+ return nullptr;
+}