This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Wed, 20 Nov 2013, Marc Glisse wrote:
On Wed, 20 Nov 2013, FX wrote:I reduced my problem to the following code: int main (void) { double x; x = 1 / 3.; __builtin_printf ("%.30lg %.30lg\n", __builtin_remainder(1., 1/3.), 1/3.); __builtin_printf ("%.30lg %.30lg\n", __builtin_remainder(1., x), x); }This calls __builtin_remainder() twice, once with constant arguments, once with a variable. Without rounding math, the two results agree (5.55e-17), but with -frounding-math, the constant case changes (-2.71e-20).On x86_64-apple-darwin, things are even weirder than x86_64-linux (the above): constant-case with -frounding-math -m64 is unchanged, while constant case with -frounding-math -m32 follows the linux results.I donât think this is right, since remainder() is supposed to be unaffected by the rounding mode. Yet, before I open a PR, I wanted to see if someone understands whatâs going onâDid you really test on x86_64-linux? I am only seeing this -2.71e-20 when using -mfpmath=387.
Oups, didn't finish my email.So 1./3 is computed with 80 bits, the first computation is very nice, then the call to printf forces that number to memory where it is rounded to 64 bits (anything can randomly cause that rounding at any time), and that is then used for the second computation.
-frounding-math is a red herring, -O0 could have disabled the constant folding.
-- Marc Glisse
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |