1

something bugged me about the instruction set extensions and the possible optimization of software for those. In the wikipedia article about the X86 instruction set is a chroniconal list of extensions, like MMX, SSE or AVX. I know i have to recompile a software if i whant it optimized for a new extension. But through other questions here i learned that it is not possible to pack several versions of compiled software in one executable. (For every new extension a new compilation.) My questions are:

  1. Does code compiled for a extension run on an older cpu without that extension?
  2. Is there a check for that extension in the compiled code? (IF MMX THEN A ELSE B or similar)
  3. How do commercial software like Photoshop or an video encoder handle this? Optimize those at all? Or do they optimize only for older extensions and exclude older CPUs from usage?
  4. Or is it possible to generade optimized code for every cpu generation and pack those in one executebale? Like fat binary but for one CPU family whith different extensions. (IF MMX THEN A ELSEIF MMX AND SSE THEN B or similar) And when the programm is starting it will only load the best optimized but runnable code. Is there a buzzword for this solution?

Thx

user2621742
  • 83
  • 1
  • 1
  • 4
  • _"it is not possible to pack several versions of compiled software in one executable"_ That's not technically true. You can detect supported CPU extensions and, if supported, switch to a code path that uses them (Truecrypt does this to support hardware AES). AFAIK it requires coding the extension instructions in assembly though, rather than letting the compiler generate them for you. – Colonel Thirty Two Feb 23 '15 at 15:12

0 Answers0