[llvm-commits] [llvm] r98023 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Tue Mar 16 18:37:34 PDT 2010
On Mar 16, 2010, at 11:27 AM, Chris Lattner wrote:
>
> On Mar 9, 2010, at 10:15 AM, Jakob Stoklund Olesen wrote:
>
>>
>> On Mar 9, 2010, at 9:41 AM, Jakob Stoklund Olesen wrote:
>>
>>>
>>> On Mar 8, 2010, at 5:37 PM, Jakob Stoklund Olesen wrote:
>>>
>>>>
>>>> On Mar 8, 2010, at 5:23 PM, Evan Cheng wrote:
>>>>
>>>>> Is 1000 scientific? :-)
>>>>
>>>
>>> The coalescer timing formed a perfect parabola with t=4.1s at N=2000. This is not a caching effect - the coalescer is quadratic in the number of function calls!
>>
>> 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.
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 ;-)
/jakob
More information about the llvm-commits
mailing list