[llvm-commits] X*log2(Y*0.5)->X*log2(Y)-X (under fast math)
Duncan Sands
baldrick at free.fr
Mon Dec 3 00:41:29 PST 2012
Hi Pedro,
>> o. As far as I can understand, this change only catch log2(0.5 x x) => log2x
>> - 1.
>> Is it able to figure out a FP value is negative-power-of-2 (to make this
>> transformation more general)?
>>
>
> A negative power of two would require a multiply and a subtract because the
> factor would not be -1 in general, (for 0.5 it is -1) so it does not really
> apply as at that point the instruction count would increase.
subtraction doesn't require an extra operation if you are subtracting a
constant, which would be the case here: you can do x+(-1) for example,
where -1 is evaluated at compile time (ConstantInt).
Ciao, Duncan.
More information about the llvm-commits
mailing list