Hello, 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, Ivan
Hi Ivan,> 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 ?if you see the b*(c+d) pattern can't you just generate your b*c+b*d instruction for it? Ciao, Duncan.
Le 5 janv. 2012 à 15:59, Ivan Llopard a écrit :> Hello, > > 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 ?Wouldn't it be simpler to detect factorize pattern in you code and generate the appropriate instruction as it if was a decomposed form. It would have the benefit to properly optimize the code if the developer choose to use the factorized form directly. -- Jean-Daniel
Le 05/01/2012 16:35, Jean-Daniel Dupas a écrit :> Le 5 janv. 2012 à 15:59, Ivan Llopard a écrit : > >> Hello, >> >> 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 ? > Wouldn't it be simpler to detect factorize pattern in you code and generate the appropriate instruction as it if was a decomposed form. > It would have the benefit to properly optimize the code if the developer choose to use the factorized form directly.Ok, I will try to match the factorized form from my back-end. Thanks you all.> > -- Jean-Daniel > > > >
Possibly Parallel Threads
- [LLVMdev] Integer factorizations in clang
- [LLVMdev] Official git mirroring of llvm, clang, lldb, test-suite, etc.?
- [SOLVED]Re: TLS/SSL error loading cert file. </etc/asterisk/keys/asterisk.pem> [Almost SOLVED]
- TLS/SSL error loading cert file. </etc/asterisk/keys/asterisk.pem> [Almost SOLVED]
- Attach a GPS in preboot mode