[all-commits] [llvm/llvm-project] 99d258: [ScalarEvolution] Handle <= and >= in non infinite...
William Moses via All-commits
all-commits at lists.llvm.org
Fri Jan 28 14:41:19 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 99d2582164c4bc8f10c3e3c20dd3690243ad49ba
https://github.com/llvm/llvm-project/commit/99d2582164c4bc8f10c3e3c20dd3690243ad49ba
Author: William S. Moses <gh at wsmoses.com>
Date: 2022-01-28 (Fri, 28 Jan 2022)
Changed paths:
M llvm/include/llvm/Analysis/ScalarEvolution.h
M llvm/lib/Analysis/ScalarEvolution.cpp
A llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
Log Message:
-----------
[ScalarEvolution] Handle <= and >= in non infinite loops
Extend scalar evolution to handle >= and <= if a loop is known to be finite and the induction variable guards the condition. Specifically, with these assumptions lhs <= rhs is equivalent to lhs < rhs + 1 and lhs >= rhs to lhs > rhs -1.
In the case of lhs <= rhs, this is true since the only case these are not equivalent
is when rhs == unsigned/signed intmax, which would have resulted in an infinite loop.
In the case of lhs >= rhs, this is true since the only case these are not equivalent
is when rhs == unsigned/signed intmin, which would again have resulted in an infinite loop.
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D118090
More information about the All-commits
mailing list