LLVM
8.0.1
|
This pass transforms loops that contain branches or switches on loop- invariant conditions to have multiple loops. More...
#include "llvm/Transforms/Scalar/SimpleLoopUnswitch.h"
Public Member Functions | |
SimpleLoopUnswitchPass (bool NonTrivial=false) | |
PreservedAnalyses | run (Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U) |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::PassInfoMixin< SimpleLoopUnswitchPass > | |
static StringRef | name () |
Gets the name of the pass we are mixed into. More... | |
This pass transforms loops that contain branches or switches on loop- invariant conditions to have multiple loops.
For example, it turns the left into the right code:
for (...) if (lic) A for (...) if (lic) A; B; C B else C for (...) A; C
This can increase the size of the code exponentially (doubling it every time a loop is unswitched) so we only unswitch if the resultant code will be smaller than a threshold.
This pass expects LICM to be run before it to hoist invariant conditions out of the loop, to make the unswitching opportunity obvious.
There is a taxonomy of unswitching that we use to classify different forms of this transformaiton:
This pass always does trivial, full unswitching for both branches and switches. For branches, it also always does trivial, partial unswitching.
If enabled (via the constructor's NonTrivial
parameter), this pass will additionally do non-trivial, full unswitching for branches and switches, and will do non-trivial, partial unswitching for branches.
Because partial unswitching of switches is extremely unlikely to be possible in practice and significantly complicates the implementation, this pass does not currently implement that in any mode.
Definition at line 63 of file SimpleLoopUnswitch.h.
Definition at line 67 of file SimpleLoopUnswitch.h.
References llvm::createSimpleLoopUnswitchLegacyPass(), and run().
PreservedAnalyses SimpleLoopUnswitchPass::run | ( | Loop & | L, |
LoopAnalysisManager & | AM, | ||
LoopStandardAnalysisResults & | AR, | ||
LPMUpdater & | U | ||
) |
Definition at line 2812 of file SimpleLoopUnswitch.cpp.
References llvm::LoopStandardAnalysisResults::AC, llvm::LPPassManager::addLoop(), llvm::AnalysisUsage::addPreserved(), llvm::AnalysisUsage::addRequired(), llvm::PreservedAnalyses::all(), assert(), llvm::dbgs(), llvm::LPPassManager::deleteSimpleAnalysisLoop(), llvm::LoopStandardAnalysisResults::DT, llvm::EnableMSSALoopDependency, F(), llvm::CallingConv::Fast, llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::getLoopAnalysisUsage(), llvm::getLoopPassPreservedAnalyses(), llvm::Value::getName(), llvm::Loop::getName(), llvm::BasicBlock::getParent(), llvm::PassRegistry::getPassRegistry(), llvm::Optional< T >::getPointer(), llvm::Optional< T >::hasValue(), INITIALIZE_PASS_BEGIN(), INITIALIZE_PASS_DEPENDENCY, llvm::initializeSimpleLoopUnswitchLegacyPassPass(), llvm::LoopStandardAnalysisResults::LI, LLVM_DEBUG, llvm::LPPassManager::markLoopAsDeleted(), llvm::LoopStandardAnalysisResults::MSSA, llvm::LoopStandardAnalysisResults::SE, llvm::LoopStandardAnalysisResults::TTI, unswitchLoop(), llvm::DominatorTreeBase< NodeT, IsPostDom >::verify(), llvm::VerifyMemorySSA, and llvm::MemorySSA::verifyMemorySSA().
Referenced by SimpleLoopUnswitchPass().