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 | 85977e6ab46e4691b941f2ae0b6cbaf4dbdfecc8 (patch) | |
tree | 03c6d9a6c241d8746bfa36ecd3a0cfd7bf7a59be /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 97540c3a4a58340f98c0e64b622f7fd3b50861ac (diff) | |
download | bcm5719-llvm-85977e6ab46e4691b941f2ae0b6cbaf4dbdfecc8.tar.gz bcm5719-llvm-85977e6ab46e4691b941f2ae0b6cbaf4dbdfecc8.zip |
Teach instsimplify to simplify calls to undef.
llvm-svn: 143719
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index c2ddc6d4863..c1416328b74 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/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 |