-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: DCE before inlining does not remove dead if
s
#29189
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
Comments
Are you positive that the I haven't actually checked; I'm simply pointing out that this might be an issue with the |
On my phone but the condition is probably being printed from n.Orig. But there are still extraneous OIF and OLITERAL (“if” and “true”) nodes there. |
if
sif
s
@mvdan I don't have complete certainty, but for sure those if bodies are not empty, see e.g. Lines 1105 to 1114 in 944a9c7
|
The inliner has logic for making sure constant if expressions don't cost anything extra: go/src/cmd/compile/internal/gc/inl.go Lines 396 to 401 in e6ae4e8
The diagnostic message might be a little confusing, but I don't think it should be affecting the output binaries at all. The if bodies are empty because of the deadcode elimination pass done after typechecking function bodies: go/src/cmd/compile/internal/gc/typecheck.go Lines 3882 to 3892 in e6ae4e8
|
Closing because I think this is working as intended. Please let us know to reopen though if you have evidence that a constant if statement is actually affecting inlining (e.g., either it's affecting budgeting, or somehow affecting the resulting assembly negatively). |
DCE performed before inlining seems to eliminate the body of
if
s where the condition can be proven to always evaluate tofalse
, but fails to eliminate the if statement and the condition themselves. So, for example, the following code:that should be DCEd (before inlining) to:
but currently DCE transforms it to:
Found by going over the output of
GO_GCFLAGS=-m ./make.bash
(the following is just a sample, see #8421 (comment) for details):This is a problem because part of the inlining budget will be consumed by the vestigial
if
s. If DCE before inlining completely removed thoseif
s more functions would likely become candidate for inlining.Likely related to #23521 and possibly to #29095.
The text was updated successfully, but these errors were encountered: