[llvm] [AArch64] Tune unrolling prefs for more patterns on Apple CPUs (PR #149358)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 08:38:28 PDT 2025


================
@@ -4897,16 +4897,18 @@ getAppleRuntimeUnrollPreferences(Loop *L, ScalarEvolution &SE,
   // Limit to loops with trip counts that are cheap to expand.
   UP.SCEVExpansionBudget = 1;
 
-  // Try to unroll small, single block loops, if they have load/store
-  // dependencies, to expose more parallel memory access streams.
+  // Try to unroll small loops, of few-blocks with low budget, if they have
+  // load/store dependencies, to expose more parallel memory access streams,
+  // or if they do little work inside a block (i.e. load -> X -> store pattern).
   BasicBlock *Header = L->getHeader();
   if (Header == L->getLoopLatch()) {
     // Estimate the size of the loop.
     unsigned Size;
-    if (!isLoopSizeWithinBudget(L, TTI, 8, &Size))
+    unsigned Width = 10;
+    if (!isLoopSizeWithinBudget(L, TTI, Width, &Size))
----------------
jroelofs wrote:

If `Width` isn't going to be used elsewhere, this is the typical LLVM style for putting a name on it:

```suggestion
    if (!isLoopSizeWithinBudget(L, TTI, /*Width=*/10, &Size))
```

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


More information about the llvm-commits mailing list