[SCEV] Make use of non-null pointers for range calculation
authorNikita Popov <npopov@redhat.com>
Fri, 23 Jun 2023 10:50:27 +0000 (12:50 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 29 Jun 2023 07:09:17 +0000 (09:09 +0200)
commit3cd4571405ba9de14072439c23257d9de3a0673b
treed521248a8e985a85c336fb515018a6736ad878ee
parentac1b69b9db5ceaba1d168de47509ab4cf190a93c
[SCEV] Make use of non-null pointers for range calculation

We know that certain pointers (e.g. non-extern-weak globals or
allocas in default address space) are not null, in which case the
lowest address they can be allocated at is their alignment.

This allows us to calculate better exit counts for loops that have
an additional null check in the guarding condition
(see alloca_icmp_null_exit_count).

Differential Revision: https://reviews.llvm.org/D153624
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/alloca.ll
llvm/test/Analysis/ScalarEvolution/incorrect-exit-count.ll
llvm/test/Analysis/ScalarEvolution/load.ll
llvm/test/Analysis/ScalarEvolution/nsw.ll
llvm/test/Analysis/ScalarEvolution/ptrtoint-global.ll
llvm/test/Analysis/ScalarEvolution/sdiv.ll
llvm/test/Analysis/ScalarEvolution/srem.ll