[all-commits] [llvm/llvm-project] 149e01: [LoopIdiom] 'arithmetic right-shift until zero': d...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Tue May 25 11:03:34 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 149e018d12642cf8cda9b26f2ffc66a63cc3cc25
      https://github.com/llvm/llvm-project/commit/149e018d12642cf8cda9b26f2ffc66a63cc3cc25
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2021-05-25 (Tue, 25 May 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
    M llvm/test/Transforms/LoopIdiom/X86/arithmetic-right-shift-until-zero.ll

  Log Message:
  -----------
  [LoopIdiom] 'arithmetic right-shift until zero': don't turn potentially infinite loops into finite ones

Nowadays LLVM does not assume that all loops are finite,
so if we want to produce a finite loop from a potentially-infinite one,
we must ensure that the original loop is known to be a finite one.

For this transform, it only matters for arithmetic right-shifts.
For them, either the function or the loop must be known to
be `mustprogress`, or the original value being shifted must be known
to be non-negative (because iff the sign bit was set,
it will never become zero, but will become `-1` in the "end").

It would be really good for alive2 to actually complain about this,
but it currently does not: https://github.com/AliveToolkit/alive2/issues/726




More information about the All-commits mailing list