[all-commits] [llvm/llvm-project] 212450: [IRCE] Relax restrictions on IRCE's latch exit count

Max Kazantsev via All-commits all-commits at lists.llvm.org
Thu Apr 13 02:00:36 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2124505fe4c9ff85173c5ca3b14810f698436239
      https://github.com/llvm/llvm-project/commit/2124505fe4c9ff85173c5ca3b14810f698436239
  Author: Max Kazantsev <mkazantsev at azul.com>
  Date:   2023-04-13 (Thu, 13 Apr 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
    M llvm/test/Transforms/IRCE/stride_more_than_1.ll

  Log Message:
  -----------
  [IRCE] Relax restrictions on IRCE's latch exit count

It seems that existing logic is too strict about latch block exit count.
It is required to be computable, however it is not used in any computations,
and effectively the only thing it is used for is to get the type of computed
exit count.

Sometimes the exit count for latch block is not known, but the loop is still
finite because of other exits, and safe bounds are still computable. In this case,
we miss an opportunity to apply IRCE.
We could instead use a more relaxed version - max symbolic exit count, which,
if exists, is enough to say that the loop is finite, and its type should be good enough.

There is a subtlety with type: we do not support latch count type wider than range
check type. Because of that, we want to have the narrowest type available. So if it
can be computed from latch block immediately, take it. Otherwise, take whatever whole
loop provides and hope that it's type isn't too wide.

Differential Revision: https://reviews.llvm.org/D147910
Reviewed By: danilaml




More information about the All-commits mailing list