This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: FWD: FLOATING-POINT CONSISTENCY, -FFLOAT-STORE, AND X86
On Tue, Dec 15, 1998 at 11:12:01AM -0700, Jeffrey A Law wrote:
> For FP, we would like the ability to reassociate some expressions. Take
> (a * b * c * d) * e
>
> Right now we'll genrate
>
> t1 = a * b;
> t2 = t1 * c;
> t3 = t2 * d;
> t4 = t3 * e;
>
> Note the dependency of each insn on the previous insn. This can be a major
> performance penalty -- especially on targets which have dual FP units or where
> a fpmul isn't incredibly fast (data dependency stalls at each step).
>
> t1 = a * b;
> t2 = c * d;
> t3 = t1 * t2;
> t4 = t3 * e;
>
> Is a much better (and safe as far as I know) sequence. The first two insns
> are totally independent, which at the minimum reduces one of the 3 stall
> conditions due to data dependency. For a target with a pipelined FPU or
> dual FPUs the second sequence will be significantly faster.
It is safe in the sence that the language may not require evaluating
(a*b*c*d) in a specific order (ANSI C doesn't afaik). However for FP,
it can give different results. Think overflow for example, or when
rounding is set to infinity, you have: 0.1 * (0.1 * -1) != (0.1 * 0.1) * -1
--
Sylvain