[llvm-commits] Fix for PR1798 (ScalarEvolution)

Wojciech Matyjewicz wmatyjewicz at fastmail.fm
Sun Feb 10 15:18:31 PST 2008


Nick Lewycky wrote:
> 
> Just one question,
> 
> +  const IntegerType *ExTy = IntegerType::get(std::max(DividendBits, 32U));
> 
> why the max of DividendBits and 32? If for whatever reason we think we 
> need only 16 bits for the computation, why expand it to 32?

We compute the divisor of the BC formula using 32-bit arithmetic. Hence,
this is the lower bound for the bitwitdh of the division, and the
dividend as well.

After your question, I have realized that 32 bits for the divisor may be
too much... Using "only" 16 bits would allow us to handle AddRecs up to
length 8. If you agree 16 is a safe bitwidth, I'll change it. However,
the maximum operation you ask about will still be necessary.

The other way is to compute the dividend with the minimum bitwidth (say,
8), and then zero-extend it to 16 (32 withouth the above change) if
necessary just before performing the division. But wouldn't it be an
overkill?

Wojtek



More information about the llvm-commits mailing list