Skip to content
Commit 027a4c8b authored by Joshua Cao's avatar Joshua Cao
Browse files

[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
parent da36d1f0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment