[llvm] [ARM] Speedups for CombineBaseUpdate. (PR #129725)

Andrew Savonichev via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 04:54:51 PST 2025


================
@@ -16284,27 +16299,19 @@ static SDValue CombineBaseUpdate(SDNode *N,
       unsigned NewConstInc = UserOffset - Offset;
       SDValue NewInc = DCI.DAG.getConstant(NewConstInc, SDLoc(N), MVT::i32);
       BaseUpdates.push_back({User, NewInc, NewConstInc});
+      if (BaseUpdates.size() > MaxBaseUpdates)
+        break;
     }
   }
 
   // Try to fold the load/store with an update that matches memory
   // access size. This should work well for sequential loads.
-  //
-  // Filter out invalid updates as well.
   unsigned NumValidUpd = BaseUpdates.size();
-  for (unsigned I = 0; I < NumValidUpd;) {
+  for (unsigned I = 0; I < NumValidUpd; I++) {
     BaseUpdateUser &User = BaseUpdates[I];
-    if (!isValidBaseUpdate(N, User.N)) {
----------------
asavonic wrote:

Good idea. The downside is that there are two calls to TryCombineBaseUpdate, so we potentially call isValidBaseUpdate twice. This only happens if we can convert an instruction to post increment, but there is a dependency on operands that we cannot break. Shouldn't be a common case, and with MaxSteps parameter being set, it is not as bad for compile time.

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


More information about the llvm-commits mailing list