[llvm-commits] [llvm] r169049 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Duncan Sands baldrick at free.fr
Sat Dec 1 05:13:12 PST 2012


Hi Owen,

On 01/12/12 12:42, Owen Anderson wrote:
>
> On Dec 1, 2012, at 3:24 AM, Duncan Sands <baldrick at free.fr> wrote:
>
>> Hi Pedro,
>>
>>> I believe the comments at the beginning of the function are descriptive enough,
>>> here are the comments copied for your convenience
>>>
>>> //
>>> // Detect pattern:
>>> //
>>> // log2(Y*0.5)
>>
>> why so special?  Why not turn log2(Y*Constant) into log2(Y) + log2(Constant)
>> for pretty much any constant, evaluating log2(Constant) at compile time?
>
> It might not be a good idea to evaluate log2(cst) on the host when its math implementation might not match the target's.  However, this transform probably could be generalized to handle other powers of two, since log2(cst) can be evaluated trivially for them.

it would be great to have a library that evaluates constant expressions
like log2(something) perfectly, rather than having to do this dance around
whether the host evaluates functions accurately enough.  I think GCC uses
MPFR for this.  In the meantime I suppose we are obliged, as you say, to
restrict to cases we can evaluate exactly.

Ciao, Duncan.



More information about the llvm-commits mailing list