This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization Question
- To: gcc at gcc dot gnu dot org
- Subject: Re: Optimization Question
- From: Andy Vaught <andy at maxwell dot la dot asu dot edu>
- Date: Mon, 26 Jul 1999 17:55:10 -0700 (MST)
>I got curious about whether the compiler was smart enough to recognize
>simple factorizations and tried the following fortran code:
>
>
> a=b*(c+d) I
>
>versus
> a=b*c+b*d II
>
>The current snapshot doesn't recognize the equivalence and simply
>generates two fmuls and and a faddp for case II (only one fmuls for
>I). Is this something that could be build into the optimization?
This sort of optimization is prohibited by the f90/95 spec for a good
reason-- floating-point arithmetic is not associative. Which is to say,
you can get a different answer depending on which form you use. The best
thing to do is to give the programmer what he asked for.
Andy
----------------- XOLD(K,IC,I)=
Andy Vaught .... DO ITERS=1, 10 XOLD(K,IC,I)
andy@maxwell.la.asu.edu | | /CALLMSOLVE(A,B,X,I,ITERS,TOL)+(RANNYU(0)
Arizona State University ======|WRITE(6,'(I5,2X,F12.6)')ITERS,TOL -HALF)
Tempe, Arizona USA OOOOOO \ENDDORETURN PARAMETER(ZERO=1.D0)*TENTH*DELTA