This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is it Okay for GCC to do the following simplifications with "-ffast-math" flag
- From: Jeff Law <law at redhat dot com>
- To: Renlin Li <renlin dot li at arm dot com>, gcc at gcc dot gnu dot org
- Cc: Wilco dot Dijkstra at arm dot com, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>
- Date: Tue, 05 May 2015 15:47:26 -0600
- Subject: Re: Is it Okay for GCC to do the following simplifications with "-ffast-math" flag
- Authentication-results: sourceware.org; auth=none
- References: <5548C526 dot 8050705 at arm dot com>
On 05/05/2015 07:27 AM, Renlin Li wrote:
Hi all,
For the following illustrative code,
double f1(int x) { return (double)(float)x; } --> return (double)x;
int f2(double x) { return (int)(float)x; } --> return (int)x;
Is it Okay for the compiler to do the simplifications shown above with
fast-match enabled?
Standard practice these days for this kind of stuff is to have separate
flags for the various kinds of transformations. -ffast-math can then
turn on those which are usually OK.
It certainly helps if the proposed transformation is safe across
industry standard benchmarks. It also helps if you can show real
world cases where it helps and the domains where the transformations
result in unexpected results.
Ultimately it's a judgment call based on those kind of factors.
jeff