There are a number of issues with the current code for converting ule -> ult (etc) predicates for comparisons controlling finite loops:
- It sets nowrap flags, which may only hold for that particular comparison, not globally. (PR60944)
- It doesn't check that the RHS is invariant. (I'm not sure this can cause practical issues independently of the previous point.)
- It runs before simplifications that may be more profitable. (PR54191)
This patch moves the handling for this into computeExitLimitFromICmp(), because it is somewhat tightly coupled with assumptions in that code, and addresses the aforementioned issues.
Fixes https://github.com/llvm/llvm-project/issues/60944.
Fixes https://github.com/llvm/llvm-project/issues/54191.
Can this overflow?