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

Owen Anderson resistor at mac.com
Sat Dec 1 03:42:26 PST 2012


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.

--Owen



More information about the llvm-commits mailing list