[SCEV] Compute non-strict exit counts without widening if RHS < MAX (#237107)
For `IV <= RHS` exits, if RHS is loop invariant and less than MAX on
entry to the loop,
RHS + 1 does not wrap.
Compute the exit count as `IV < RHS + 1` in the original type before
widening, where howManyLessThans
can use loop guards to rule out IV overflow.
Updates the RHS argument of helper to allow contextual information
nsw/nuw etc.
howManyLessThans ( .. , const SCEV* RHS )
->
howManyLessThans ( .. , SCEVUse RHS )
Alive2: https://alive2.llvm.org/ce/z/77u3KL unsigned and signed source.
IR diff: https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1900
scalar-evolution.NumExitCountsComputed does increase for few cases.
compile time:
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1901 - [ -6%
, +1 %] compile time delta. geomean 0.04%
compile-time-tracker:
http://llvm-compile-time-tracker.com/compare.php?from=9640b6a6cc9516095c37006f78438e6aa7fc7c05&to=8c51f651759f7cbc99f6fe821cf6ee72687ba491&stat=instructions:u