Re:Weird compiler bug – Same code, different results
by shakna on Friday January 29, 2021 @09:15PM
(#25965348)
The clang docs explicitly say that they don't support Annex F at all. Is this story finally going to change? So that you have at least partial support?
Re:Weird compiler bug – Same code, different results
by titzer on Friday January 29, 2021 @06:01PM
(#25963961)
No, they consistently perform optimizations that violate IEEE 754 rules, such as reassociation and commutation of expressions. These are difficult to observe (unless you are in the habit of observing -0 vs 0), but yes, you can observe them. They are very precisely specified by IEEE 754 and C/C++ compilers perform illegal optimizations.
Re:Weird compiler bug – Same code, different results
by jcranmer on Friday January 29, 2021 @06:11PM
(#25964061)
They do those optimizations when you enable fast-math flags. Some compilers (e.g., icc) enable those by default. When fast-math is not enabled, then the IEEE 754-violating optimizations are disabled.
Source: I've been working on such optimizations this past week. And that means establishing precisely which flags I need to have enabled in order for optimization to kick in.
Re:Weird compiler bug – Same code, different results
by zaitanz on Friday January 29, 2021 @06:30PM
(#25964249)
This is very true. Once upon a time -o3 would enable fast-math. We're very careful to ensure we use test models to verify the outputs of release binaries. Enabling fast-math as you have said optimises the equations in a way that produces different results.
(That reminds me, I need to harangue the llvm-libc folks to add that pragma to their fpenv code for correctness sake).