nir: add nir_unsigned_upper_bound and nir_addition_might_overflow
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 12 Nov 2019 17:51:19 +0000 (17:51 +0000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Jul 2020 18:25:35 +0000 (18:25 +0000)
commit72ac3f60261a8510512861b93e843e695331e2ab
tree91c0bd2a3c0937d54b9d1e2dac5a3dc46c34790b
parent2694a34aa2c32aeb32d7d70af91db56c6eaaa23b
nir: add nir_unsigned_upper_bound and nir_addition_might_overflow

This adds a nir_unsigned_upper_bound() helper which does something similar
to nir_analyze_range() except it tries to obtain the largest possible
value instead of it's relation to zero.

It also adds nir_addition_might_overflow(), which uses this helper to try
to prove that an unsigned addition does not wrap around.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2720>
src/compiler/nir/nir.h
src/compiler/nir/nir_range_analysis.c