[LLVMdev] current llvm vs. current gcc code size

Dale Johannesen dalej at apple.com
Fri Aug 22 11:27:55 PDT 2008

This is interesting.  Nobody has tried very hard to get -Os to work  
well AFAIK, so it's that not surprising it doesn't:)  Aside from  
optimization knobs, I don't think there's anything in x86 instruction  
selection to pick small code sequences, which can be important.  I  
suspect -Os will become important later though.

One thing that might be going on is differing default settings.  These  
are worth checking out:
Frame pointer elimination (small prolog/epilog)?
Relocation model (PIC, dynamic-no-pic, static?)
strict aliasing?

On Aug 20, 2008, at 8:50 PMPDT, regehr wrote:

> This is a bit random but perhaps interesting:
> Attached is a histogram of code sizes for about 50,000 random C  
> programs compiled by recent versions of llvm and gcc.  x-axis is  
> bytes in the text segment and y-axis is number of programs in each  
> 100-byte bucket.
> Code size for a program is taken to be the smallest code size across  
> -O0, -O1, -O2, -O3, and -Os, for a given compiler.
> I don't know why each histogram has two peaks, or why llvm's left- 
> hand peak is at a lower code size than gcc's left-hand peak.   
> Perhaps the left-hand peaks indicate trivial random programs that  
> compile completely away and then llvm has a more concise crt0.
> Anyway the interesting effect here is the rightward shift of the  
> main bulk of the binaries produced by llvm vs. gcc.  This would seem  
> to indicate that there are optimization opportunities being missed  
> by llvm.  Ideally, there would be some automatic way to identify  
> these opportunities, perhaps using delta-debugging techniques.  If  
> this seems interesting to people I can look into it more...
> This is targeting x86/Linux.
> John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: size.png
Type: image/png
Size: 4094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080822/e5bc810d/attachment.png>
-------------- next part --------------
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list