Hello, On Mon, Oct 02 2023, Hanke Zhang via Gcc wrote: > Hi, I have some questions about the strategy and behavior of function > splitting in gcc, like the following code: > > int glob; > void f() { > if (glob) { > printf("short path\n"); > return; > } > // do lots of expensive things > // ... > } > > I hope it can be broken down like below, so that the whole function > can perhaps be inlined, which is more efficient. > > int glob; > void f() { > if (glob) { > printf("short path\n"); > return; > } > f_part(); > } > > void f_part() { > // do lots of expensive things > // ... > } > > > But on the contrary, gcc splits it like these, which not only does not > bring any benefits, but may increase the time consumption, because the > function call itself is a more resource-intensive thing. > > int glob; > void f() { > if (glob) { > f_part(); > return; > } > // do lots of expensive things > // ... > } > > void f_part() { > printf("short path\n"); // just do this???? > } > > Are there any options I can offer to gcc to change this behavior? Or > do I need to make some changes in ipa-split.cc?
I'd suggest you file a bug to Bugzilla with a specific example that is mis-handled, then we can have a look and discuss what and why happens and what can be done about it. Thanks, Martin