[llvm] r214135 - IR: Optimize size of use-list order shuffle vectors

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jul 29 10:44:31 PDT 2014


> On 2014-Jul-29, at 10:21, David Blaikie <dblaikie at gmail.com> wrote:
> 
>> Every use list shuffle will be at least size 2 (otherwise, there's
>> nothing to shuffle).  If mallocs had 0B memory overhead,
>> `std::vector<unsigned>` of size 2 would cost 32B.  Since mallocs
>> actually do have overhead (usually at least 16B), the common case (2-6
>> items) will take less memory.
> 
> Right - but for every element that's bigger than the small space, you
> still pay the small in the Stack, so it does become a bit of a matter
> of size statistics as to where the sweet spot is.

True.  I just grabbed 6 because it meant strictly less overhead than std::vector
for small size, and I can't imagine there being enough fewer use-lists size 2-6
(savings: malloc overhead + (size-2)*4B) than there are >=7 (losses: 8B) for it
to be a net loss.



More information about the llvm-commits mailing list