[llvm-commits] X*log2(Y*0.5)->X*log2(Y)-X (under fast math)

Pedro Artigas partigas at apple.com
Fri Nov 30 10:41:17 PST 2012


Hello Shuxin,

Answer inline

On Nov 30, 2012, at 10:22 AM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:

> hi, Pedro:
> 
>   Just curious, *NOT* review. 
>  o.   What's the advantage of this transformation if the costs (say, in term of latency) between 
> fadd/fsub and fmpy is negligible?
> 

I agree that if cost of multiplication = cost of addition the transform is not useful but LLVM assumes that cost of multiplication > cost of addition (for example when it transforms 2*X into X+X) already and this is true in architectures I can think of so, since it is already an embedded assumption, this is no different than what other passes already do. Ideally one would have an abstract arch model to make this only trigger when the assumption holds but AFAIK there is no such thing today.

>   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.

Hope to have cleared all issues

Thanks

Pedro

> Thanks
> Shuxin
> 
> On 11/30/12 9:39 AM, Pedro Artigas wrote:
>> Hello All,
>> 
>> This patch implements the above algebra transform under fast math flag.
>> 
>> Thanks
>> 
>> Pedro Artigas
>> 
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121130/0e272629/attachment.html>


More information about the llvm-commits mailing list