[llvm-commits] Review request: dominance frontier computation speedup

Cameron Zwarich zwarich at apple.com
Wed Nov 24 11:37:21 PST 2010


On Nov 24, 2010, at 12:44 PM, Jakob Stoklund Olesen wrote:

> On Nov 23, 2010, at 11:34 PM, Cameron Zwarich wrote:
> 
>> On 2010-11-23, at 11:16 PM, Jakob Stoklund Olesen wrote:
>> 
>>> On Nov 23, 2010, at 9:27 PM, Cameron Zwarich wrote:
>>> 
>>>> There aren't very many good use cases for std::set. Most dominance frontiers are small, so a SmallPtrSet seemed like a good choice. I experimented with different small values of the inline capacity and found that 2 was best for performance.
>>> 
>>> Does the majority of sets really have only 2 or less members? Otherwise, a DenseSet might be better.
>> 
>> I didn't take any stats, but on the same benchmark using DenseSet is more than 2x slower.
> 
> Probably because each set mallocs.
> 
> On second thought, I am not so sure it is a good idea to replace std::set here. The dominance frontier data structure has quadratic size, and this change could blow up the constant factor.
> 
> When a SmallPtrSet overflows its 'small' size, it allocates space for 128 pointers. That uses more memory than a std::set for up to 32 entries which is probably most cases.

I wouldn't have guessed that the jump was so drastic. Could it be controlled with a template parameter? I can run some stats to guess a good value.

I also noticed that there is an extra pointer wasted for SmallStorage:

  /// SmallStorage - Fixed size storage used in 'small mode'.  The extra element
  /// ensures that the end iterator actually points to valid memory.
  const void *SmallStorage[SmallSizePowTwo+1];

Isn't a pointer to 1 past valid memory valid for comparisons in C++? Nothing should be dereferencing it.

> Actually, I think Chris wants to get rid of dominance frontiers entirely because of the memory requirements.

Yeah, Chris mentioned this and I have started looking at some other phi placement algorithms, at least for cases other than the first SRoA / mem2reg. I just want a fair comparison so I am speeding up dominance frontiers first.

Cameron



More information about the llvm-commits mailing list