diff options
author | Dan Gohman <gohman@apple.com> | 2011-11-04 18:32:42 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2011-11-04 18:32:42 +0000 |
commit | 71d050315704c23b235594d3fad5268c12d825e3 (patch) | |
tree | 15ddf159c60ed3223809791456baa648bfe4be69 /lib/Analysis/InstructionSimplify.cpp | |
parent | 73a1ad8f0560f01830fd206e84d4a21e5b3b7f59 (diff) |
Teach instsimplify to simplify calls to undef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | lib/Analysis/InstructionSimplify.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index c2ddc6d486..c1416328b7 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -2474,6 +2474,14 @@ Value *llvm::SimplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS, return ::SimplifyCmpInst(Predicate, LHS, RHS, TD, DT, RecursionLimit); } +static Value *SimplifyCallInst(CallInst *CI) { + // call undef -> undef + if (isa<UndefValue>(CI->getCalledValue())) + return UndefValue::get(CI->getType()); + + return 0; +} + /// SimplifyInstruction - See if we can compute a simplified version of this /// instruction. If not, this returns null. Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD, @@ -2569,6 +2577,9 @@ Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD, case Instruction::PHI: Result = SimplifyPHINode(cast<PHINode>(I), DT); break; + case Instruction::Call: + Result = SimplifyCallInst(cast<CallInst>(I)); + break; } /// If called on unreachable code, the above logic may report that the |