Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

x87 and out-of-order execution

k_sarnath
Beginner
375 Views
Since most x87 instructions rely on TOP OF STACK as an implied parameter -- Will it affect out of order execution?
Will switching to scalar SSE code give dramatic performance (like doing a MUL and ADD together etc..)

Thanks,
0 Kudos
1 Solution
capens__nicolas
New Contributor I
375 Views
It affects out-of-order execution in the same way as other operand dependencies. Also note that the XCHG instruction is virtually for free (latency 0) since it is handled as a register renaming.

However, x87 by default computes 80-bit results, which for operations like division and square root are very slow. You can explicitly lower that precision to 64- or 32-bit though through the control word.

Also, some compilers are not that good at creating efficient x87 code due to the complications ofmanaging theregister stack. There can generate notably faster scalar SSE code. As far as I'm aware the difference on most reputable compilers is very minor though.

Furthermore on x64 SSE has access to 16 registers which for some algorithms reduces spilling.

But if you really want to improve performance you should probably look into parallelising your code to make full use of SSE (and later AVX).

View solution in original post

0 Kudos
2 Replies
capens__nicolas
New Contributor I
376 Views
It affects out-of-order execution in the same way as other operand dependencies. Also note that the XCHG instruction is virtually for free (latency 0) since it is handled as a register renaming.

However, x87 by default computes 80-bit results, which for operations like division and square root are very slow. You can explicitly lower that precision to 64- or 32-bit though through the control word.

Also, some compilers are not that good at creating efficient x87 code due to the complications ofmanaging theregister stack. There can generate notably faster scalar SSE code. As far as I'm aware the difference on most reputable compilers is very minor though.

Furthermore on x64 SSE has access to 16 registers which for some algorithms reduces spilling.

But if you really want to improve performance you should probably look into parallelising your code to make full use of SSE (and later AVX).
0 Kudos
k_sarnath
Beginner
375 Views
Thanks for the detailed answer! It was useful.
0 Kudos
Reply