[LLVMdev] TableGen syntax for matching a constant load

Chris Lattner clattner at apple.com
Sat Feb 26 18:40:19 PST 2011


On Feb 26, 2011, at 6:12 PM, Jakob Stoklund Olesen wrote:

>> 
>> All these patterns have one important downside. They are suboptimal if
>> more than one store happens in a row. E.g. the 0 store is better
>> expressed as xor followed by two register moves, if a register is
>> available... This is most noticable when memset() gets inlined
> 
> Note that LLVM's -Os option does not quite mean the same as GCC's flag.
> It disables optimizations that increase code size without a clear performance gain.
> It does not try to minimize code size at any cost.

Jakob is right, but there is a clear market for "smallest at any cost".  The FreeBSD folks would really like to build their bootloader with clang for example :).

It should be reasonably easy to add a new "optsize2" function attribute to LLVM IR, and have that be set with -Oz (the "optimize for size at any cost") flag, which could then enable stuff like this.

There are lots of other cases where this would be useful, such as forced use of "rep; movsb" on x86, which is much smaller than a call to memset, but also much slower :).

-Chris 



More information about the llvm-dev mailing list