From a1bbdff93363c81a10fb1dec91d54a4fe926f4d3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 27 Nov 2008 23:18:11 +0000 Subject: enhance RecursivelyDeleteTriviallyDeadInstructions to make PHIs dead if they are single-value. llvm-svn: 60194 --- llvm/lib/Transforms/Utils/Local.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Transforms') 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(I)) { + if (Value *PNV = PN->hasConstantValue()) + PN->replaceAllUsesWith(PNV); + } + + // Okay, if the instruction is dead, delete it. if (!isInstructionTriviallyDead(I)) continue; -- cgit v1.2.3