optimization/3928: The -ffast-,math option does not re-associate f.p. multiply
trt@acm.org
trt@acm.org
Fri Aug 3 11:06:00 GMT 2001
>Number: 3928
>Category: optimization
>Synopsis: The -ffast-,math option does not re-associate f.p. multiply
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: pessimizes-code
>Submitter-Id: net
>Arrival-Date: Fri Aug 03 11:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Tom Truscott
>Release: gcc version 3.0 20010326 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Programs compiled with -ffast-math should re-associate
and fold floating point constant multiplication.
>How-To-Repeat:
Compile the following program with -ffast-math
and observe in the assembly code that there are two
multiplies by 3, rather than one multiply by 9:
multiply_by_nine (x)
double x;
{
return x * 3 * 3;
}
>Fix:
In gcc/fold_const.c, at approx line 5577, change:
if (! wins
&& (! FLOAT_TYPE_P (type)
|| (flag_fast_math && code != MULT_EXPR)))
to
if (! wins && (! FLOAT_TYPE_P (type) || flag_fast_math))
(Arguably the "code != MULT_EXPR" was intended to be ==,
and so by mistake gcc has been re-associating + and -
rather than *. Given that it has been this way
and no one has noticed, I think gcc should just
re-associate all such expressions.
It might be appropriate to revise the comment
preceeding this code, though.)
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list