[PATCH] D17652: [CGP] Duplicate addressing computation in cold paths if required to sink addressing mode

David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 16:17:11 PST 2016


davidxl added a comment.

A general problem I see in address sinking optimization is the lack of global cost analysis -- the analysis should consider

1. the cost of the folded instruction (if the address can be folded in)
2. whether the original address instruction can be eliminated (for instance, only sunk into some of the uses)
3. if the address can not be folded, what is the additional cost
4. what is the estimated register pressure reduction with the address sinking

The above should be all weighted with the block frequency information.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:1767
@@ +1766,3 @@
+  // into their uses.
+  if (CI->hasFnAttr(Attribute::Cold))
+    for (auto &Arg : CI->arg_operands()) {
----------------
Why limiting this just to call instruction? How about any other uses of address expressions in cold blocks?  Also why just check 'cold' attribute of the callsite? How about other cold blocks? 

================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:1772
@@ +1771,3 @@
+      unsigned AS = Arg->getType()->getPointerAddressSpace();
+      return optimizeMemoryInst(CI, Arg, Arg->getType(), AS);
+    }
----------------
If we extend this to handle calls -- the optimizeMemoryInst's comments need to be fixed -- the first instruction may not just be memorInstr.


http://reviews.llvm.org/D17652





More information about the llvm-commits mailing list