[all-commits] [llvm/llvm-project] fd77fa: [SCEV] Add ranges tests

Joshua Cao via All-commits all-commits at lists.llvm.org
Mon Apr 24 00:32:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fd77fab07afe4d3ea7383cf2c9a0f659e27ee77f
      https://github.com/llvm/llvm-project/commit/fd77fab07afe4d3ea7383cf2c9a0f659e27ee77f
  Author: Joshua Cao <cao.joshua at yahoo.com>
  Date:   2023-04-24 (Mon, 24 Apr 2023)

  Changed paths:
    M llvm/test/Analysis/ScalarEvolution/ranges.ll

  Log Message:
  -----------
  [SCEV] Add ranges tests


  Commit: da36d1f09901fa5c0e9c0102bbefecbdeedd4ef2
      https://github.com/llvm/llvm-project/commit/da36d1f09901fa5c0e9c0102bbefecbdeedd4ef2
  Author: Joshua Cao <cao.joshua at yahoo.com>
  Date:   2023-04-24 (Mon, 24 Apr 2023)

  Changed paths:
    A llvm/test/Analysis/ScalarEvolution/trip-multiple.ll

  Log Message:
  -----------
  [SCEV] Add trip multiple tests


  Commit: 027a4c8b96c7f97df8e98b1dac069b956810ab94
      https://github.com/llvm/llvm-project/commit/027a4c8b96c7f97df8e98b1dac069b956810ab94
  Author: Joshua Cao <cao.joshua at yahoo.com>
  Date:   2023-04-24 (Mon, 24 Apr 2023)

  Changed paths:
    M llvm/include/llvm/Analysis/ScalarEvolution.h
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/nsw.ll
    M llvm/test/Analysis/ScalarEvolution/ranges.ll
    M llvm/test/Analysis/ScalarEvolution/trip-multiple-guard-info.ll
    M llvm/test/Analysis/ScalarEvolution/trip-multiple.ll

  Log Message:
  -----------
  [SCEV] Precise trip multiples

We currently have getMinTrailingZeros(), from which we can get a SCEV's
multiple by computing 1 << MinTrailingZeroes. However, this only gets us
multiples that are a power of 2. This patch introduces a way to get max
constant multiples that are not just a power of 2. The logic is similar
to that of getMinTrailingZeros. getMinTrailingZeros is replaced by
computing the max constant multiple, and counting the number of trailing
bits.

This is applied in two places:

1) Computing unsigned constant ranges. For example, if we have i8
   {10,+,10}<nuw>, we know the max constant it can be is 250.

2) Computing trip multiples as shown in SCEV output. This is useful if
   for example, we are unrolling a loop by a factor of 5, and we know
   the trip multiple is 5, then we don't need a loop epilog.

If the code sees that a SCEV does not have <nuw>, it will fall back to
finding the max multiple that is a power of 2. Multiples that are a
power of 2 will still be a multiple even after the SCEV overflows.

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


Compare: https://github.com/llvm/llvm-project/compare/61fee67cd77a...027a4c8b96c7


More information about the All-commits mailing list