diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 19:34:46 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-24 19:34:46 +0000 |
commit | 3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1 (patch) | |
tree | 1aa8c2d5969c527ac4bafc5c71fe4dfd39fa9ae2 /llvm/lib/Transforms/Scalar/EarlyCSE.cpp | |
parent | f15064871ad933370532f068eca70fb5134ba69f (diff) | |
download | bcm5719-llvm-3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1.tar.gz bcm5719-llvm-3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1.zip |
SimplifyInstruction does not imply DCE
We cannot remove an instruction with no uses just because
SimplifyInstruction succeeds. It may have side effects.
llvm-svn: 273711
Diffstat (limited to 'llvm/lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/EarlyCSE.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp index 0e93b0a37b0..9d0ef42e039 100644 --- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp @@ -582,11 +582,18 @@ bool EarlyCSE::processNode(DomTreeNode *Node) { // its simpler value. if (Value *V = SimplifyInstruction(Inst, DL, &TLI, &DT, &AC)) { DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n'); - Inst->replaceAllUsesWith(V); - Inst->eraseFromParent(); - Changed = true; - ++NumSimplify; - continue; + if (!Inst->use_empty()) { + Inst->replaceAllUsesWith(V); + Changed = true; + } + if (isInstructionTriviallyDead(Inst, &TLI)) { + Inst->eraseFromParent(); + Changed = true; + } + if (Changed) { + ++NumSimplify; + continue; + } } // If this is a simple instruction that we can value number, process it. |