This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: const folding vs multiply-add
- To: Dale Johannesen <dalej at apple dot com>
- Subject: Re: const folding vs multiply-add
- From: Richard Henderson <rth at redhat dot com>
- Date: Fri, 9 Nov 2001 16:51:16 -0800
- Cc: gcc at gcc dot gnu dot org
- References: <017E7510-D4AC-11D5-9999-003065C86F94@apple.com>
On Thu, Nov 08, 2001 at 04:52:10PM -0800, Dale Johannesen wrote:
> Currently the tree-based const folding changes x*2.0 to x+x.
> This is not always the right thing to do on a machine with
> a multiply-add instruction (ppc):
> for(i=...) { x[i] = y[i] * 2.0 + z; }
> Best code is to pull the load of 2.0 out of the loop and
> generate a single multiply-add instruction within the loop.
Given the existance of the C99 fma function, it would be a
good idea to create a well-known multiply-add pattern so
that we can recognize this function as a built-in.
If we have that, we can notice that the machine supports
this sort of thing and generate the code to use the fused
instruction right from the start.
r~