Trivially re-materializable instructions have spill weights that are half of what...
authorEvan Cheng <evan.cheng@apple.com>
Wed, 4 Apr 2007 07:04:55 +0000 (07:04 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 4 Apr 2007 07:04:55 +0000 (07:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35658 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp

index a01889a643e6ebf29407163dbfef230df8c91026..3858a9868cfd3e9f7048f433be42afb3eaf7d146 100644 (file)
@@ -164,13 +164,13 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
             unsigned reg = rep(mop.getReg());
             mii->getOperand(i).setReg(reg);
 
-            // If the definition instruction is re-materializable, its spill
-            // weight is zero.
             LiveInterval &RegInt = getInterval(reg);
-            if (!RegInt.remat) {
-              RegInt.weight +=
-                (mop.isUse() + mop.isDef()) * pow(10.0F, (int)loopDepth);
-            }
+            float w = (mop.isUse()+mop.isDef()) * powf(10.0F, (float)loopDepth);
+            // If the definition instruction is re-materializable, its spill
+            // weight is half of what it would have been normally.
+            if (RegInt.remat)
+              w /= 2;
+            RegInt.weight += w;
           }
         }
         ++mii;