[LLVMdev] opts do not occur in some situations?

Chris Lattner clattner at apple.com
Wed Dec 17 23:51:07 PST 2008


On Dec 7, 2008, at 12:13 AM, Azriel Fasten wrote:

> Hi, I'm trying to understand the optimization passes. I was wondering
> why some seemingly obvious optimizations don't occur in some
> situations.

Hi Azriel,

Sorry for the delay in responding.

You're hitting a serious problem we have with llvm-gcc, which is that  
the GCC inliner is going crazy and inlining functions it should  
definitely not be inlining (such as recursive functions like this).  I  
filed this bug about it:
http://llvm.org/bugs/show_bug.cgi?id=3232

The other impact that you're seeing is that floating point math is not  
commutative, so tail recursion elimination cannot be done.  If you  
change this to pass 19 as an int, and use this command:

$ llvm-gcc main.opt.cpp -S -o - -emit-llvm -O0 | llvm-as | opt -std- 
compile-opts | llvm-dis

You'll see that it gets completely constant folded into a call to  
printf.

-Chris




More information about the llvm-dev mailing list