2 ms·
Basically, the optimizer failed to notice that (long)(c?a:b) can be turned into (c?(long)a:(long)b) And that since a and b are literals, the cast to
by jimrandomh 13y ago
Basically, the optimizer failed to notice that
(long)(c?a:b)
can be turned into
(c?(long)a:(long)b)
And that since a and b are literals, the cast to long is free in the latter case, but costs two instructions and a register in the former case.
Note that this is very much compiler-specific (the person asking the question didn't say which compiler he was using), and I did not get the same slowdown in the Mono compiler (with or without LLVM).