[all-commits] [llvm/llvm-project] ea12c2: [SCEV] Move mustprogress based no-self-wrap logic ...

Philip Reames via All-commits all-commits at lists.llvm.org
Thu Nov 18 10:10:58 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ea12c2cb9c4221095abfb2af7148140783040734
      https://github.com/llvm/llvm-project/commit/ea12c2cb9c4221095abfb2af7148140783040734
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-11-18 (Thu, 18 Nov 2021)

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

  Log Message:
  -----------
  [SCEV] Move mustprogress based no-self-wrap logic so it applies to all exit conditions

This change moves logic which we'd added specifically for less than tests so that it applies to equalities and greater than tests as well. The basic idea is that if we can show an IV cycles infinitely through the same series on self-wrap, and that the exit condition must be taken to prevent UB, we can conclude that it must be taken before self-wrap and thus infer said flag.

The motivation here is simple loops with unsigned induction variables w/non-one steps and inequality tests. A toy example would be:
for (unsigned i = 0; i != N; i += 2) { body; }

If body contains no side effects, and this is a mustprogress function, we can assume that this must be a finite loop and thus that the exit count is N/2.

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




More information about the All-commits mailing list