[llvm] [SystemZ] Add inlining heuristic for IV update in callee. (PR #113135)

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 06:48:11 PDT 2024


================
@@ -74,6 +74,40 @@ static void countNumMemAccesses(const Value *Ptr, unsigned &NumStores,
     }
 }
 
+static void getNumGEPIndexUses(const Value *V, unsigned &NumGEPIdxUses) {
+  for (const User *U : V->users()) {
+    if (const auto *LI = dyn_cast<LoadInst>(U)) {
+      assert(isa<AllocaInst>(V) && LI->getType()->isIntegerTy() &&
+             "Expected a load only from the alloca, with integer type.");
----------------
JonPsson1 wrote:

Makes sense - patch updated.

The interesting function in search.cpp had quite a few of these GEP uses (>25 IIRC), which wasn't that common over benchmarks. I experimented a bit and it seemed to work well to not have any particular threshold, but just check that it is in fact used as an addressing register. If there is ever a case where we would need to raise the bar a bit here I guess we could go back to the original version, and in the meanwhile I agree it's a bit clearer like this.

https://github.com/llvm/llvm-project/pull/113135


More information about the llvm-commits mailing list