This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/57071] Optimize (-1)**k to 1 - 2 * mod(K, 2)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57071

Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Joost.VandeVondele at mat
                   |                            |dot ethz.ch

--- Comment #2 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2013-04-26 06:52:13 UTC ---
indeed, very common to write this.. however, this is even more common in a loop

DO i=0,N
   y=y+(-1)**i * x**i
ENDDO

so there you really would like to have this converted to some form that uses
...
DO i=..
    tmp_s=-tmp_s  
    tmp_x=tmp_x*x
    y=y+tmp_s*tmp_x
ENDDO

I'm not sure how the different forms behave in this respect.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]