You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
seankhliao
changed the title
cmd/compile: allow bound check skip via directive
proposal: cmd/compile: allow bound check skip via directive
Mar 14, 2024
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.
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 asgo:noinline
directive.boundsCheck
withinssagen
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
The text was updated successfully, but these errors were encountered: