[PATCH] D159354: [SROA] Limit the number of allowed slices when trying to split allocas

Dhruv Chawla via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 08:18:01 PDT 2023


0xdc03 added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SROA.cpp:127
+static cl::opt<int>
+    SROAMaxAllocaSlices("sroa-max-alloca-slices", cl::init(32),
+                        cl::desc("Maximum number of alloca slices allowed "
----------------
nikic wrote:
> This limit is probably way too low. I'd expect something on the order of 1024 here, otherwise there will be regressions.
> This limit is probably way too low. I'd expect something on the order of 1024 here, otherwise there will be regressions.

The reason I put 32 was because I thought 1024 was quite slow... here's some statistics for different values (running opt -O3 on unoptimized IR produced by rustc):
```
2    : 0.05s user
4    : 0.04s user
8    : 0.06s user
16   : 0.06s user
32   : 0.08s user
64   : 0.05s user
128  : 0.12s user
256  : 0.56s user
512  : 0.59s user
1024 : 6.62s user
2048 : 53.27s user
```
I tried to run opt without the patch, but I had to give up after 20 minutes. The exponential growth here is quite crazy, but it seems manageable at 512.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159354/new/

https://reviews.llvm.org/D159354



More information about the llvm-commits mailing list