[PATCH] Experiment with keeping GEPs near calls

Quentin Colombet qcolombet at apple.com
Thu Mar 12 16:51:11 PDT 2015


Hi Daniel,

Thanks for your patience.

First of all, yes this new logic needs to be hidden behind a flag until it is properly tuned.
In particular, we miss a profitability model, i.e., reduce exceeded register pressure, before doing the sinking.

Now, regarding the code itself, the sinking logic, modulo the missing profitability model, looks right to me, but it does not seem correct to have it in HoistOutOfLoop :).

Cheers,
-Quentin


================
Comment at: lib/CodeGen/MachineLICM.cpp:776
@@ +775,3 @@
+       I != Preheader->instr_end(); ++I) {
+    if (IsLoopInvariantInst(*I) && !HasLoopPHIUse(I))
+      Candidates.push_back(I);
----------------
A comment here would be welcome.
I suspect you are just interested in the fact that the instruction shouldn't use or define physical registers as well as memory operand (which is part of what this function does).
Without a comment, at first glance, this is confusing because instructions in the preheader should be loop invariant!

================
Comment at: lib/CodeGen/MachineLICM.cpp:782
@@ +781,3 @@
+    const MachineOperand &MO = I->getOperand(0);
+    if (!MO.isDef() || !MO.isReg() || MO.getReg() == 0)
+      continue;
----------------
The idiom is usually !MO.getReg()

================
Comment at: lib/CodeGen/MachineLICM.cpp:789
@@ +788,3 @@
+    for (MachineInstr &MI : MRI->use_instructions(MO.getReg())) {
+      if (!MI.isCopy()) {
+        CanSink = false;
----------------
I believe this check shouldn't be needed for the general approach.

http://reviews.llvm.org/D7259

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






More information about the llvm-commits mailing list