[Issue 7625] inlining only works with explicit else branch
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Mar 30 09:53:48 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=7625
hsteoh at quickfur.ath.cx changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #6 from hsteoh at quickfur.ath.cx ---
The fix was incomplete. Here's a test case for which dmd fails to inline a
function that's basically identical to another inlined function, the only
difference being the omission of `else`:
------
int tembo(int x, int y)
{
if (y == 0) return 0;
x++;
return x / y;
}
int pembo(int x, int y)
{
if (y == 0) return 0;
else
{
x++;
return x / y;
}
}
int twiga(int x, int y, int z)
{
auto w = tembo(x, y);
return w * z;
}
int simba(int x, int y, int z)
{
auto w = pembo(x, y);
return w * z;
}
------
Compiling with `dmd -O -inline` and disassembling, I found that twiga still
contains a function call to tembo, whereas simba inlines pembo. Commenting out
the x++ from tembo and pembo causes successful inlining of both functions in
twiga and simba. So it seems that the inliner is still unable to deal with the
case where the else block (with omitted `else`) contains anything more than
just a simple return statement.
--
More information about the Digitalmars-d-bugs
mailing list