1. Branching inside function: maybe the memory access and branching cost pays up when the processor supports the bests instructions, but if makes the worst case slower.
1 2 3 4 5 6 7 | real32 Sin(real32 Angle) { if (ProcessorHasSSE4) // Compute sine with SSE4 else // Compute sine with SSE2 } |
2. Switching function at startup: prevents function from being inlined.
1 | Sin = ProcessorHasSSE4 ? SinSSE4 : SinSSE2; |
Does someone know another way to do this? maybe modifying instructions at runtime... :ohmy:
PS.: Sorry for the bad English, it's not my native language