[all-commits] [llvm/llvm-project] 4a3dc7: [SCEV] Fix bug involving zero step and non-invaria...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Jul 23 15:19:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a3dc7dc9a03ff4864a0e2cd31b15848481c322b
      https://github.com/llvm/llvm-project/commit/4a3dc7dc9a03ff4864a0e2cd31b15848481c322b
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-07-23 (Fri, 23 Jul 2021)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll

  Log Message:
  -----------
  [SCEV] Fix bug involving zero step and non-invariant RHS in trip count logic

Eli pointed out the issue when reviewing D104140. The max trip count logic makes an assumption that the value of IV changes. When the step is zero, the nowrap fact becomes trivial, and thus there's nothing preventing the loop from being nearly infinite. (The "nearly" part is because mustprogress may disallow an infinite loop while still allowing 999999999 iterations before RHS happens to allow an exit.)

This is very difficult to see in practice. You need a means to produce a loop varying RHS in a mustprogress loop which doesn't allow the loop to be infinite. In most cases, LICM or SCEV are smart enough to remove the loop varying expressions.

Differential Revision: https://reviews.llvm.org/D106327




More information about the All-commits mailing list