Re:Weird compiler bug – Same code, different results
by cperciva on Friday January 29, 2021 @04:53PM
(#25963163)
Probably the author is accidentally getting 80-bit "extended double" arithmetic.
[ Parent
| on HN ]
Re:Weird compiler bug – Same code, different results
by cozzyd on Friday January 29, 2021 @06:48PM
(#25964404)
That should be clear from looking at the assembly, shouldn't it? Don't think the floating point environment can change that but I could be wrong.
Floating-point rounding modes seem more likely to me. The author should be able to dump the floating point configuration to confirm, I'm sure.
Re:Weird compiler bug – Same code, different results
by cperciva on Friday January 29, 2021 @08:33PM
(#25965113)
The same x86 instructions are used for arithmetic on float/double/extended types; the difference is a precision setting in the x87 control word.
Re:Weird compiler bug – Same code, different results
by cozzyd on Friday January 29, 2021 @08:48PM
(#25965202)
Well in most cases I've looked at generated assembly (not that often), the xmm registers are used even for scalar operations, which I thought was the default option for gcc on x86-64, but I suppose it might differ on different systems (or perhaps 32-bit mode was used for some reason).
Re:Weird compiler bug – Same code, different results
by cperciva on Friday January 29, 2021 @09:24PM
(#25965383)
Right, if you're using xmm regs you're getting double or single precision. Sometimes the x87 regs get used and that's when "accidentally computed with extra precision and then double-rounded" comes up.