11 ms·
unions are well known for scaring compilers away from many types of optimizations when encountered. For example, if you're writing a SIMD vector class then pret
by ajg1977 16y ago
unions are well known for scaring compilers away from many types of optimizations when encountered. For example, if you're writing a SIMD vector class then pretty much the worst thing you can do is put the SIMD data type in a union with a float array.
- haberman 16y agoThe union is irrelevant, even with a union the compiler eliminated the branch in another test I ran where both functions had the same prototype. I'm on an iPad at the moment so can't verify, but I'd be willing to bet that exactly the same code would be generated if the two function pointers were passed as separate parameters (ie not in a union)