zlacker

[parent] [thread] 2 comments
1. maskli+(OP)[view] [source] 2024-01-24 06:42:26
GP seems to be saying that you can flag individual functions in GCC, thereby avoiding this issue: only flagged functions would be compiled with fast math semantics.
replies(1): >>lorenz+71
2. lorenz+71[view] [source] 2024-01-24 06:55:13
>>maskli+(OP)
This only work if it's a leaf function that will throw away the result. If you feed the result of your --fast-math function into other working code you risk breaking it.
replies(1): >>lifthr+v5
◧◩
3. lifthr+v5[view] [source] [discussion] 2024-01-24 07:45:32
>>lorenz+71
`-ffast-math` is fully local, asides from GCC's unexpected `crtfastmath.o` linkage which is global.

Functions with `-ffast-math` enabled still return fp values via usual registers and in usual formats. If some function `f` is expected to return -1.0 to 1.0 for particluar inputs, `-ffast-math` can only make it to return 1.001 or NaN instead. If another function without `-ffast-math` expects and doesn't verify f's return value, it will surely misbehave, but only because the original analysis of f no longer holds.

`-ffast-math` the compiler option is bad because this effect is not evident from the code. Anything visible in the code should be okay.

[go to top]