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: An analogue to gcc's __builtin_expect #6837

Closed
mrakh opened this issue Oct 27, 2020 · 1 comment
Closed

Proposal: An analogue to gcc's __builtin_expect #6837

mrakh opened this issue Oct 27, 2020 · 1 comment

Comments

@mrakh
Copy link
Contributor

mrakh commented Oct 27, 2020

In GNU C, one can use the __builtin_expect construct in a conditional statement as a hint to the compiler, where the resulting assembly is arranged in a way that reduces the expected number of jumps and thus minimizes CPU pipeline stalls. It's often used in hot code where branching is unavoidable. I believe that exposing similar functionality to Zig would be useful, either as a built-in, or as a qualifier keyword used with conditional flow constructs (e.g. if, while).

@rohlem
Copy link
Contributor

rohlem commented Oct 27, 2020

duplicate of #489

@mrakh mrakh closed this as completed Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants