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

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Mar 8 17:37:52 PST 2010


On Mar 8, 2010, at 5:23 PM, Evan Cheng wrote:

> Is 1000 scientific? :-)

No. That would require measuring when the LiveInterval size where it outgrows cache. I didn't do that :-(

I have also seen cases where a virtual register LiveInterval becomes too big. That is a lot harder to fix. I think the real problem is the extra indirection in SlotIndex. If SlotIndex were just an unsigned in disguise, each LiveRange would be just 16 bytes, and all ranges for a register would be in contiguous memory. 

> On Mar 8, 2010, at 4:59 PM, Jakob Stoklund Olesen wrote:
> 
>> Author: stoklund
>> Date: Mon Mar  8 18:59:48 2010
>> New Revision: 98023
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=98023&view=rev
>> Log:
>> Disable physical register coalescing when the number of live ranges for the
>> physreg becomes ridiculously high.
>> 
>> std::upper_bound may be log(N), but for sufficiently large live intervals, it
>> becomes log(N)*cachemiss = a long long time.
>> 
>> This patch improves coalescer time by 4500x for a function with 20000
>> function calls. The generated code is different, but not significantly worse -
>> the allocator hints are almost as good as physreg coalescing anyway.
>> 
>> Modified:
>>   llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
>> 
>> Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=98023&r1=98022&r2=98023&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Mar  8 18:59:48 2010
>> @@ -1671,8 +1671,20 @@
>>        // density, do not join them, instead mark the physical register as its
>>        // allocation preference.
>>        LiveInterval &JoinVInt = SrcIsPhys ? DstInt : SrcInt;
>> +        LiveInterval &JoinPInt = SrcIsPhys ? SrcInt : DstInt;
>>        unsigned JoinVReg = SrcIsPhys ? DstReg : SrcReg;
>>        unsigned JoinPReg = SrcIsPhys ? SrcReg : DstReg;
>> +
>> +        // Don't join with physregs that have a ridiculous number of live
>> +        // ranges. The data structure performance is really bad when that
>> +        // happens.
>> +        if (JoinPInt.ranges.size() > 1000) {
>> +          mri_->setRegAllocationHint(JoinVInt.reg, 0, JoinPReg);
>> +          ++numAborts;
>> +          DEBUG(dbgs() << "\tPhysical register too complicated, abort!\n");
>> +          return false;
>> +        }
>> +
>>        const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg);
>>        unsigned Threshold = allocatableRCRegs_[RC].count() * 2;
>>        unsigned Length = li_->getApproximateInstructionCount(JoinVInt);
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 





More information about the llvm-commits mailing list