diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPredication.cpp')
-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; |