summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-10-22 19:10:07 +0000
committerSanjay Patel <spatel@rotateright.com>2017-10-22 19:10:07 +0000
commitb80daf0b48c6be27812c95904298fac0c9bdc4e2 (patch)
tree26cfe1572d9998ca15e55056cc18a3a3cf4dfb98 /llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
parentdc168722daa842e93c3651057b3dde507a5c1e2d (diff)
downloadbcm5719-llvm-b80daf0b48c6be27812c95904298fac0c9bdc4e2.tar.gz
bcm5719-llvm-b80daf0b48c6be27812c95904298fac0c9bdc4e2.zip
[SimplifyCFG] delay switch condition forwarding to -latesimplifycfg
As discussed in D39011: https://reviews.llvm.org/D39011 ...replacing constants with a variable is inverting the transform done by other IR passes, so we definitely don't want to do this early. In fact, it's questionable whether this transform belongs in SimplifyCFG at all. I'll look at moving this to codegen as a follow-up step. llvm-svn: 316298
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index 723619f46bb..6f38e5d11b5 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -179,8 +179,10 @@ static bool simplifyFunctionCFG(Function &F, const TargetTransformInfo &TTI,
return true;
}
+// FIXME: The new pass manager always creates a "late" simplifycfg pass using
+// this default constructor.
SimplifyCFGPass::SimplifyCFGPass()
- : Options(UserBonusInstThreshold, true, false) {}
+ : Options(UserBonusInstThreshold, true, true, false) {}
SimplifyCFGPass::SimplifyCFGPass(const SimplifyCFGOptions &PassOptions)
: Options(PassOptions) {}
@@ -200,12 +202,15 @@ namespace {
struct BaseCFGSimplifyPass : public FunctionPass {
std::function<bool(const Function &)> PredicateFtor;
int BonusInstThreshold;
+ bool ForwardSwitchCondToPhi;
bool ConvertSwitchToLookupTable;
bool KeepCanonicalLoops;
- BaseCFGSimplifyPass(int T, bool ConvertSwitch, bool KeepLoops,
+ BaseCFGSimplifyPass(int T, bool ForwardSwitchCond, bool ConvertSwitch,
+ bool KeepLoops,
std::function<bool(const Function &)> Ftor, char &ID)
: FunctionPass(ID), PredicateFtor(std::move(Ftor)),
+ ForwardSwitchCondToPhi(ForwardSwitchCond),
ConvertSwitchToLookupTable(ConvertSwitch),
KeepCanonicalLoops(KeepLoops) {
BonusInstThreshold = (T == -1) ? UserBonusInstThreshold : T;
@@ -219,8 +224,9 @@ struct BaseCFGSimplifyPass : public FunctionPass {
const TargetTransformInfo &TTI =
getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
return simplifyFunctionCFG(F, TTI,
- {BonusInstThreshold, ConvertSwitchToLookupTable,
- KeepCanonicalLoops, AC});
+ {BonusInstThreshold, ForwardSwitchCondToPhi,
+ ConvertSwitchToLookupTable, KeepCanonicalLoops,
+ AC});
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -235,7 +241,7 @@ struct CFGSimplifyPass : public BaseCFGSimplifyPass {
CFGSimplifyPass(int T = -1,
std::function<bool(const Function &)> Ftor = nullptr)
- : BaseCFGSimplifyPass(T, false, true, Ftor, ID) {
+ : BaseCFGSimplifyPass(T, false, false, true, Ftor, ID) {
initializeCFGSimplifyPassPass(*PassRegistry::getPassRegistry());
}
};
@@ -245,7 +251,7 @@ struct LateCFGSimplifyPass : public BaseCFGSimplifyPass {
LateCFGSimplifyPass(int T = -1,
std::function<bool(const Function &)> Ftor = nullptr)
- : BaseCFGSimplifyPass(T, true, false, Ftor, ID) {
+ : BaseCFGSimplifyPass(T, true, true, false, Ftor, ID) {
initializeLateCFGSimplifyPassPass(*PassRegistry::getPassRegistry());
}
};
OpenPOWER on IntegriCloud