[PATCH] D145510: [SCEV] Fix finite loop non-strict predicate simplification (PR60944)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 08:20:43 PST 2023


nikic created this revision.
nikic added reviewers: mkazantsev, fhahn, reames, efriedma, wsmoses.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


https://reviews.llvm.org/D145510

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
  llvm/test/Transforms/IndVarSimplify/pr60944.ll
  llvm/test/Transforms/IndVarSimplify/range-iter-threshold.ll
  llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-value.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145510.503051.patch
Type: text/x-patch
Size: 15426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230307/a96a2867/attachment.bin>


More information about the llvm-commits mailing list