[SCEV] Use constant range of RHS to prove NUW on narrow IV in trip count logic
authorPhilip Reames <listmail@philipreames.com>
Fri, 5 Nov 2021 22:35:53 +0000 (15:35 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 5 Nov 2021 22:36:47 +0000 (15:36 -0700)
commitd24a0e88576dca1c475a7f48d4361136a46f9b72
tree4d8c796590a41d75d6acc4358988cb62c18f217b
parent3c7960cba19ed926b8e86b4c619e81c0f7da4d15
[SCEV] Use constant range of RHS to prove NUW on narrow IV in trip count logic

The basic idea here is that given a zero extended narrow IV, we can prove the inner IV to be NUW if we can prove there's a value the inner IV must take before overflow which must exit the loop.

Differential Revision: https://reviews.llvm.org/D109457
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/trip-count-implied-addrec.ll
llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll