[LLVMdev] SIV tests in LoopDependence Analysis, Sanjoy's patch

Duncan Sands baldrick at free.fr
Tue Apr 3 01:07:36 PDT 2012


Hi,

>> private:
>>   Value *source, *destination;
>>   Kind kind;
>>   SmallVector<const Level *, 4>  levels;
>
> I'd malloc an ordinary vector of the appropriate length,
> since we know the length at allocation time.

if the number of levels is usually small it is usually better to use a
SmallVector (like in the code above) and do:
   levels.reserve(known_size);
That way you avoid a malloc if known_size <= 4.

Ciao, Duncan.



More information about the llvm-dev mailing list