diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -6816,7 +6816,8 @@ Opts.RoundToAlign = false; Opts.NullIsUnknownSize = true; uint64_t ObjSize; - if ((isa(V) || isa(V)) && + if ((isa(V) || isa(V) || + isAllocationFn(V, &TLI)) && getObjectSize(V, ObjSize, DL, &TLI, Opts) && ObjSize > 1) { // The highest address the object can start is ObjSize bytes before the // end (unsigned max value). If this value is not a multiple of the diff --git a/llvm/test/Analysis/ScalarEvolution/malloc.ll b/llvm/test/Analysis/ScalarEvolution/malloc.ll --- a/llvm/test/Analysis/ScalarEvolution/malloc.ll +++ b/llvm/test/Analysis/ScalarEvolution/malloc.ll @@ -5,7 +5,7 @@ ; CHECK-LABEL: 'f' ; CHECK-NEXT: Classifying expressions for: @f ; CHECK-NEXT: %alloc = tail call dereferenceable(64) ptr @malloc(i64 64) -; CHECK-NEXT: --> %alloc U: full-set S: full-set +; CHECK-NEXT: --> %alloc U: [1,-64) S: full-set ; CHECK-NEXT: Determining loop execution counts for: @f ; %alloc = tail call dereferenceable(64) ptr @malloc(i64 64) @@ -16,7 +16,7 @@ ; CHECK-LABEL: 'f2' ; CHECK-NEXT: Classifying expressions for: @f2 ; CHECK-NEXT: %alloc = tail call dereferenceable_or_null(64) ptr @malloc(i64 64) -; CHECK-NEXT: --> %alloc U: full-set S: full-set +; CHECK-NEXT: --> %alloc U: [0,-64) S: full-set ; CHECK-NEXT: Determining loop execution counts for: @f2 ; %alloc = tail call dereferenceable_or_null(64) ptr @malloc(i64 64)