This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/47990] Missed promotion of double precision constants to single precision for -funsafe-math-optimizations
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 1 Aug 2011 13:07:08 +0000
- Subject: [Bug middle-end/47990] Missed promotion of double precision constants to single precision for -funsafe-math-optimizations
- Auto-submitted: auto-generated
- References: <bug-47990-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47990
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-01 13:07:00 UTC ---
The intel compiler does not perform this optimization even at -fast. It does
perform the demotion on
float foo (float x, float y)
{
return (int)((float)(x/y + 0.5)) * y;
}
though, even with default optimization (also with the conversion to
int removed or associated to apply to the first operand of the
multiplication only).
So they leave alone what looks like a usual "rounding" pattern.
My original idea was to fold (int)((double)(x/y) + 0.5) to (int)(x/y + 0.5f),
similar to (float)((double)(x/y) + 0.5) to (x/y + 0.5f) which we already
do (at -O0, in convert_to_real).