3

I know that the SSEs are an alternative to the x87 floating point instruction, but is the x87 FPU still implemented in modern CPUs like Ivy-Bridge or Haswell?

Did SSEs replace the x87 instruction set?

Sean Lim
  • 33
  • 2

2 Answers2

7

The x87 FPU is still available. It may or may not use the same hardware as the SSE units, and it may be faster or may be slower, but your CPU will still understand the x87 instructions.

So no, it is not a clean replacement (there are also things you could do in x87 which are not supported in the SSE instruction set)

But consider that if they suddenly removed support for the x87 instructions, every program which relied on it would suddenly stop working.

Ouch.

jalf
  • 243,077
  • 51
  • 345
  • 550
  • 1
    However, as far as most compilers are concerned, x87 doesn't really exist anymore in 64-bit environments, as in, they won't generate code for it. They will usually generate SSE instructions even to work on single floating point numbers. – Sebastian Redl May 06 '13 at 19:55
  • 4
    @SebastianRedl: Many C and C++ compilers will still generate code for x87 when the `long double` type is explicitly used; for `float` and `double`, however, you’re absolutely correct. – Stephen Canon May 06 '13 at 20:00
  • 1
    @StephenCanon True for compilers where long double != double (not all of them), but who uses long double? ;) – Sebastian Redl May 06 '13 at 20:03
  • 3
    @SebastianRedl: my life would certainly be much easier if everyone would agree to stop using it. – Stephen Canon May 06 '13 at 20:03
  • A lot of people would have used 80-bit `long double` if compilers had decently supported it. Given three values a, b, and c, which are within a factor of 100 of each other, how efficiently can you write code that's guaranteed to compute `double d=a+b+c;` within 9/16LSB if the best type you have to work with is a 64-bit double? How about if you can do intermediate computations as 80-bit `long double`? – supercat Oct 19 '14 at 20:20
  • Even if an 80-bit `long double` took 16 bytes to store (ten useful bytes plus six padding), in most cases it wouldn't be necessary to store very many of them, and in those cases where it would be necessary to store a lot of them the alternative would generally be to store twice as many `doubles`, so the `long double` would still be a win. – supercat Oct 19 '14 at 20:22
0

As far as I know, there is still no SSE replacement for the x87 remainder instructions FPREM and FPREM1, which are typically used to implement C functions like fmod, remainder and remquo. So it will still be used for a while yet.

Simon Byrne
  • 7,694
  • 1
  • 26
  • 50