Skip to content

Conversation

mratsim
Copy link
Collaborator

@mratsim mratsim commented Mar 26, 2018

Currently with 31 - builtin_clz, this compiles into bsr + xor (from clz) + sub.
To massage GCC into producing a single bsr instruction, it is better to use xor than sub.
Those are equivalent since 31 has the form 2^n -1

Currently with `31 - builtin_clz`, this compiles into bsr + xor (from clz) + sub.
To massage GCC into producing a single bsr instruction, it is better to use xor than sub.
Those are equivalent since 31 has the form `2^n -1`
@Araq
Copy link
Member

Araq commented Apr 25, 2018

Who can confirm this is correct?

@dom96
Copy link
Contributor

dom96 commented Apr 25, 2018

Please add some comments in the code for such optimisations, not everyone has the time to dig through Git history to learn about these :)

@Varriount Varriount closed this Jun 4, 2018
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

Successfully merging this pull request may close these issues.

4 participants