Skip to content
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

proposal: cmd/compile: allow bound check skip via directive #66318

Closed
lollllcat opened this issue Mar 14, 2024 · 4 comments
Closed

proposal: cmd/compile: allow bound check skip via directive #66318

lollllcat opened this issue Mar 14, 2024 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Proposal
Milestone

Comments

@lollllcat
Copy link

Proposal Details

We propose adding a new directive to skip bound checks in the compile toolchain. The new directive will allow the unnecessary bound check to be eliminated if the flag AllowBCSkip is turned on. The current bound check elimination passes (BCE and CSE) are relatively simple and leave many redundant bound checks unremoved. Such unnecessary checks bring extra performance overhead. Improving compiler optimization pass is another solution but it can be time consuming and requires sophisticated analysis. This proposal aims for a straightforward optimization if users know the bound check is always unnecessary but unremoved.

Specifically,
-allowbcskip flag from the command line during compilation will enable this new feature.
//go:noboundcheck directive at the function level will allow the bound check to be skipped for the specific function if the check is always redundant. It works similarly as go:noinline directive.
boundsCheck within ssagen will check the new flag and directive to optionally skipping bound check code generation.

Grit link: https://go-review.googlesource.com/c/go/+/571539. Filing a new issue to make it clearer what we are proposing.
Thanks.

cc
@jinlin-bayarea

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 14, 2024
@seankhliao seankhliao changed the title cmd/compile: allow bound check skip via directive proposal: cmd/compile: allow bound check skip via directive Mar 14, 2024
@gopherbot gopherbot added this to the Proposal milestone Mar 14, 2024
@seankhliao
Copy link
Member

Duplicate of #47529

@seankhliao seankhliao marked this as a duplicate of #47529 Mar 14, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2024
@randall77
Copy link
Contributor

I think this is just proposing the already-existing -gcflags=-B flag?

@lollllcat
Copy link
Author

@randall77
Copy link
Contributor

So -allowbcskip just changes a //go:noboundcheck directive from a no-op to its intended semantics? Not sure why that additional step is needed. When would you have //go:noboundcheck directives but then not use -allowbcskip?
As @seankhliao says, the individual directive has already been proposed and declined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Proposal
Projects
None yet
Development

No branches or pull requests

4 participants