[llvm-commits] [llvm] r98023 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Chris Lattner clattner at apple.com
Tue Mar 16 18:41:24 PDT 2010


On Mar 16, 2010, at 6:37 PM, Jakob Stoklund Olesen wrote:

>>> 
>>> The attached graph shows the coalescer runtime as a function of the array length in my tiny test function (inlining disabled). The patch kicks in at N=500 and reduces runtime to nothing.
>> 
>> Is it possible to fix or improve the N^2 algorithm?
> 
> Yes, I think so. From the end of SimpleJoin:
> 
>  // Update the liveintervals of sub-registers.
>  if (TargetRegisterInfo::isPhysicalRegister(LHS.reg))
>    for (const unsigned *AS = tri_->getSubRegisters(LHS.reg); *AS; ++AS)
>      li_->getOrCreateInterval(*AS).MergeInClobberRanges(*li_, LHS,
>                                                    li_->getVNInfoAllocator());
> 
> 
> MergeInClobberRanges() is linear in the size of LHS, and SimpleJoin() is called once for each LiveRange in LHS -> quadratic runtime.
> 
> However, SimpleJoin() is called to merge a trivial RHS into a complex LHS. It may be as simple as calling MergeClobberRanges(RHS) instead. I would have to read the code more closely.

Nice, definitely sounds like a worthwhile experiment.

> Ideally, I want to avoid physreg joining altogether, and use better hinting instead. Half of the coalescer would go away, and all of the bugs ;-)

cool, do that too! ;-)

-Chris



More information about the llvm-commits mailing list