[PATCH] Cleanup register pressure calculation in MachineLICM

Daniel Jasper djasper at google.com
Fri Apr 3 09:24:54 PDT 2015


================
Comment at: lib/CodeGen/MachineLICM.cpp:896
@@ +895,3 @@
+    else
+      RegPressure[Class] -= ClassAndCost.second;
+  }
----------------
Turns out, the + was actually correct, but I need to compare against -ClassAndCost.second above.

================
Comment at: lib/CodeGen/MachineLICM.cpp:902
@@ +901,3 @@
+                                                      bool ConsiderSeen) {
+  DenseMap<unsigned, int> Cost;
+  if (MI->isImplicitDef())
----------------
qcolombet wrote:
> I would prefer a reference on the DenseMap.
> Copying it around may not be efficient.
I think this is exactly what RVO was designed for and think that the code is cleaner and nicer with it.

Even if RVO should fail one day (which I don't think it will), I doubt the performance difference could be measured.

================
Comment at: lib/CodeGen/MachineLICM.cpp:1120
@@ -1127,3 +1119,3 @@
 /// register pressure.
-bool MachineLICM::CanCauseHighRegPressure(DenseMap<unsigned, int> &Cost,
+bool MachineLICM::CanCauseHighRegPressure(const DenseMap<unsigned, int>& Cost,
                                           bool CheapInstr) {
----------------
qcolombet wrote:
> This part of the patch is unrelated to this change (i.e., constify + for-range).
> Please commit that separately.
Yeah, this was actually change when I was using a SmallVector, now it is just cleanup. Submitted separately in r234018.

http://reviews.llvm.org/D8604

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list