[LLVMdev] Poor floating point optimizations?

Sdadsda Sdasdaas llvmuser at yahoo.com
Sat Nov 20 16:08:23 PST 2010


Thanks for replying so fast. This UnsafeFPMath trick in fact solves "pxor adds" 
case, but the resulting code is still not as good as I expected from LLVM. 

For example expressions like "1+x+1+x+1+x+1+x" (basically adding a lot of 
constants and variables) are complied to a long series off <add>s both in IR 
and 
assembly code.
Both GCC and MSVC generates C1*x +C2 (mov + mul + add).

I am new to using LLVM. I am using Visual Studio 2008 on Windows, targeting 
32-bit X86 code. I'm using LLVM as a library. I've 
added setOptLevel(CodeGenOpt::Aggressive) to the engine but with no effect. 
Please let me know if there are some optimization options/passes in LLVM that 
could optimize such example expressions as  "1+x+1+x+1+x+1+x".

Bob


      



More information about the llvm-dev mailing list