diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-12-14 22:05:20 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-12-14 22:05:20 +0000 |
commit | 7034870f30320d6fbc74effff539d946018cd00a (patch) | |
tree | ee9ae42eaba9f9c6f3d273cb552a89dcf2f7ea2b /include | |
parent | a40d3af28eea6220a69a9fce6af00d605e82f586 (diff) |
[SimplifyCFG] don't sink common insts too soon (PR34603)
This should solve:
https://bugs.llvm.org/show_bug.cgi?id=34603
...by preventing SimplifyCFG from altering redundant instructions before early-cse has a chance to run.
It changes the default (canonical-forming) behavior of SimplifyCFG, so we're only doing the
sinking transform later in the optimization pipeline.
Differential Revision: https://reviews.llvm.org/D38566
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Transforms/Scalar.h | 2 | ||||
-rw-r--r-- | include/llvm/Transforms/Scalar/SimplifyCFG.h | 3 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/Local.h | 10 |
3 files changed, 12 insertions, 3 deletions
diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 07d3d7fc8f6..6fe35b441b5 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -267,7 +267,7 @@ FunctionPass *createJumpThreadingPass(int Threshold = -1); // FunctionPass *createCFGSimplificationPass( unsigned Threshold = 1, bool ForwardSwitchCond = false, - bool ConvertSwitch = false, bool KeepLoops = true, + bool ConvertSwitch = false, bool KeepLoops = true, bool SinkCommon = false, std::function<bool(const Function &)> Ftor = nullptr); //===----------------------------------------------------------------------===// diff --git a/include/llvm/Transforms/Scalar/SimplifyCFG.h b/include/llvm/Transforms/Scalar/SimplifyCFG.h index ed6b1b1853b..1afb9c7f954 100644 --- a/include/llvm/Transforms/Scalar/SimplifyCFG.h +++ b/include/llvm/Transforms/Scalar/SimplifyCFG.h @@ -39,7 +39,8 @@ public: : SimplifyCFGPass(SimplifyCFGOptions() .forwardSwitchCondToPhi(false) .convertSwitchToLookupTable(false) - .needCanonicalLoops(true)) {} + .needCanonicalLoops(true) + .sinkCommonInsts(false)) {} /// Construct a pass with optional optimizations. diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index 6d8d8591fa1..7dd21dfc1a8 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -63,16 +63,20 @@ struct SimplifyCFGOptions { bool ForwardSwitchCondToPhi; bool ConvertSwitchToLookupTable; bool NeedCanonicalLoop; + bool SinkCommonInsts; AssumptionCache *AC; SimplifyCFGOptions(unsigned BonusThreshold = 1, bool ForwardSwitchCond = false, bool SwitchToLookup = false, bool CanonicalLoops = true, + bool SinkCommon = false, AssumptionCache *AssumpCache = nullptr) : BonusInstThreshold(BonusThreshold), ForwardSwitchCondToPhi(ForwardSwitchCond), ConvertSwitchToLookupTable(SwitchToLookup), - NeedCanonicalLoop(CanonicalLoops), AC(AssumpCache) {} + NeedCanonicalLoop(CanonicalLoops), + SinkCommonInsts(SinkCommon), + AC(AssumpCache) {} // Support 'builder' pattern to set members by name at construction time. SimplifyCFGOptions &bonusInstThreshold(int I) { @@ -91,6 +95,10 @@ struct SimplifyCFGOptions { NeedCanonicalLoop = B; return *this; } + SimplifyCFGOptions &sinkCommonInsts(bool B) { + SinkCommonInsts = B; + return *this; + } SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) { AC = Cache; return *this; |