diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-27 23:18:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-27 23:18:11 +0000 |
commit | 564c0a233010cb1ff2f9ee2d4d16870284d72487 (patch) | |
tree | 492d1adfad99f0fea72206f3a5e4f0cfe38d3a15 /lib/Transforms/Utils/Local.cpp | |
parent | 4f02c74a8ec8f4ca83b823146cb9c987ed79b3f6 (diff) |
enhance RecursivelyDeleteTriviallyDeadInstructions to make
PHIs dead if they are single-value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60194 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 1e1b386944..cab7f03ab0 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/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; |