diff options
author | Devang Patel <dpatel@apple.com> | 2007-06-28 00:44:10 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-06-28 00:44:10 +0000 |
commit | 558f1b8439847d6241cb033ba32c5aeaed0cf8ff (patch) | |
tree | b9bde02ec1e844926e1c13d25b4476a9d31afdf7 /lib | |
parent | a20f35d2e71fda42f773d40efde0aff9e07f2804 (diff) | |
download | external_llvm-558f1b8439847d6241cb033ba32c5aeaed0cf8ff.zip external_llvm-558f1b8439847d6241cb033ba32c5aeaed0cf8ff.tar.gz external_llvm-558f1b8439847d6241cb033ba32c5aeaed0cf8ff.tar.bz2 |
If a condition is not inside a loop then the condition is suitable
to loop unswitch candidate for the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 7ad3bd6..b797918 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -128,6 +128,13 @@ LoopPass *llvm::createLoopUnswitchPass(bool Os) { static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) { // Constants should be folded, not unswitched on! if (isa<Constant>(Cond)) return false; + + // If cond is not in loop then it is not suitable. + if (Instruction *I = dyn_cast<Instruction>(Cond)) + if (!L->contains(I->getParent())) + return 0; + if (isa<Argument>(Cond)) + return 0; // TODO: Handle: br (VARIANT|INVARIANT). // TODO: Hoist simple expressions out of loops. |