Hacker News new | past | comments | ask | show | jobs | submit login

See https://godbolt.org/z/3Yqbceaza for what godbolt says clang produces.

Keep in mind that this doesn't use the fact that we know that the input is between 0 to 63.




> Keep in mind that this doesn't use the fact that we know that the input is between 0 to 63.

You can use __builtin_assume for this: https://godbolt.org/z/K4jKhxnTq


An assert() also does the trick: https://godbolt.org/z/MecvMGPdW

edit uh but when asserts are disabled it won't work: https://godbolt.org/z/4TMs1Wc5z

unless you roll your own assert: https://godbolt.org/z/4v35rrTvn


9*x/64 still reduces to 2 instructions

https://godbolt.org/z/6WsWqh4ah




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: