[llvm] r184105 - Switch spill weights from a basic loop depth estimation to BlockFrequencyInfo.

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Jun 17 15:14:19 PDT 2013


On Jun 17, 2013, at 2:47 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:

> This is signed a sum of block frequencies once the normalization is gone. IIRC, my plan was to represent this as two BlockFrequency variables - a negative part and a positive part. That should tame the saturating fixpoint arithmetic in a sensible way.

In other words, I wanted to do something like this:

  BlockFrequency BiasN; // Sum of blocks that prefer a spill.
  BlockFrequency BiasP; // Sum of blocks that prefer a register.

Then:

 bool update(const Node nodes[]) {
   // Compute the weighted sum of inputs.
   BlockFrequency SumN = BiasN;
   BlockFrequency SumP = BiasP;
   for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I) {
     if (nodes[I->second].Value == -1)
       SumN += I->first;
     if (nodes[I->second].Value == 1)
       SumP += I->first;
   }

   Value = 0;
   if (SumN > SumP+Thres)
     Value = -1;
   if (SumP > SumN+Thres)
     Value = 1;

This should safely and symmetrically deal with the saturating block frequency arithmetic, and the result is independent of the order of the link vector.

It’s possible a simpler solution is just as good.

/jakob





More information about the llvm-commits mailing list