Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -1860,8 +1860,8 @@ // Check for pointer simplifications. if (V->getType()->isPointerTy()) { - // Alloca never returns null, malloc might. - if (isa(V) && Q.DL.getAllocaAddrSpace() == 0) + // Alloca never returns null. + if (isa(V)) return true; // A byval, inalloca, or nonnull argument is never null. Index: test/Analysis/ValueTracking/alloca-nonnull.ll =================================================================== --- /dev/null +++ test/Analysis/ValueTracking/alloca-nonnull.ll @@ -0,0 +1,11 @@ +; RUN: opt -S -instsimplify < %s | FileCheck %s + +target datalayout = "A5" + +; CHECK: ret i1 true +define i1 @f() { +entry: + %a = alloca i32, align 4, addrspace(5) + %tobool = icmp ne i32 addrspace(5)* %a, null + ret i1 %tobool +}