[llvm-commits] [llvm] r143719 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/undef.ll
Dan Gohman
gohman at apple.com
Fri Nov 4 11:32:43 PDT 2011
Author: djg
Date: Fri Nov 4 13:32:42 2011
New Revision: 143719
URL: http://llvm.org/viewvc/llvm-project?rev=143719&view=rev
Log:
Teach instsimplify to simplify calls to undef.
Modified:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/undef.ll
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=143719&r1=143718&r2=143719&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Nov 4 13:32:42 2011
@@ -2474,6 +2474,14 @@
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 @@
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
Modified: llvm/trunk/test/Transforms/InstSimplify/undef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/undef.ll?rev=143719&r1=143718&r2=143719&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/undef.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/undef.ll Fri Nov 4 13:32:42 2011
@@ -125,3 +125,10 @@
%r = select i1 undef, i64 undef, i64 %a
ret i64 %r
}
+
+; @test18
+; CHECK: ret i64 undef
+define i64 @test18(i64 %a) {
+ %r = call i64 (i64)* undef(i64 %a)
+ ret i64 %r
+}
More information about the llvm-commits
mailing list