[cfe-dev] Integer factorizations in clang

Chris Lattner clattner at apple.com
Thu Jan 5 10:31:40 PST 2012


On Jan 5, 2012, at 7:15 AM, Ivan Llopard wrote:

> Hi,
> 
> I have a small test case :
> 
> a = b * c + b * d
> 
> and clang is fatorizing b to get only one multiplication (-O3) which is 
> normally good for most architectures. But in my case, that pattern takes 
> just one instruction and I would like to recover it as is.
> Where can I find this particular optimization in clang ?
> Is there a way of setting multiplications as being cheaper than 
> additions/subtracions in clang ?
> 
> Thanks in advance,

As mentioned on llvmdev, the right way to handle this is to write a pattern that matches (a+b)*c -> yourinstruction(a,c,b,c)

-Chris



More information about the cfe-dev mailing list