It seems that bitselect() does not offer any benefit over using (a&b)|(~a&c). None at all. Not that I hoped that the compiler will somehow generate magically better IL code using some magic instructions, but I was thinking that there could be some wise trick they do. I thought that bitselect() is there for some reason.
Decided to make a simple test. Basically the round function in MD5 (round1 and 2) is:
1) (b & c) | ((~b) & d)
which can be directly replaced with
2) bitselect(b,d,c)
and the third option is to rewrite it as:
3) d ^ (b & (c ^ d))
1) and 2) give the same speed and 3) is a bit faster, but the difference is negligible.
Argh
Guess what...
Decided to make a simple test. Basically the round function in MD5 (round1 and 2) is:
1) (b & c) | ((~b) & d)
which can be directly replaced with
2) bitselect(b,d,c)
and the third option is to rewrite it as:
3) d ^ (b & (c ^ d))
1) and 2) give the same speed and 3) is a bit faster, but the difference is negligible.
Argh
Guess what...