[PATCH] D118090: [ScalarEvolution] Handle <= and >= in non infinite loops
William Moses via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 24 18:10:29 PST 2022
wsmoses created this revision.
wsmoses added reviewers: jdoerfert, fhahn, nikic.
Herald added a subscriber: hiraditya.
wsmoses requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118090
Files:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/unittests/Analysis/ScalarEvolutionTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118090.402726.patch
Type: text/x-patch
Size: 11936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220125/ceda7722/attachment.bin>
More information about the llvm-commits
mailing list