diff options
author | Philip Reames <listmail@philipreames.com> | 2019-04-01 16:05:15 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-04-01 16:05:15 +0000 |
commit | d109e2a7c3b7602c92e1fd92884876a28b68fd78 (patch) | |
tree | 299d5cd55fd5fcc8031d8baae391aeeef3719892 /llvm/lib/Transforms | |
parent | dae5ff2b7b8e0eedea2d7cc6b767e83a57d997b1 (diff) | |
download | bcm5719-llvm-d109e2a7c3b7602c92e1fd92884876a28b68fd78.tar.gz bcm5719-llvm-d109e2a7c3b7602c92e1fd92884876a28b68fd78.zip |
[LoopPred] Delete the old condition expressions if unused
LoopPredication was replacing the original condition, but leaving the instructions to compute the old conditions around. This would get cleaned up by other passes of course, but we might as well do it eagerly. That also makes the test output less confusing.
llvm-svn: 357406
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopPredication.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index 7695889a4a5..6257f419459 100644 --- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp @@ -193,6 +193,7 @@ #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" #define DEBUG_TYPE "loop-predication" @@ -641,7 +642,9 @@ bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard, LastCheck = Check; else LastCheck = Builder.CreateAnd(LastCheck, Check); + auto *OldCond = Guard->getOperand(0); Guard->setOperand(0, LastCheck); + RecursivelyDeleteTriviallyDeadInstructions(OldCond); LLVM_DEBUG(dbgs() << "Widened checks = " << NumWidened << "\n"); return true; @@ -676,9 +679,11 @@ bool LoopPredication::widenWidenableBranchGuardConditions( // Make sure that the check contains widenable condition and therefore can be // further widened. LastCheck = Builder.CreateAnd(LastCheck, WidenableCondition); + auto *OldCond = Guard->getOperand(0); Guard->setOperand(0, LastCheck); assert(isGuardAsWidenableBranch(Guard) && "Stopped being a guard after transform?"); + RecursivelyDeleteTriviallyDeadInstructions(OldCond); LLVM_DEBUG(dbgs() << "Widened checks = " << NumWidened << "\n"); return true; |