On Thu, Jun 8, 2023 at 11:15 AM Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > On Thu, Jun 08, 2023 at 10:05:43AM +0100, Jonathan Wakely via Gcc-patches > wrote: > > > Looking at assembly, one of the differences I see is that the "after" > > > version has calls to realloc_insert(), while "before" version seems to > > > have > > > them inlined [2]. > > > > > > [1] > > > https://git.linaro.org/toolchain/ci/interesting-commits.git/tree/gcc/sha1/b7b255e77a271974479c34d1db3daafc04b920bc/tcwg_bmk-code_size-cpu2017fast/status.txt > > > > > > > > I find it annoying that adding `if (n < sz) __builtin_unreachable()` seems > > to affect the size estimates for the function, and so perturbs inlining > > decisions. That code shouldn't add any actual instructions, so shouldn't > > affect size estimates. > > > > I mentioned this in a meeting last week and Jason suggested checking > > whether using __builtin_assume has the same undesirable consequences, so I > > We don't support __builtin_assume (intentionally), if you mean > [[assume(n>=sz)]], > then because n >= sz doesn't have side-effects, it will be lowered to > exactly that if (n < sz) __builtin_unreachable(); - you can look at > -fdump-tree-all to confirm that. > > I agree that the inliner should ignore if (comparison) > __builtin_unreachable(); > from costs estimation. And inliner should ignore what we emit for > [[assume()]] > if there are side-effects. CCing Honza.
Agreed, that would be nice. Note that we have inliner limits in place to avoid compile-time and memory-usage explosion as well so these kind of "tricks" may be a way to defeat them. Richard. > > Jakub >