New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 13419 - Remove comma expression in std.uni #2485
Conversation
LGTM |
Yeah, thanks guys... Bored yawn. |
Yes, something really needs to be done about this annoying restriction. But it needs to be done in DMD. We should probably put more non-inlineable code into Phobos, to raise the pressure ;-) |
@schuetzm I agree. The problem is it's users who would loose on performance, while we shuffle work between compiler and phobos teams. So ideally it's first fix the compiler, then rewrite code. But alas compiler guys would say that since everybody in the know already writes code using comma to get inlining, it's not a top priority. Here we go catch-22. |
Agreed. I'm a little surprised to hear it doesn't inline this already.
We would? |
@yebblies Well, okay maybe they won't :) I wish to be proven wrong, it come up before, not a single time. There seems to always be some pressing matters far greater then inlining of basic if statements and multiple early returns. It especially hurts functions that return something. |
DMD's inlining is really poor. It gives up too easily. I always find that gdc's inlining is far superior. |
I am marking this as blocked until inlining issue is fixed in DMD. |
Looking at the first function, this can be inlined char truncate()(char ch) pure @safe
{
ch -= 0x80;
return ch < 0x40 ? ch : (badEncoding(), cast(char)0);
} But this can't: char truncate()(char ch) pure @safe
{
ch -= 0x80;
if (ch < 0x40) return ch;
badEncoding();
return cast(char)0);
} But this one can: char truncate()(char ch) pure @safe
{
ch -= 0x80;
if (ch < 0x40)
return ch;
else
{
badEncoding();
return cast(char)0);
}
} ie The if-and-fallthough means the inliner's primitive flow analysis can't tell that function 2 always returns and can therefore be turned into an expression. @DmitryOlshansky Of the other functions modified in this pull, which ones are actually prevented from being inlined? |
@yebblies I'll try to use the if/else wokraround and see if there any other patterns that can't be re-written or problematic. |
I still think the inliner should be improved. But at least that shouldn't block this PR anymore. |
@schuetzm Please update code to if/else branch to ensure inlining in dmd. |
9d256e6
to
6113fba
Compare
I changed all except the one in |
Looks reasonable; |
Yep, it is up to Dmitry to call it merge-ready |
Aye-aye. I'll just run my benchmarks with and without this patch. Somewhat busy at the moment, please nag me if I forget. |
Seems like all is in order. |
Auto-merge toggled on |
Issue 13419 - Remove comma expression in std.uni
Stumbled across the bugzilla issue related to the if/else branch inlining issue today; thought I should log it here (i dunno, for posterity, or perhaps somebody will take a look at it): https://issues.dlang.org/show_bug.cgi?id=7625 |
This is a patch by Ketmar Dark:
https://issues.dlang.org/show_bug.cgi?id=13419