summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-27 23:18:11 +0000
committerChris Lattner <sabre@nondot.org>2008-11-27 23:18:11 +0000
commita1bbdff93363c81a10fb1dec91d54a4fe926f4d3 (patch)
tree9f28ef9e815a28595050e4ff4770f5802cfdde21 /llvm/lib/Transforms/Utils/Local.cpp
parent1cb4f72706dc16173c8747a848ca0205f79b347f (diff)
downloadbcm5719-llvm-a1bbdff93363c81a10fb1dec91d54a4fe926f4d3.tar.gz
bcm5719-llvm-a1bbdff93363c81a10fb1dec91d54a4fe926f4d3.zip
enhance RecursivelyDeleteTriviallyDeadInstructions to make
PHIs dead if they are single-value. llvm-svn: 60194
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 1e1b3869446..cab7f03ab0f 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -190,6 +190,15 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V,
while (!Insts.empty()) {
I = *Insts.begin();
Insts.erase(I);
+
+ // If this is a PHI node, we may be able to make it dead if we know all the
+ // input values are the same.
+ if (PHINode *PN = dyn_cast<PHINode>(I)) {
+ if (Value *PNV = PN->hasConstantValue())
+ PN->replaceAllUsesWith(PNV);
+ }
+
+ // Okay, if the instruction is dead, delete it.
if (!isInstructionTriviallyDead(I))
continue;
OpenPOWER on IntegriCloud