This is the mail archive of the
mailing list for the GCC project.
Weird constant folding of __builtin_remainder() with -frounding-math
- From: FX <fxcoudert at gmail dot com>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 20 Nov 2013 15:49:37 +0100
- Subject: Weird constant folding of __builtin_remainder() with -frounding-math
- Authentication-results: sourceware.org; auth=none
I reduced my problem to the following code:
int main (void)
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…