summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp3
-rw-r--r--llvm/test/Transforms/InstSimplify/call.ll16
2 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 746b7409dfe..b52ffeebe61 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4009,7 +4009,8 @@ static Value *SimplifyCall(Value *V, IterTy ArgBegin, IterTy ArgEnd,
FunctionType *FTy = cast<FunctionType>(Ty);
// call undef -> undef
- if (isa<UndefValue>(V))
+ // call null -> undef
+ if (isa<UndefValue>(V) || isa<ConstantPointerNull>(V))
return UndefValue::get(FTy->getReturnType());
Function *F = dyn_cast<Function>(V);
diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
index b360ecb8434..814f1f21aca 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -187,4 +187,20 @@ cast.end: ; preds = %cast.notnull, %entr
; CHECK: br i1 %cmp, label %cast.end, label %cast.notnull
}
+define i32 @call_null() {
+entry:
+ %call = call i32 null()
+ ret i32 %call
+}
+; CHECK-LABEL: define i32 @call_null(
+; CHECK: ret i32 undef
+
+define i32 @call_undef() {
+entry:
+ %call = call i32 undef()
+ ret i32 %call
+}
+; CHECK-LABEL: define i32 @call_undef(
+; CHECK: ret i32 undef
+
declare noalias i8* @malloc(i64)
OpenPOWER on IntegriCloud