This is the mail archive of the 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]

Re: Weird constant folding of __builtin_remainder() with -frounding-math

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.

Marc Glisse

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]