summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-06-24 19:34:46 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-06-24 19:34:46 +0000
commit3b3e954ea2a48d0d466dec383f6bfa40a90dd0e1 (patch)
tree1aa8c2d5969c527ac4bafc5c71fe4dfd39fa9ae2 /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parentf15064871ad933370532f068eca70fb5134ba69f (diff)
downloadbcm5719-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/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 1d8d2a5e469..e7957f9599a 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -1746,13 +1746,18 @@ bool JumpThreadingPass::DuplicateCondBranchOnPHIIntoPred(
// phi translation.
if (Value *IV =
SimplifyInstruction(New, BB->getModule()->getDataLayout())) {
- delete New;
ValueMapping[&*BI] = IV;
+ if (!New->mayHaveSideEffects()) {
+ delete New;
+ New = nullptr;
+ }
} else {
+ ValueMapping[&*BI] = New;
+ }
+ if (New) {
// Otherwise, insert the new instruction into the block.
New->setName(BI->getName());
PredBB->getInstList().insert(OldPredBranch->getIterator(), New);
- ValueMapping[&*BI] = New;
}
}
OpenPOWER on IntegriCloud